Update onetoken_gateway.py
This commit is contained in:
parent
0fae58f333
commit
e14672ab8c
@ -618,21 +618,23 @@ class OnetokenTradeWebsocketApi(WebsocketClient):
|
|||||||
# Futures
|
# Futures
|
||||||
elif _type == "future":
|
elif _type == "future":
|
||||||
long_position = PositionData(
|
long_position = PositionData(
|
||||||
symbol=account_data["contract"],
|
symbol=X["contract"],
|
||||||
exchange=Exchange.OKEX, # todo add Exchange
|
exchange=Exchange(self.exchange.upper()),
|
||||||
direction=Direction.LONG,
|
direction=Direction.LONG,
|
||||||
volume=account_data["total_amount_long"],
|
price=X["average_open_price_long"],
|
||||||
frozen=account_data["total_amount_long"] - \
|
volume=X["total_amount_long"],
|
||||||
account_data["available_long"],
|
pnl=X["unrealized_long"],
|
||||||
|
frozen=X["frozen_position_long"],
|
||||||
gateway_name=self.gateway_name,
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
short_position = PositionData(
|
short_position = PositionData(
|
||||||
symbol=account_data["contract"],
|
symbol=X["contract"],
|
||||||
exchange=Exchange.OKEX, # todo add Exchange
|
exchange=Exchange(self.exchange.upper()),
|
||||||
direction=Direction.SHORT,
|
direction=Direction.SHORT,
|
||||||
volume=account_data["total_amount_short"],
|
price=X["average_open_price_short"],
|
||||||
frozen=account_data["total_amount_short"] - \
|
volume=X["total_amount_short"],
|
||||||
account_data["available_short"],
|
pnl=X["unrealized_short"],
|
||||||
|
frozen=X["frozen_position_short"],
|
||||||
gateway_name=self.gateway_name,
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.gateway.on_position(long_position)
|
self.gateway.on_position(long_position)
|
||||||
@ -677,20 +679,19 @@ class OnetokenTradeWebsocketApi(WebsocketClient):
|
|||||||
|
|
||||||
trade_timestamp = order_data["last_update"][11:19]
|
trade_timestamp = order_data["last_update"][11:19]
|
||||||
self.trade_count += 1
|
self.trade_count += 1
|
||||||
|
if order_data["dealt_amount"]:
|
||||||
trade = TradeData(
|
self.trade_count += 1
|
||||||
symbol=order.symbol,
|
trade = TradeData(
|
||||||
exchange=order.exchange,
|
symbol=order.symbol,
|
||||||
orderid=order.orderid,
|
exchange=order.exchange,
|
||||||
tradeid=str(self.trade_count),
|
orderid=orderid,
|
||||||
direction=order.direction,
|
tradeid=str(self.trade_count),
|
||||||
price=order_data["average_dealt_price"],
|
direction=order.direction,
|
||||||
volume=order_data["last_dealt_amount"],
|
price=order_data["average_dealt_price"],
|
||||||
gateway_name=self.gateway_name,
|
volume=order_data["dealt_amount"],
|
||||||
time=trade_timestamp
|
gateway_name=self.gateway_name,
|
||||||
)
|
time=trade_timestamp)
|
||||||
|
self.gateway.on_trade(trade)
|
||||||
self.gateway.on_trade(trade)
|
|
||||||
|
|
||||||
def ping(self):
|
def ping(self):
|
||||||
""""""
|
""""""
|
||||||
|
Loading…
Reference in New Issue
Block a user