cyberjunky / 3commas-cyber-bots

3Commas bot helpers, AltRank, GalaxyScore, Watchlists, Auto-Compound, TrailingStopLoss, TakeProfitIncrement
MIT License
209 stars 68 forks source link

Request: Automatic Compound and grid modifying #6

Open Ferrox85 opened 2 years ago

Ferrox85 commented 2 years ago

Hi,

Great work on this! You've asked for idea's to do.

What I would like is automatic gridbot management. I do this by hand and consumes a lot of time monitoring this and modifying the grids if it gained and the price moved outside the grid.

I have 2 ideas:

Thing to keep in mind: Sometimes you need to stop the grid if modifying it, before accepting the new settings. Not sure this is a 3commas gui problem.

cyberjunky commented 2 years ago

Will have look, my gridbot experience is limited, but lets see...

cyberjunky commented 2 years ago

@Ferrox85 I quickly wrote the basic framework, whats missing is the logic.

What do we need, keep the middle of the grid on the price? Or do we fetch more data like orders and work with those?

ron@laptop-ubuntu:~/3commas-cyber-bots(main)$ ./gridbot.py 
2021-11-12 20:16:49,276 - gridbot - INFO - 3Commas bot helper gridbot
2021-11-12 20:16:49,276 - gridbot - INFO - Started at Friday 20:16:49 12-11-2021
2021-11-12 20:16:49,277 - gridbot - INFO - Loaded configuration from '/home/ron/3commas-cyber-bots/gridbot.ini'
2021-11-12 20:16:49,277 - gridbot - INFO - Notifications are enabled
2021-11-12 20:16:49,278 - gridbot - INFO - Reloaded configuration from '/home/ron/3commas-cyber-bots/gridbot.ini'
2021-11-12 20:16:49,867 - gridbot - INFO - Current gridbot settings :
2021-11-12 20:16:49,868 - gridbot - INFO - Name: My Grid Bot TEST
2021-11-12 20:16:49,877 - gridbot - INFO - Pair: USDT_BTC
2021-11-12 20:16:49,877 - gridbot - INFO - Upper price: 69000.0
2021-11-12 20:16:49,878 - gridbot - INFO - Lower price: 58849.0
2021-11-12 20:16:49,878 - gridbot - INFO - Quantity per grid: 0.08925
2021-11-12 20:16:49,878 - gridbot - INFO - Grids quantity: 10
2021-11-12 20:16:50,019 - gridbot - INFO - Fetched 3Commas price for pair USDT_BTC 63758.93 OK
2021-11-12 20:16:50,019 - gridbot - INFO - Price for USDT_BTC is 63758.93
2021-11-12 20:16:50,020 - gridbot - INFO - Next update in 3600 Seconds at 21:16:50
Ferrox85 commented 2 years ago

Thank you for your work, when I have time I'll dive in to it!

I think we need the gains to, to calculate the amount we can put back in the grid.

I have time tomorrow to give look in to it.

cyberjunky commented 2 years ago

This is what is avaulabe from the bot itself, haven't looked yet what is available for gridbot deals The grid line with status None shows up as waiting in my graph, strange...

{'id': 1009981, 'account_id': 30616081, 'account_name': 'Paper Account 12345', 'is_enabled': True, 'grids_quantity': '10', 'created_at': '2021-11-12T18:50:27.047Z', 'updated_at': '2021-11-12T20:34:04.513Z', 'strategy_type': 'manual', 'upper_stop_loss_enabled': False, 'lower_stop_loss_enabled': False, 'lower_price': '58899.0', 'lower_stop_loss_price': None, 'lower_stop_loss_action': 'stop_bot', 'upper_price': '70050.0', 'upper_stop_loss_price': None, 'upper_stop_loss_action': 'stop_bot', 'quantity_per_grid': '0.08925', 'leverage_type': 'not_specified', 'leverage_custom_value': None, 'name': 'My Grid Bot TEST', 'pair': 'USDT_BTC', 'start_price': '64076.56', 'grid_price_step': '1239.0', 'current_profit': '110.47016925', 'current_profit_usd': '110.47016925', 'total_profits_count': '1', 'bought_volume': '5704.75780875', 'sold_volume': '5803.8298605', 'profit_percentage': '0.2130801012239838867944017', 'current_price': '64256.55', 'investment_base_currency': '0.44625', 'investment_quote_currency': '21690.4275', 'grid_lines': [{'price': '65094.0', 'side': 'sell', 'order_placed': True}, {'price': '63855.0', 'side': None, 'order_placed': False}, {'price': '58899.0', 'side': 'buy', 'order_placed': True}, {'price': '60138.0', 'side': 'buy', 'order_placed': True}, {'price': '61377.0', 'side': 'buy', 'order_placed': True}, {'price': '62616.0', 'side': 'buy', 'order_placed': True}, {'price': '66333.0', 'side': 'sell', 'order_placed': True}, {'price': '67572.0', 'side': 'sell', 'order_placed': True}, {'price': '68811.0', 'side': 'sell', 'order_placed': True}, {'price': '70050.0', 'side': 'sell', 'order_placed': True}], 'editable': True}
Ferrox85 commented 2 years ago

Well, I think all the info is there, but it is hard to manage those gridbots, or compounding them manually.

What to keep in mind:

Because the gain result is in the quoted asset, maybe it is an idea to add an extra grid line below the current last grid line. So when it is the most interesting you convert it. Or you need to increase the quantity per grid (which is preferable, but you need to buy more of the asset. And here comes the tricky part. This is not easily possible with 3commas. I usually buy manually of the asset needed to increase this quantity per grid. If you buy to many, you running short of quoted asset, and you are not able to change it anymore (or you need te sell manually again).

Well, it is complex to automate this. I think the main thing to do is: -automatic chasing of the grid while maintaining the grid spacing in % and number of grid quantity -Find a way of automatic compounding and add to the grid quantity (not sure if this is even possible while I am thinking about this because of the need of buying asset manually...?)

I've tried by gui to add a grid line below the current price to buy an extra line with the pofit I made.. But then it needs more of the quoted asset.

Maybe you have thoughts on this topic.. The more I think about it, the harder it gets...