zenbot
zenbot copied to clipboard
Allow currency_capital and asset_capital options also in live mode
These options look awesome, but they only work in paper, or with the simulator:
--currency_capital <amount> for paper trading, amount of start capital in currency
--asset_capital <amount> for paper trading, amount of start capital in asset
I'd like to run zenbot on an exchange where I still want to trade manually, and I want to be sure that zenbot won't use all the capital or asset it can find.
This would be useful for zenbot newbies like me, that after running simulations and paper mode would like to try zenbot by allocating to the bot a small amount to use, to begin, and then increase after gaining confidence with zenbot.
To me, this is a really important feature. To be honest, now I'm not using zenbot in live because this feature is missing.
Is there a reason why this was limited only in paper mode?
When a buy/sell order is confirmed, the currency capital and asset capital values should be updated. Then instead of checking the balance on the exchange, it should refer to these values for the next signals.
It should work without hiccups. Thoughts?
In live mode the bot always syncs your balance prior to creating a order to make sure you actually have enough funds to create the order in the first place.
engine.js executeSignal()
// if s.signal
// 1. sync balance
// 2. get quote
// 3. calculate size/price
// 4. validate size against min/max sizes
// 5. cancel old orders
// 6. place new order
// 7. record order ID and start poll timer
// 8. if not filled after timer, repeat process
// 9. if filled, record order stats
Will i get what you are after i don't find it very practical to allow people to override the real capital (using currency|asset_capital
) in live mode for this very reason, as you would need to make sure that they don't credit the bot more than they actually have.
Furthermore the bot (and you) would loss complete track of your current balance.
One possible solution would be to add something like a --currency_hold
and --capital_hold
option that you subtract from the balance prior to calculating the order size and if the sum of it is 0 (or less) cancel the signal unless its positive.
e.g. you trade BTC-USD pair with a balance of 1 BTC and 10000 USD using --asset_hold=0.1 --currency_hold=1000
the bot would be limited to creating a (initial) maximum sell order of 0.9 BTC
and buy order of 9000 USD
and make sure that you always hold at least 0.1 BTC
and 1000 USD
Think of it like a sell/loss protection but for your capital.
This way its possible to utilize the feature in live, paper and sim mode.
Thanks for the answer @defkev iIf I understand correctly, you suggest as an alternative to hold on the account 0.1 and hold also 1000 USD. What happens if in the meantime I deposit another 5000 USD because I want to trade them manually? The bot still will hold the 1000 USD you configured, but will trade all the rest, which I didn't want it to do.
With an "hold" option as you are suggesting, everytime I deposit money to an exchange or do a manual trade I'd have to kill the bot, then re-run it by adapting the amount to hold, to save my money or my crypto. It would not be very convenient.
For this reason I still think that limiting the bot as I suggested is better. The only downside is, as you spotted correctly: if the balance is less than what you assigned the bot, there will be an error, which can be handled.
E.g. I have 1500 and I assign the bot --currency_capital 1000
(USD). There is no buy signal for many hours, but in the meantime I get inspired to trade manually, using the exchange website, so I trade 1000 USD. The resulting balance now 500. When the bot tries to do a buy trade there would be an API error: because it tried to buy for 1000 USD with a balance of 500. Alight, error handling: do the buy order with 500 instead of 1000. Or even prevent the error by checking the balance just to be sure. If the balance is less, adapt the buy order and buy just for 500. See what I mean? If in the meantime 500 magically re-appear after I finalize my manual trade, the bot (which should be smart enough to know how much it spent so far) will think "Cool! There are 500 USD that I can still use for another buy order, since my master allowed me to trade 1000", and make another buy order for 500 USD.
For selling, same thing. If in the meantime I do some manual trades and buy crypto, I don't want the bot to sell all of it, or a % of it (as it's possible now to configure), I want it to sell up to an Y amount. Ideally up to the amount it bought before, that should be the default on my opinion.
Ideally it should be possible to configure the bot ()that would be a different option), so that it starts with a capital X, does purchases (one, or multiple ones) to buy an Y amount of crypto, and sells only that Y amount of crypto. Then re-invests what it got back from the trade(s) (initial amount X + some gains, or initial amount - losses if the bot sold in loss) and does more trades. If you want to withdraw the gains the bot did for you, you stop the bot, withdraw, and restart it with the reset profits option.
Hello team, do we have a solution for the issue of @firepol ? I think is very important to have this param to limit possible great loss !!! Thx