Thank you for sharing this, I’ve been tinkering with something similar to no avail. I keep breaching my maxPosi. I set it equal to the net of my two open positions (buys/sells). Was wondering how to tru-up to the exchange periodically to ensure that there is no position drift, would you have anything that can help with that => I found sync_positions but haven’t been able to get it working (that was about a month ago so am more proficient with the code.
I am using one of firetron’s dca models and trying to stop when I reach a certain “maxPosi”. I’ve inserted the following in Exit() and Go() as described below. for some reason doesn’t seem that efficient.
Bot Description:
-- Firetron's Hedged DCA Dipper
--
-- Runs a long and a short each doing dollar cost averaging strategy.
-- Expands positions on an interval and exits whenever there is a profit.
-- Only expands a position when its profit is less than a trigger.
Add’s
netPos = (LongAmount() - ShortAmount())
if netPos < 0 and Abs(netPos) > maxPosi then
ExitCheckShort(debugInfo)
elseif netPos > 0 and netPos > maxPosi then
ExitCheckLong(debugInfo)
else
end
Code Blocks Updated
-- ------------------------------------
-- Exiting
-- ------------------------------------
function Exit ()
local debugInfo = GetDebugInfo()
netPos = (LongAmount() - ShortAmount())
if netPos < 0 and Abs(netPos) > maxPosi then
ExitCheckShort(debugInfo)
elseif netPos > 0 and netPos > maxPosi then
ExitCheckLong(debugInfo)
else
end
ExitCheckShort(debugInfo)
ExitCheckShort(debugInfo)
end
Second Spot
function Go ()
local debugInfo = GetDebugInfo()
if debugInfo.isVerbose then
SafeLog(logHRule)
end
netPos = (LongAmount() - ShortAmount())
if netPos < 0 and Abs(netPos) > maxPosi then
ExitCheckShort(debugInfo)
elseif netPos > 0 and netPos > maxPosi then
ExitCheckLong(debugInfo)
else
end
GoCheckLong(debugInfo)
GoCheckShort(debugInfo)
end
-
This reply was modified 2 years, 5 months ago by Hedgehog.
-
This reply was modified 2 years, 5 months ago by Hedgehog.
-
This reply was modified 2 years, 5 months ago by Hedgehog.
-
This reply was modified 2 years, 5 months ago by Hedgehog.