[紧急补丁] 币安持仓信息变成多条,净仓,多,空

This commit is contained in:
msincenselee 2020-05-06 16:21:07 +08:00
parent f8b24c9be1
commit c5e600ce25

View File

@ -548,6 +548,8 @@ class BinancefRestApi(RestClient):
for d in data: for d in data:
# self.gateway.write_log(d) # self.gateway.write_log(d)
volume = float(d["positionAmt"]) volume = float(d["positionAmt"])
if d.get('positionSide') != 'BOTH':
continue
position = PositionData( position = PositionData(
accountid=self.accountid, accountid=self.accountid,
symbol=d["symbol"], symbol=d["symbol"],
@ -560,7 +562,8 @@ class BinancefRestApi(RestClient):
gateway_name=self.gateway_name, gateway_name=self.gateway_name,
) )
self.gateway.on_position(position) self.gateway.on_position(position)
if position.symbol == 'BTCUSDT':
self.gateway.write_log(f'{position.__dict__}\n {d}')
# self.gateway.write_log("持仓信息查询成功") # self.gateway.write_log("持仓信息查询成功")
def on_query_order(self, data: dict, request: Request) -> None: def on_query_order(self, data: dict, request: Request) -> None:
@ -879,7 +882,7 @@ class BinancefTradeWebsocketApi(WebsocketClient):
gateway_name=self.gateway_name, gateway_name=self.gateway_name,
) )
holding_pnl += float(pos_data['up']) holding_pnl += float(pos_data['up'])
self.gateway.on_position(position) # self.gateway.on_position(position)
for acc_data in packet["a"]["B"]: for acc_data in packet["a"]["B"]:
if acc_data['a'] != 'USDT': if acc_data['a'] != 'USDT':