Skip to content

Commit

Permalink
feat: fix price_feed
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel1302 committed Oct 26, 2023
1 parent 32b27c7 commit 6c3e98f
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions vega_sim/scenario/common/utils/price_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,11 @@ def get_historic_price_series(
def _binance_price_listener(iter_obj, symbol):
ws = websocket.WebSocketApp(
f"wss://stream.binance.com:9443/ws/{symbol}@kline_1s",
on_message=lambda _, msg: _on_message(iter_obj, msg, symbol),
on_message=lambda _, msg: _on_message(iter_obj, msg),
)
ws.run_forever(reconnect=5)


def _on_message(iter_obj, message, symbol):
iter_obj.latest_price = float(json.loads(message)["k"]["c"])

def _xauusd_price_listener(iter_obj):
url = "https://forex-data-feed.swissquote.com/public-quotes/bboquotes/instrument/XAU/USD"
while True:
Expand Down Expand Up @@ -221,14 +218,6 @@ def _xauusd_price_listener(iter_obj):
time.sleep(30)


def _price_listener(iter_obj, symbol):
ws = websocket.WebSocketApp(
f"wss://stream.binance.com:9443/ws/{symbol}@kline_1s",
# on_open=lambda ws: print("ok"),
on_message=lambda _, msg: _on_message(iter_obj, msg),
)
ws.run_forever(reconnect=5)


def _on_message(iter_obj, message):
iter_obj.latest_price = float(json.loads(message)["k"]["c"])
Expand All @@ -250,7 +239,7 @@ def __init__(self, product: str = "BTCBUSD"):
if product == "XAUUSD":
self._forwarding_thread = threading.Thread(
target=_xauusd_price_listener,
args=(self,),
args=(self, self.product.lower()),
daemon=True,
)
else:
Expand Down

0 comments on commit 6c3e98f

Please sign in to comment.