如果position data 文件不存在, 创建它
This commit is contained in:
parent
ffb2952fce
commit
363cb17ea4
@ -31,6 +31,12 @@ class PositionManager:
|
||||
# 待处理订单信息
|
||||
self.pending_orders = {} # {order_id -> LocalOrder}
|
||||
self.data_path = os.path.join(Config.DATA_DIR, self.strategy_name + "_positions.json")
|
||||
# 确保数据目录存在
|
||||
os.makedirs(os.path.dirname(self.data_path), exist_ok=True)
|
||||
# 如果文件不存在,创建一个空文件
|
||||
if not os.path.exists(self.data_path):
|
||||
with open(self.data_path, 'w') as f:
|
||||
f.write('{}')
|
||||
self.load_data()
|
||||
|
||||
def update_position(self, code, direction, amount):
|
||||
|
Loading…
x
Reference in New Issue
Block a user