jimmy-sha256 / deribit_websocket_v2 Goto Github PK
View Code? Open in Web Editor NEWThis is a python wrapper written to make it simple to connect to Deribit's JSON-RPC api v2 using websockets.
License: MIT License
This is a python wrapper written to make it simple to connect to Deribit's JSON-RPC api v2 using websockets.
License: MIT License
Deribit API provides public/unsubscribe_all
method to unsubscribe all channels. I am running a script that is subscribing to multiple channels. I am using asyncio.get_event_loop()
to run in coroutines. My issue is that after a certain time period I have to disconnect from existing channels and subscribe to newer ones. I ran another script to call unsubscribe_all but in other window it does not un-subscribe at all and it keeps pulling data.
Can you tell me some way to do it?
Thanks for the code. I am new to python and api but I managed to authenticate to the test version of deribit and to fill market orders. However, limit orders that are not filled immediately always get cancelled, so I am unable to use stop limit orders or buy orders that are too low or well orders that are too high. I use the default option good_til_cancelled for time in force. Thanks for your help.
I wonder how it is possible to subscribe to a few private channels, and just keep an active loop and print any changes that come during the subscription.
also heartbeat seems not inserted yet, are you making this later on?
answer = client.buy('BTC-PERPETUAL', 10, 'limit', False, price = 64460)
would be
{'jsonrpc': '2.0', 'id': 1, 'result': {'trades': [], 'order': {'is_liquidation': False, 'risk_reducing': False, 'order_type': 'limit', 'creation_timestamp': 1709663161987, 'order_state': 'open', 'contracts': 1.0, 'average_price': 0.0, 'reduce_only': False, 'post_only': False, 'last_update_timestamp': 1709663161987, 'filled_amount': 0.0, 'replaced': False, 'web': False, 'api': True, 'mmp': False, 'instrument_name': 'BTC-PERPETUAL', 'order_id': '66581975120', 'max_show': 10.0, 'time_in_force': 'good_til_cancelled', 'amount': 10.0, 'direction': 'buy', 'price': 64460.0, 'label': ''}}, 'usIn': 1709663161985366, 'usOut': 1709663161988051, 'usDiff': 2685, 'testnet': False}
trying to cancel this order_id
d = client.cancel(order_id)
returns
{'jsonrpc': '2.0', 'id': 1, 'error': {'message': 'not_open_order', 'code': 11044}, 'usIn': 1709663172181556, 'usOut': 1709663172183829, 'usDiff': 2273, 'testnet': False}
Any help greatly appreciated : very nice code otherwise; good start to build more
Hi, I wonder how to keep websocket connecting , and use it every time ?
Hello,
I want to contribute and am just working on an enhanced version, capable of more account sessions (in order to be possibly able to work with more accounts with different API keys at the same time), correctly and immediately parsed response to work with and more endpoints. Could you or would you be willing to merge it later or put a link to it in the description?
Thanks.
I am trying to subscribe to basically all options i can via deribit to stream their order book data. Can this be done in this wrappers current state? If not I would be willing to help to try to bring it to an ability to do this
Hi. Do you plan to add a possibility to work with the subscription outputs? It would be very effective to just "ping" once, let the WS open forever and fetch only one variable in some other Python class to get the updates.
Hello James
I am trying to use your deribit ws api to retrieve market data. I am struggling what is the value of the api variable in the loop function? Maybe you have also a quick example to retrieve market data?
Thanks for your assistance. Greetings, Peter
Great simple code. I am not so familar with websocket, threading, etc , but strongly need actual order list for fantastic HTF scalping and have similar bot on bitmex.
This code is very simple and beautiful, but without actual order list feature useless for me (
If I right understand , i need this functional:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.