new trader config option

This commit is contained in:
Nicolás Sánchez 2024-10-31 09:52:14 -03:00
parent b3d22c0fa2
commit 82686a04ab
4 changed files with 29 additions and 23 deletions

View File

@ -1,5 +1,6 @@
2024.10.31: 2024.10.31:
. Added an option to set the wait time before sending a new safety order. . Added an option to set the wait time before sending a new safety order.
. Added a per-trader option to enable or disable slippage checks.
2024.10.30: 2024.10.30:
. Changes trying to catch the wrong base amount bug. . Changes trying to catch the wrong base amount bug.

View File

@ -7,6 +7,7 @@
"safety_order_scale": 0.0105, #Size multiplier of every subsequent safety order. (check strategy documentation for more details) "safety_order_scale": 0.0105, #Size multiplier of every subsequent safety order. (check strategy documentation for more details)
"write_logs": false, #Write logs to file. "write_logs": false, #Write logs to file.
"calculate_fees": true, #Take into account the fees when calculating profits. "calculate_fees": true, #Take into account the fees when calculating profits.
"check_slippage": true, #Slippage checks before sending orders.
"cleanup": true, #Execute the cleanup routine every trader (re)start. "cleanup": true, #Execute the cleanup routine every trader (re)start.
"telegram": true, #Send Telegram notifications. "telegram": true, #Send Telegram notifications.
"tp_mode": 3, #Take profit mode. (check strategy documentation for more details) "tp_mode": 3, #Take profit mode. (check strategy documentation for more details)

View File

@ -5,7 +5,6 @@ Mandatory:
2. Instead of giving a list of order_ids to each trader, give a list of the open orders and that's it (for easier future development, partial order fills for example) 2. Instead of giving a list of order_ids to each trader, give a list of the open orders and that's it (for easier future development, partial order fills for example)
3. Deploying script, both for testnet and for mainnet. 3. Deploying script, both for testnet and for mainnet.
4. Maintain local orderbooks for each trading pair. 4. Maintain local orderbooks for each trading pair.
5. Global option for slippage checks.
Would be nice to have: Would be nice to have:

View File

@ -24,6 +24,9 @@ class trader:
self.max_short_safety_orders = 45 self.max_short_safety_orders = 45
if "max_short_safety_orders" in config_dict: if "max_short_safety_orders" in config_dict:
self.max_short_safety_orders = config_dict["max_short_safety_orders"] self.max_short_safety_orders = config_dict["max_short_safety_orders"]
self.check_slippage = True
if "check_slippage" in self.config_dict:
self.check_slippage = self.config_dict["check_slippage"]
self.start_time = int(time.time()) self.start_time = int(time.time())
self.total_amount_of_quote=0 self.total_amount_of_quote=0
self.total_amount_of_base=1 self.total_amount_of_base=1
@ -192,6 +195,7 @@ class trader:
return 1 return 1
#check slippage #check slippage
if self.check_slippage:
self.broker.logger.log_this("Checking slippage...",2,self.pair) self.broker.logger.log_this("Checking slippage...",2,self.pair)
self.status_dict["pause_reason"] = "start_bot - checking slippage" self.status_dict["pause_reason"] = "start_bot - checking slippage"
if self.check_orderbook_depth(self.broker.get_slippage_default_threshold(),self.config_dict["order_size"]): if self.check_orderbook_depth(self.broker.get_slippage_default_threshold(),self.config_dict["order_size"]):
@ -914,6 +918,7 @@ class trader:
#self.safety_order_index = 0 #self.safety_order_index = 0
self.config_dict = self.reload_config_dict() self.config_dict = self.reload_config_dict()
if self.check_slippage:
self.broker.logger.log_this("Checking slippage...",2,self.pair) self.broker.logger.log_this("Checking slippage...",2,self.pair)
price_to_compare = self.broker.get_top_bid_price(self.pair) if self.is_short else self.broker.get_top_ask_price(self.pair) price_to_compare = self.broker.get_top_bid_price(self.pair) if self.is_short else self.broker.get_top_ask_price(self.pair)
if abs(filled_order["price"]-price_to_compare)/filled_order["price"]>self.broker.get_slippage_default_threshold(): if abs(filled_order["price"]-price_to_compare)/filled_order["price"]>self.broker.get_slippage_default_threshold():