[Fix] convert position related str to float/int

This commit is contained in:
vn.py 2019-07-26 10:41:44 +08:00
parent f85a7a54d5
commit 31bf3a7124

View File

@ -387,28 +387,28 @@ class OkexfRestApi(RestClient):
return
for pos_data in data["holding"][0]:
if float(pos_data["long_qty"]) > 0:
if int(pos_data["long_qty"]) > 0:
pos = PositionData(
symbol=pos_data["instrument_id"].upper(),
exchange=Exchange.OKEX,
direction=Direction.LONG,
volume=pos_data["long_qty"],
volume=int(pos_data["long_qty"]),
frozen=float(pos_data["long_qty"]) - float(pos_data["long_avail_qty"]),
price=pos_data["long_avg_cost"],
pnl=pos_data["realised_pnl"],
price=float(pos_data["long_avg_cost"]),
pnl=float(pos_data["realised_pnl"]),
gateway_name=self.gateway_name,
)
self.gateway.on_position(pos)
if float(pos_data["short_qty"]) > 0:
if int(pos_data["short_qty"]) > 0:
pos = PositionData(
symbol=pos_data["instrument_id"],
exchange=Exchange.OKEX,
direction=Direction.SHORT,
volume=pos_data["short_qty"],
volume=int(pos_data["short_qty"]),
frozen=float(pos_data["short_qty"]) - float(pos_data["short_avail_qty"]),
price=pos_data["short_avg_cost"],
pnl=pos_data["realised_pnl"],
price=float(["short_avg_cost"]),
pnl=float(["realised_pnl"]),
gateway_name=self.gateway_name,
)
self.gateway.on_position(pos)