Skip to content

Commit

Permalink
save the data when changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
51bitquant committed Nov 16, 2021
1 parent 3549375 commit 5a9de5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion trader/binance_future_trader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):

Expand Down
5 changes: 2 additions & 3 deletions trader/binance_spot_trader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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) # 仓位的个数.

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5a9de5d

Please sign in to comment.