This is a python wrapper written to make it simple to connect to Deribit's JSON-RPC api v2 using websockets.
- Installation
- Credentials
- Index Price
- Ticker Data
- Buy
- Sell
- Stop Buy
- Stop Sell
- Edit
- Cancel
- Cancel All
- Account Summary
- Get Position
mkdir deribit_ws && cd deribit_ws
git clone https://github.com/Jimmy-sha256/deribit_ws.git
virtualenv --python=/usr/bin/python3.10 venv
source /venv/bin/activate
pip install -r requirements.txt
Add your deribit api access key and access secret to the credentials.py file:
Add either main-net or test-net websocket url to credentials.py file:
- wss://testapp.deribit.com/ws/api/v2
- wss://deribit.com/ws/api/v2
index(currency)
Paramaters | Type | Description |
---|---|---|
currency |
string |
'BTC', 'ETH' |
https://docs.deribit.com/v2/#public-get_index
ticker(instrument_name)
Paramaters | Type | Description |
---|---|---|
instrument_name |
string |
'BTC-PERPETUAL', 'ETH-PERPETUAL' |
https://docs.deribit.com/v2/#public-ticker
buy(instrument_name, amont, order_type, price, post_only)
Paramaters | Type | Description |
---|---|---|
instrument_name |
string |
'BTC-PERPETUAL', 'ETH-PERPETUAL' |
amount |
int |
number of contracts to purchase |
order_type |
string |
'market', 'limit' |
price |
int |
price to purchase contracts at |
post_only |
boolean | True / False |
https://docs.deribit.com/v2/#private-buy
sell(instrument_name, amont, order_type, price, post_only)
Paramaters | Type | Description |
---|---|---|
instrument_name |
string |
'BTC-PERPETUAL', 'ETH-PERPETUAL' |
amount |
int |
number of contracts to purchase |
order_type |
string |
'market', 'limit' |
price |
int |
price to purchase contracts at |
post_only |
boolean | True / False |
https://docs.deribit.com/v2/#private-sell
stop_buy(instrument_name, trigger, amont, order_type, stop_price, price)
Paramaters | Type | Description |
---|---|---|
instrument_name |
string |
'BTC-PERPETUAL', 'ETH-PERPETUAL' |
trigger |
string |
'index_price', 'mark_price', 'last_price' |
amount |
int |
number of contracts to purchase |
order_type |
string |
'stop_market', 'stop_limit' |
stop_price |
int |
price at which order is triggered |
price |
int |
price to purchase contracts at |
https://docs.deribit.com/v2/#private-buy
stop_sell(instrument_name, trigger, amont, order_type, stop_price, price)
Paramaters | Type | Description |
---|---|---|
instrument_name |
string |
'BTC-PERPETUAL', 'ETH-PERPETUAL' |
trigger |
string |
'index_price', 'mark_price', 'last_price' |
amount |
int |
number of contracts to purchase |
order_type |
string |
'stop_market', 'stop_limit' |
stop_price |
int |
price at which order is triggered |
price |
int |
price to purchase contracts at |
https://docs.deribit.com/v2/#private-sell
edit(order_id, amount, price)
Paramaters | Type | Description |
---|---|---|
order_id |
string |
id of order '3032588463' |
amount |
int |
edit number of contracts |
price |
int |
edit price of contracts |
https://docs.deribit.com/v2/#private-edit
cancel(order_id)
Paramaters | Type | Description |
---|---|---|
order_id |
string |
id of order to be canceled '3032588463' |
https://docs.deribit.com/v2/#private-cancel
cancel_all()
This method takes no parameters
https://docs.deribit.com/v2/#private-cancel_all
account_summary(currency)
Paramaters | Type | Description |
---|---|---|
currency |
string |
'BTC', 'ETH' |
https://docs.deribit.com/v2/#private-get_account_summary
get_position(currency)
Paramaters | Type | Description |
---|---|---|
instrument_name |
string |
'BTC-PERPETUAL', 'ETH-PERPETUAL' |