I’m currently teaching myself some Python, which includes making some programs that interact with the Deribit API.

I have created a GitHub account where I will be sharing anything that may be useful to others. You can find that GitHub account here.

Much of the code I publish will serve as some useful functioning examples of how anyone can connect to their Deribit account using Python code.

All of this code is free to use for all, however do bear in mind I’m not a professional programmer, so before you let anything loose on the production version of the platform, you would be best advised to have a read of the code yourself. You should check that things behave how you expect them to in every scenario. This is particularly true for anything that has trading functionality. Use the test-net, that’s what it’s there for! The test site can be found at test.deribit.com.

The first code I’m releasing has no trading functionality though. This little program allows the user to pull in all their open positions (shown in the table at the bottom). The user can then select a currency to analyse and select a minimum and maximum value for the x axis (underlying price). The program will then pull in all the required data and display information about the Greeks of the positions for the selected currency.

The repository can be found here.

The Greeks are shown for today, and then as time passes with additional plots. The other times shown are currently hard coded to today plus 30%, 60%, and 90% of the time remaining until the nearest expiration date of the currently open positions. The implied volatility used in these calculations is the current mark price of each option.

This program uses the following api endpoints:

-get_positions
-get_order_book
-get_instruments
-get_instrument (not used but included in api_functions.py)
-get_book_summary_by_instrument (not used but included in api_functions.py)

This first program only uses JSON-RPC over HTTP, as I have not implemented websockets yet. While it only shows implementations for a small number of endpoints, I will be adding examples of more in the future. In the meantime though you can find details on all the available api endpoints at docs.deribit.com. With just a couple of examples and only a small amount of programming ability, it’s relatively simple to construct the functions for any other endpoints you may want to use in your own programs.

Tkinter is used for the GUI, and Matplotlib is used to plot the charts. Both are very commonly used libraries in Python, so there is plenty of information available online if you want to edit things and aren’t sure how.

To use the program in your own Deribit account you will need to change the api_client_id and api_client_secret in settings.py. Both of these are available on the api page in your Deribit account.

The testnet and the production site are completely separate systems, so be sure you are using details from the correct website/account. If you wish to use this on the production website, you will also need to change the api_exchange_address in settings.py.

Shout out to Elliot Parker (who used to work for Deribit and now works for Paradigm) as I used one of his github repositories as my first way of getting something working with the Deribit API.

AUTHOR(S)

Cryptarbitrage

Deribit Content - Spreadsheets, Options, Futures Premiums..

RECENT ARTICLES