Open Burnie09 opened 6 years ago
This is correct and has been reported before.
Unless an order has been partially filled a re-order will always use the same size, which inevitable causes a insufficient funds error if the price moved up.
Looking at the code one possible solution would be to remove the size attribute during a price adjust if the order has not been partially filled, this way executeSignal recalculates the size according to the new price.
PR ready.
Test it and report back @Burnie09
It seems to be working (added some more debug to check);
2018-02-10 20:16:18 - placing buy order... 2018-02-10 20:16:19 - buy order for 0.08683668 placed at 6866.91 EUR (596.2996662588)
2018-02-10 20:16:17 6862.32 BTC-EUR +0.20% 1 - 49.64 0.0347 0.0196 buying 0.00000 BTC 596.29 EUR
2018-02-10 20:16:22 - 6867.33 vs our 6866.91 2018-02-10 20:16:23 - buy order timed out, adjusting price 2018-02-10 20:16:24 - buy order for 0.08683137 placed at 6867.33 EUR (596.2996721421)
2018-02-10 20:16:34 - 6867.34 vs our 6867.33 2018-02-10 20:16:35 - buy order timed out, adjusting price 2018-02-10 20:16:36 - buy order for 0.08683124 placed at 6867.34 EUR (596.2996477016) ... 2018-02-10 20:17:32 - order status: open 2018-02-10 20:17:32 - 6890.09 vs our 6889.67 2018-02-10 20:17:32 - cancelling order 2018-02-10 20:17:33 - buy order timed out, adjusting price 2018-02-10 20:17:34 - placing buy order... 2018-02-10 20:17:34 - buy order for 0.08654466 placed at 6890.08 EUR (596.2996309728) 2018-02-10 20:17:36 - order status: done
buy order completed at 2018-02-10 20:17:34: 0.08683668 BTC at 6890.08 EUR total 598.311 EUR 0.3374% slippage (orig. price 6866.91 EUR) execution: a minute
2018-02-10 20:18:00 6867.75 BTC-EUR -0.28% 2 50.74 + 0.0354 0.0376 bought 0.08654 BTC 0.00 EUR
Seems the size in the completion text is the original size (0.08683668), but it works. - 100% bought.
100% bought
👍
I wonder why we are tracking size
as _order.orig_size
in my_trades
though 🤔
nvm.
If this was a partial order we of course would wont the original size duh
We could change it in placeOrder
and (maybe) add a adjusted
flag if _order
exists.
Thats actually a silly hack as it doesn't account for timed out partial orders.
I'll switch one of my bots to 100% and think of a proper solution once i have the time.
Just to let you know. I can confirm your findings. Partial orders just stops. (And then you don't seem to manually buy the rest either.)
System information
Describe the problem
( GDAX.BTC-EUR / maker )
When zenbot is adjusting a (maker) buy, it adjusts price, but doesn't seem to adjust size to buy. Having c.buy_pct = 100 will result in not enough funds. Workaround is using c.buy_pct = 99 (will not work if slippage > ~1.01%)
example below:
Source code / logs
2018-02-10 16:23:31 6938.79 BTC-EUR +0.11% 2 --- 28.15 -0.0643 0.0243 0.00000 BTC 609.93 EUR +0.00% +1.99%
manual limit BUY command executed 2018-02-10 16:23:42 - placing buy order... 2018-02-10 16:23:42 - buy order placed at 6938.53 EUR 2018-02-10 16:23:44 - order status: open 2018-02-10 16:23:46 - order status: open 2018-02-10 16:23:48 - order status: open 2018-02-10 16:23:50 - order status: open 2018-02-10 16:23:50 - 6938.54 vs our 6938.53 2018-02-10 16:23:50 - cancelling order 2018-02-10 16:23:51 - buy order timed out, adjusting price 2018-02-10 16:23:51 - placing buy order... 2018-02-10 16:23:51 - not enough balance for buy, aborting - 0.08790594 @ 6938.69 2018-02-10 16:23:51 - not enough balance, or signal switched, cancel buy
2018-02-10 16:23:52 6938.79 BTC-EUR +0.11% 2 --- 28.15 -0.0643 0.0243 0.00000 BTC 609.93 EUR +0.00% +1.99%