A model trading bot for the ZUBR cryptocurrency derivative trading platform. Includes connector classes that provide an abstracted interface to APIs for receiving market data and for placing trade orders, as well as a working bot that uses them to execute a basic trading strategy.
The bot is a non-user-interactive command line application. It requires a json configuration file to specify its numerous connection and strategy parameters, illustrated here.
To connect the bot to a live testing server to place trades requires an account with ZUBR and obtaining an IP-specific login ID. This repository includes a simple dummy server creatively named DummyBYSONServer which can accept a connection and acknowledge basic trading messages, sufficient for the bot to run, but does not test message validity or simulate the complexities of the active trading environment.
The robot attempts to maintain two limit orders:
- a buy order at
(current best purchase price + current best sale price)/2 - interest - shift * position
- a sell order at
(current best purchase price + current best sale price)/2 + interest - shift * position
Both orders are placed with volume equal to the "quoteSize" parameter, or the largest volume that will keep the bot within the bounds of maxposition >= position >= -maxposition
if that is less. Orders are updated if either order is entirely filled, or when the best current prices change. The bot additionally has mechanisms to avoid violating message flooding limits.
BYSONChannel
and MarketObserver
respectively implement connections to the trading gate and the order book subscription and each can make calls to an associated interface when messages arrive. BYSONChannel
additionally provides support for outgoing trading messages.
SLF4J is used for logging throughout. Initial development and testing was done with the SimpleLogger binding an a classpath properties file such as this, you can use whichever binding you please.
In addition to SLF4J 1.7.30, the ExampleZUBRRobot and MarketObserver classes depend on minimal-json 0.9.5 and Java-WebSocket 1.5.1. Java 8 is required.
The code is provided under the terms of the MIT License.