[Fix] convert position related str to float/int
This commit is contained in:
parent
f85a7a54d5
commit
31bf3a7124
@ -387,28 +387,28 @@ class OkexfRestApi(RestClient):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for pos_data in data["holding"][0]:
|
for pos_data in data["holding"][0]:
|
||||||
if float(pos_data["long_qty"]) > 0:
|
if int(pos_data["long_qty"]) > 0:
|
||||||
pos = PositionData(
|
pos = PositionData(
|
||||||
symbol=pos_data["instrument_id"].upper(),
|
symbol=pos_data["instrument_id"].upper(),
|
||||||
exchange=Exchange.OKEX,
|
exchange=Exchange.OKEX,
|
||||||
direction=Direction.LONG,
|
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"]),
|
frozen=float(pos_data["long_qty"]) - float(pos_data["long_avail_qty"]),
|
||||||
price=pos_data["long_avg_cost"],
|
price=float(pos_data["long_avg_cost"]),
|
||||||
pnl=pos_data["realised_pnl"],
|
pnl=float(pos_data["realised_pnl"]),
|
||||||
gateway_name=self.gateway_name,
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.gateway.on_position(pos)
|
self.gateway.on_position(pos)
|
||||||
|
|
||||||
if float(pos_data["short_qty"]) > 0:
|
if int(pos_data["short_qty"]) > 0:
|
||||||
pos = PositionData(
|
pos = PositionData(
|
||||||
symbol=pos_data["instrument_id"],
|
symbol=pos_data["instrument_id"],
|
||||||
exchange=Exchange.OKEX,
|
exchange=Exchange.OKEX,
|
||||||
direction=Direction.SHORT,
|
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"]),
|
frozen=float(pos_data["short_qty"]) - float(pos_data["short_avail_qty"]),
|
||||||
price=pos_data["short_avg_cost"],
|
price=float(["short_avg_cost"]),
|
||||||
pnl=pos_data["realised_pnl"],
|
pnl=float(["realised_pnl"]),
|
||||||
gateway_name=self.gateway_name,
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.gateway.on_position(pos)
|
self.gateway.on_position(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user