Deribit Trading System is a high-performance order execution and management system that operates through a command-line interface.
Deribit Trading System
Overview
Deribit Trading System is a high-performance order execution and management system that operates through a command-line interface. It uses a WebSocket client to connect to the Deribit TESTNET and manage trading portfolios with advanced functionality.
Features
- WebSocket-based trading interface
- Command-line trading operations
- Support for various order types
- API authentication
- Open orders management
- Order modification and cancellation
Tech Stack
Prerequisites
System Requirements
- C++ Compiler (g++)
- CMake
- Boost Libraries
- OpenSSL
- Git
Fast setup
To quickly configure your system and set up the project, please go ahead and execute the appropriate setup script for your operating system as detailed below.- NOTE: Please make sure you are in the repository's root directory before running the script.
macOS:
Run the following commands to execute the setup script:chmod +x ./scripts/setup_mac.sh
./scripts/setup_mac.sh
Linux:
Run the following commands to execute the setup script:chmod +x ./scripts/setup_linux.sh
./scripts/setup_linux.sh
Windows
For Windows, use the PowerShell script as follows:Set-ExecutionPolicy Bypass -Scope Process -Force
.\scripts\setup_windows.ps1
This will install the necessary dependencies, build the project, and prepare it for use.
Installation Guide
Mac OS
- Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install dependencies:
brew install cmake gcc boost openssl git readline
Linux (Ubuntu/Debian)
- Update package list:
sudo apt update
- Install dependencies:
sudo apt install cmake gcc libboost-all-dev libssl-dev git libreadline-dev
Windows
- Download and Install:
Project Setup
- Clone the Repository:
git clone https://github.com/Venkatesan-M/deribit-trading-system.git
cd deribit-trading-system
- Create Build Directory:
mkdir build
cd build
- Build the Project:
cmake .. -Wno-dev
cmake --build .
- Run the Application:
./deribit_trader
Disclaimer
This is a trading system for educational and testing purposes. Always use caution and understand the risks involved in cryptocurrency trading.
Getting Started with Deribit
Account Setup
- Create an account on Deribit Testnet
- Generate API Keys:
Application Usage
Basic Commands
help / man: Show all supported commandsquit / exit: Close WebSocket connections and exitclose <id> [code] [reason]: Closes the connection with the given id; optional: specify exit code and/or reasonconnect <URI>: Creates a connection with the given URIshow <id>: Get connection metadatasend <id> msg: Send message to specific connectionshow_messages <id>: View message exchangessend <id> <message>: Sends the message to the specified connectionview_subscriptions: Displays the list of subscribed symbols to stream continuous orderbook updatesview_stream: Displays the stream continuous orderbook updates subscribed symbolslatency_report: Generates a latency report of the current sessionreset_report: Delete's the data of the latency report of the current session
Deribit API Commands
Connection and Authentication
- Connect to Testnet:
Deribit connect
connect wss://test.deribit.com/ws/api/v2
- Authenticate:
Deribit <id> authorize <connectionid> <clientid> <client_secret> [-s]
Order Management
- Buy Order:
Deribit <id> buy <instrument> <transaction_name>
- Sell Order:
Deribit <id> sell <instrument> <transaction_name>
- Modify Order:
Deribit <id> modify <order_id>
- Cancel Order:
Deribit <id> cancel <order_id>
Cancell all orders
Deribit <id> cancel_all
Information Retrieval
- Get Open Orders:
Deribit <id> getopenorders [<currency>] [<instrument>] [<label>]
- View Positions:
Deribit <id> positions [currency] [kind]
- Get OrderBook:
Deribit <id> orderbook <instrument> [<depth>]
Symbol Subscription
- Subscribe to a symbol:
Deribit <id> subscribe [symbol]
- Unsubscribe to a symbol:
Deribit <id> unsubscribe [symbol]
- Unsubscribe to all symbol:
Deribit <id> unsubscribe_all
Supported Order Types
| Order Type | Flag | |---------------------|-----------------| | Limit | limit | | Stop Limit | stop_limit | | Take Limit | take_limit | | Market | market | | Stop Market | stop_market | | Take Market | take_market | | Market Limit | market_limit | | Trailing Stop | trailing_stop |
Time in Force Options
| Option | Flag | |---------------------------|-------------------------| | Good Till Cancelled | goodtilcancelled | | Good Till Day | goodtilday | | Fill or Kill | fillorkill | | Immediate or Cancel | immediateorcancel |
Project Structure
โโโ include # Header files
โ โโโ api
โ โ โโโ api.h
โ โโโ authentication
โ โ โโโ password.h
โ โโโ json
โ โ โโโ json.hpp
โ โโโ utils
โ โ โโโ utils.h
โ โโโ latency
โ โโโ tracker.h
โ โโโ websocket
โ โโโ websocket_client.h
โโโ README.md
โโโ setup.sh
โโโ src
โโโ main.cpp # main function (deribit trader)
โโโ api
โ โโโ api.cpp # Implementation Deribit API's Functionality
โโโ authentication
โ โโโ password.cpp # Authentication and Session Management Functionality
โโโ latency
โ โโโ tracker.cpp # Latenct tracking logic
โโโ utils
โ โโโ utils.cpp # Helper functions and utils
โโโ websocket
โโโ websocket_client.cpp # websocketpp and WebSocket endpoint implementation
Development
- you are free to develop more feature on this, just refer the new DERIBIT API DOCS
- Test the API Call on Deribit API Console
Contribution
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch
- Make your changes
- Submit a pull request
License
MIT License
Copyright (c) 2025 Venkatesan M