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,19 +679,18 @@ 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"]:
|
||||||
|
self.trade_count += 1
|
||||||
trade = TradeData(
|
trade = TradeData(
|
||||||
symbol=order.symbol,
|
symbol=order.symbol,
|
||||||
exchange=order.exchange,
|
exchange=order.exchange,
|
||||||
orderid=order.orderid,
|
orderid=orderid,
|
||||||
tradeid=str(self.trade_count),
|
tradeid=str(self.trade_count),
|
||||||
direction=order.direction,
|
direction=order.direction,
|
||||||
price=order_data["average_dealt_price"],
|
price=order_data["average_dealt_price"],
|
||||||
volume=order_data["last_dealt_amount"],
|
volume=order_data["dealt_amount"],
|
||||||
gateway_name=self.gateway_name,
|
gateway_name=self.gateway_name,
|
||||||
time=trade_timestamp
|
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