jonathanelscpt / valr-python

Python SDK for VALR exchange APIs
MIT License
15 stars 17 forks source link

BNB Support #17

Open erasmush opened 2 years ago

erasmush commented 2 years ago

Hi Jonathan,

I see we have BNBZAR on VALR now.

Could you please add it to the websocket?

Kind regards Hannes

jonathanelscpt commented 2 years ago

Hey Hannes,

You're faster than me! :D Sure, I'll add support this week.

Regards Jonathan Els

On Tue, 8 Mar 2022 at 12:00, erasmush @.***> wrote:

Hi Jonathan,

I see we have BNBZAR on VALR now.

Could you please add it to the websocket?

Kind regards Hannes

— Reply to this email directly, view it on GitHub https://github.com/jonathanelscpt/valr-python/issues/17, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFA3DIB3ZHCKBFD4HUI2NGDU64XMNANCNFSM5QGACDAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

erasmush commented 2 years ago

Ah, you are the best!

Thanks Jonathan

jonathanelscpt commented 2 years ago

I had a look, its a trivial change. As per their changelog, is no API-level changes to support this (as expected).

If you're not using the helper enums, you can simply input "BNBZAR" or "BNB" strings where applicable, and the current version will work fine.

Aside - I will also roll in the 8 February 2022 changelog emum support for FULL_ORDERBOOK_UPDATE. I asked the VALR team for this a while ago, so what glad to see that they delivered a much-needed new feature (still alpha though). I'm not committing to any support for WebSocket processing to support this new stream, it's out of the scope of this library. If you want to see something similar, have a look at https://github.com/jacoduplessis/luno_streams. Jaco did some great work there.

Regards Jonathan Els

On Tue, 8 Mar 2022 at 14:37, erasmush @.***> wrote:

Ah, you are the best!

Thanks Jonathan

— Reply to this email directly, view it on GitHub https://github.com/jonathanelscpt/valr-python/issues/17#issuecomment-1061785699, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFA3DIGNAGQLTJL7KVMCSNTU65JZ7ANCNFSM5QGACDAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

erasmush commented 2 years ago

Thanks Jonathan!

erasmush commented 2 years ago

Hi Jonathan,

I am unable to see any updates for BNBZAR when following the AGGREGATED_ORDERBOOK_UPDATE stream. Please could you give my code a quick look to see if I am missing something blatantly obvious. It would be much appreciated.

"""

loop = asyncio.new_event_loop()

def VALR_Orderbook(loop):

while True:
try: def pretty_hook(data: Dict):

        if data['currencyPairSymbol'] != 'BTCZAR' and data['currencyPairSymbol'] != 'ETHZAR' and data['currencyPairSymbol'] != 'XRPZAR' and data['currencyPairSymbol'] != 'SOLZAR':
           print(data['currencyPairSymbol'])

        if data['currencyPairSymbol'] == 'BNBZAR':
           Valr_BNB_bid = float(data['data']['Bids'][0]['price'])            
           Valr_BNB_ask = float(data['data']['Asks'][0]['price'])
           print('Valr_BNB_bid: ',Valr_BNB_bid)

     c = WebSocketClient(api_key=VALR_api_key_code, api_secret=VALR_api_key_secret,
                    ws_type=WebSocketType.TRADE.name,
                    trade_subscriptions=[TradeEvent.AGGREGATED_ORDERBOOK_UPDATE.name],
                    hooks={TradeEvent.AGGREGATED_ORDERBOOK_UPDATE.name : pretty_hook})
     asyncio.set_event_loop(loop)
     loop.run_until_complete(c.run())

  except:
      print(traceback.format_exc())
      time.sleep(5)

VALR_Orderbook(loop) """