From 31bf3a7124325287172f5953abc5961004674adc Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Fri, 26 Jul 2019 10:41:44 +0800 Subject: [PATCH] [Fix] convert position related str to float/int --- vnpy/gateway/okexf/okexf_gateway.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vnpy/gateway/okexf/okexf_gateway.py b/vnpy/gateway/okexf/okexf_gateway.py index 7a3eca7d..28138c41 100644 --- a/vnpy/gateway/okexf/okexf_gateway.py +++ b/vnpy/gateway/okexf/okexf_gateway.py @@ -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)