Package: valr-py
A Python SDK for VALR cryptocurrency exchange APIs.Installationpip install valr-pyYou can also install the in-development version with:pip install https://github.com/Quirky-Fox/valr-py/archive/master.zipAuthenticationAuthenticating to VALR API private resources requires a valid API Key from theVALR exchange.Synchronous REST API ClientTo use thesynchronousREST API client:>>>fromvalr_pyimportClient>>>fromvalr_py.exceptionsimportIncompleteOrderWarning>>>fromdecimalimportDecimal>>>>>>c=Client(api_key='api_key',api_secret='api_secret')>>>c.rate_limiting_support=True# honour HTTP 429 "Retry-After" header values>>>limit_order={..."side":"SELL",..."quantity":Decimal('0.1'),..."price":Decimal('10000'),..."pair":"BTCZAR",..."post_only":True,...}>>>try:...res=c.post_limit_order(**limit_order)...order_id=res['id']...print(order_id)...exceptIncompleteOrderWarningasw:# HTTP 202 Accepted handling for incomplete orders...order_id=w.data['id']...print(order_id)...exceptExceptionase:...print(e)"558f5e0a-ffd1-46dd-8fae-763d93fa2f25"Asynchronous REST API ClientTheasynchronousREST API client is still in development.Coming soon!WebSocket API ClientTo use the WebSocket API client:>>>importasyncio>>>fromtypingimportDict>>>frompprintimportpprint>>>fromvalr_pyimportWebSocketClient>>>fromvalr_py.enumimportTradeEvent>>>fromvalr_py.enumimportWebSocketType>>>>>>defpretty_hook(data:Dict):...pprint(data)>>>>>>c=WebSocketClient(api_key='api_key',api_secret='api_secret',currency_pairs=['BTCZAR'],...ws_type=WebSocketType.TRADE.name,...trade_subscriptions=[TradeEvent.MARKET_SUMMARY_UPDATE.name],...hooks={TradeEvent.MARKET_SUMMARY_UPDATE.name:pretty_hook})>>>loop=asyncio.get_event_loop()>>>loop.run_until_complete(c.run()){'currencyPairSymbol':'BTCZAR','data':{'askPrice':'151601','baseVolume':'314.7631144','bidPrice':'151600','changeFromPrevious':'2.14','created':'2020-02-06T22:47:03.129Z','currencyPairSymbol':'BTCZAR','highPrice':'152440','lastTradedPrice':'151600','lowPrice':'146765','previousClosePrice':'148410','quoteVolume':'47167382.04552981'},'type':'MARKET_SUMMARY_UPDATE'}This library leverageswebsocketsandasyncioand is thus a coroutine-based API client.  Both of
VALR’sAccount WebSocket connectionandTrade WebSocket connectionAPI endpoints are included.  Furthermore,
the SDK fully supports VALR’s subscription methods for bothAccountandTradeendpoints.
Please see theVALR API documentationfor further information.For each subscription, a hook must be provided to process the WS responses.  Failing to do so raises
aHookNotFoundErrorexception.  For ease of use, severalEnumclasses have been implemented
(as showcased above) for client instantiation and hook consumption of API responses. However, client input is
accepted instrformat.Although not completely minimalistic, please note that the SDK is implemented as a thin client and parsing of API
streams response is left up to the application user.DevelopmentTo execute all tests run:toxNote, to combine the coverage data from all the tox environments run:Windowsset PYTEST_ADDOPTS=--cov-append
toxOtherPYTEST_ADDOPTS=--cov-append toxDonateIf this library has helped you or if you would like to support future development, donations are most welcome:CryptocurrencyAddressBTC38c7QWggrB2HLUJZFmhAC2zh4t8C57c1ecETH0x01eD3b58a07c6d005281Db76e6c1AE2bfF2226ADChangelog0.3.0 (2023-04-20)Added new API features:Add fiat bank accounts APIsAdd VALR Pay APIsAdded formatting of balances as a convenience function0.2.7 (2021-12-06)Enum support for SOLZAR0.2.6 (2021-11-15)added subaccount supportadded all rest api endpoint changes for 2021api renaming to align with VALR api docsunit tests extended to support endpoint changes and subaccount feature0.2.5 (2021-11-02)bank fast withdrawal support0.2.4 (2020-09-27)build stability bugfixes0.2.3 (2020-09-27)replacedjsonwithsimplejsonfor speed improvements0.2.2 (2020-05-25)renamed several sdk methods for API standardizationadded enums for REST APIadded support for simple enum str printingadded type support for enumsadded XRPZAR support in currency enum0.2.1 (2020-05-25)Decimalsupport and JSON serialization handlingaddedtypingsupport for all API callsasync support for VALR’s beta websocket APIadditional api documentationbuild automation extensions0.1.7 (2020-01-11)Standardised api attribute naming in ClientUpdated doctest and readme for more detailed SDK description0.1.6 (2020-01-11)Added custom warningIncompleteOrderWarningon receiving202 Acceptedresponse to support
custom handling of incomplete ordersAdded custom warningTooManyRequestsWarningduring 429 handlingAdded class flag for enabling or disabling 429 handler0.1.5 (2020-01-11)Expanded test suites to unit, functional and live integration testingInternal class refactoringAdded optional HTTP 429 handling by honouring the “Retry-After” header value sent in VALR responses0.1.4 (2020-01-04)Streamlined ordering api calls with decoratorsAdded typing supportRe-worked class design internals to support later async expansionFixed bugs with str ‘None’ insertion with f-stringsExpanded unit tests to cover all api endpoints for synchronous client0.1.3 (2020-01-02)Fixed defect with empty body signed signaturesUpdated class importingAdded additional docstrings and unit tests0.1.2 (2019-12-31)Updated readme and documentation0.1.1 (2019-12-31)corrected build error issue in setup.py0.1.0 (2019-12-29)Initial PyPi release0.0.0 (2019-12-27)Alpha-only. Not released on PyPI.