diff --git a/trader/binance_future_trader.py b/trader/binance_future_trader.py index 867b3e6..cdc7f36 100644 --- a/trader/binance_future_trader.py +++ b/trader/binance_future_trader.py @@ -291,6 +291,7 @@ def start(self): for s in deleted_positions: del self.positions.positions[s] # delete the position data if the position notional is very small. + self.positions.save_data() pos_symbols = self.positions.positions.keys() # the position's symbols, if there is {"symbol": postiondata}, you get the symbols here. pos_count = len(pos_symbols) # position count @@ -326,7 +327,7 @@ def start(self): index += 1 self.place_order(s, signal['pct'], signal['pct_4h']) - self.positions.save_data() + def place_order(self, symbol: str, hour_change: float, four_hour_change: float): diff --git a/trader/binance_spot_trader.py b/trader/binance_spot_trader.py index 86e9114..78254fc 100644 --- a/trader/binance_spot_trader.py +++ b/trader/binance_spot_trader.py @@ -231,7 +231,7 @@ def start(self): value = pos * bid_price if value < self.symbols_dict.get(s, {}).get('min_notional', 0): print(f"{s} notional value is small, delete the position data.") - deleted_positions.append(s) # + deleted_positions.append(s) # # del self.positions.positions[s] # delete the position data if the position notional is very small. else: avg_price = pos_data.get('avg_price') @@ -302,6 +302,7 @@ def start(self): for s in deleted_positions: del self.positions.positions[s] # delete the position data if the position notional is very small. + self.positions.save_data() pos_symbols = self.positions.positions.keys() # 有仓位的交易对信息. pos_count = len(pos_symbols) # 仓位的个数. @@ -333,8 +334,6 @@ def start(self): index += 1 self.place_order(s, signal['pct'], signal['pct_4h']) - self.positions.save_data() - def place_order(self, symbol: str, hour_change: float, four_hour_change: float): buy_value = config.initial_trade_value