commit
33bd9c56c7
@ -644,27 +644,26 @@ class OkexWebsocketApi(WebsocketClient):
|
|||||||
|
|
||||||
def on_depth(self, d):
|
def on_depth(self, d):
|
||||||
""""""
|
""""""
|
||||||
for tick_data in d:
|
symbol = d["instrument_id"]
|
||||||
symbol = d["instrument_id"]
|
tick = self.ticks.get(symbol, None)
|
||||||
tick = self.ticks.get(symbol, None)
|
if not tick:
|
||||||
if not tick:
|
return
|
||||||
return
|
|
||||||
|
|
||||||
bids = d["bids"]
|
bids = d["bids"]
|
||||||
asks = d["asks"]
|
asks = d["asks"]
|
||||||
for n, buf in enumerate(bids):
|
for n, buf in enumerate(bids):
|
||||||
price, volume, _ = buf
|
price, volume, _ = buf
|
||||||
tick.__setattr__("bid_price_%s" % (n + 1), float(price))
|
tick.__setattr__("bid_price_%s" % (n + 1), float(price))
|
||||||
tick.__setattr__("bid_volume_%s" % (n + 1), float(volume))
|
tick.__setattr__("bid_volume_%s" % (n + 1), float(volume))
|
||||||
|
|
||||||
for n, buf in enumerate(asks):
|
for n, buf in enumerate(asks):
|
||||||
price, volume, _ = buf
|
price, volume, _ = buf
|
||||||
tick.__setattr__("ask_price_%s" % (n + 1), float(price))
|
tick.__setattr__("ask_price_%s" % (n + 1), float(price))
|
||||||
tick.__setattr__("ask_volume_%s" % (n + 1), float(volume))
|
tick.__setattr__("ask_volume_%s" % (n + 1), float(volume))
|
||||||
|
|
||||||
tick.datetime = datetime.strptime(
|
tick.datetime = datetime.strptime(
|
||||||
d["timestamp"], "%Y-%m-%dT%H:%M:%S.%fZ")
|
d["timestamp"], "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||||
self.gateway.on_tick(copy(tick))
|
self.gateway.on_tick(copy(tick))
|
||||||
|
|
||||||
def on_order(self, d):
|
def on_order(self, d):
|
||||||
""""""
|
""""""
|
||||||
|
@ -709,26 +709,25 @@ class OkexfWebsocketApi(WebsocketClient):
|
|||||||
|
|
||||||
def on_depth(self, d):
|
def on_depth(self, d):
|
||||||
""""""
|
""""""
|
||||||
for tick_data in d:
|
symbol = d["instrument_id"]
|
||||||
symbol = d["instrument_id"]
|
tick = self.ticks.get(symbol, None)
|
||||||
tick = self.ticks.get(symbol, None)
|
if not tick:
|
||||||
if not tick:
|
return
|
||||||
return
|
|
||||||
|
|
||||||
bids = d["bids"]
|
bids = d["bids"]
|
||||||
asks = d["asks"]
|
asks = d["asks"]
|
||||||
for n, buf in enumerate(bids):
|
for n, buf in enumerate(bids):
|
||||||
price, volume, _, __ = buf
|
price, volume, _, __ = buf
|
||||||
tick.__setattr__("bid_price_%s" % (n + 1), price)
|
tick.__setattr__("bid_price_%s" % (n + 1), price)
|
||||||
tick.__setattr__("bid_volume_%s" % (n + 1), volume)
|
tick.__setattr__("bid_volume_%s" % (n + 1), volume)
|
||||||
|
|
||||||
for n, buf in enumerate(asks):
|
for n, buf in enumerate(asks):
|
||||||
price, volume, _, __ = buf
|
price, volume, _, __ = buf
|
||||||
tick.__setattr__("ask_price_%s" % (n + 1), price)
|
tick.__setattr__("ask_price_%s" % (n + 1), price)
|
||||||
tick.__setattr__("ask_volume_%s" % (n + 1), volume)
|
tick.__setattr__("ask_volume_%s" % (n + 1), volume)
|
||||||
|
|
||||||
tick.datetime = utc_to_local(d["timestamp"])
|
tick.datetime = utc_to_local(d["timestamp"])
|
||||||
self.gateway.on_tick(copy(tick))
|
self.gateway.on_tick(copy(tick))
|
||||||
|
|
||||||
def on_order(self, d):
|
def on_order(self, d):
|
||||||
""""""
|
""""""
|
||||||
|
Loading…
Reference in New Issue
Block a user