Skip to content

This is a python wrapper written to make it simple to connect to Deribit's JSON-RPC api v2 using websockets.

License

Notifications You must be signed in to change notification settings

pte1601/deribit_websocket_v2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deribit Websocket API v2

This is a python wrapper written to make it simple to connect to Deribit's JSON-RPC api v2 using websockets.

Table of Contents

  1. Installation
  2. Credentials
  3. Index Price
  4. Ticker Data
  5. Buy
  6. Sell
  7. Stop Buy
  8. Stop Sell
  9. Edit
  10. Cancel
  11. Cancel All
  12. Account Summary
  13. 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'

https://docs.deribit.com/v2/#private-get_position

About

This is a python wrapper written to make it simple to connect to Deribit's JSON-RPC api v2 using websockets.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%