Skip to content

Rinjani Bitcoin Arbitrager is a Proof-Of-Concept prototype of an automatic arbitrage trading system.

License

Notifications You must be signed in to change notification settings

bitrinjani/rinjani

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️This version is no longer maintained. A newer version is available.

Rinjani Bitcoin Arbitrager

Rinjani Bitcoin Arbitrager is a Proof-Of-Concept prototype of an automatic arbitrage trading system targeting Bitcoin exchanges operated in Japan.

Screenshot

Getting Started

To run the Arbitrager, clone this repository and build it in Visual Studio 2017. Open config.json and replace Key and Secret fields with your API keys (tokens) and secrets.

Prerequisites

Software

  • Windows OS (Tested on Windows 10)
  • Visual Studio 2017

Supported Brokers (Exchanges)

Currently, the Arbitrager supports three brokers (exchanges) operated in Japan.

  • Bitflyer
  • Quoine
  • Coincheck

How it works

  1. Every 3 seconds, the Arbitrager fetches quotes from all configured brokers.
  2. Verifies if the max net exposure (MaxNetExposure config) is not breached.
  3. Filters out quotes that are not usable for arbitrage. For example, if MaxShortPosition config is 0 and the current position is 0 for a broker, ask quotes for the broker are filtered out.
  4. Calculates best ask and best bid. If the spread is not inverted, there is no arbitrage opportunity, so the arbitrager waits for the next iteration.
  5. Verifies if there is enough expected profit. If the expected profit is smaller than MinTargetProfit config, the Arbitrager waits for the next iteration.
  6. Arbitrage the spread by sending a buy leg and a sell leg to each broker.
  7. With 3 seconds interval, the Arbitrager checks if the legs are filled or not.
  8. If the both legs are filled, shows the profit.

Configuration

All configurations are stored in config.json.

Global Config

Name Values Description
DemoMode true or false If it's True, the arbitrager analyzes spreads but doesn't send any trade.
PriceMergeSize integer Merges small quotes into the specified price ladder before analyzing arbitrage opportunity.
MaxSize decimal Maximum BTC size to be sent to a broker.
MinSize decimal Minimum BTC size to be sent to a broker.
MinTargetProfit Integer Minimum JPY size to try to arbitrage.
IterationInterval Millisecond Time lapse in milliseconds of an iteration. When it's set to 3000, the quotes fetch and the spreads analysis for all the brokers are done every 3 seconds
PositionRefreshInterval Millisecond Time lapse in milliseconds of position data refresh. Position data is used to check max exposure and long/short availability for each broker.
SleepAfterSend Millisecond Time lapse in milliseconds after one arbitrage is done.
MaxNetExposure decimal Maximum total net exposure. If net exposure qty is larger than this value, Arbitrager stops.
MaxRetryCount integer Maximum retry count to check if arbitrage orders are filled or not. If the orders are not filled after the retries, Arbitrager tries to cancel the orders and continues.
OrderStatusCheckInterval Millisecond Time lapse in milliseconds to check if arbitrage orders are filled or not.

Broker config

Name Values Description
Broker Bitflyer, Quoine or Coincheck Broker enum
Enabled true or false Enable the broker for arbitrage
Key string Broker API Key or Token
Secret string BrokerAPI Secret
MaxLongPosition decimal Maximum long position allowed for the broker.
MaxShortPosition decimal Maximum short position allowed for the broker
CashMarginType Cash, MarginOpen, MarginClose, NetOut Arbitrage order type. Currently, this option is not fully supported. Please do not change from the default values.

Limitations

For Bitflyer, CashMarginType must be Cash. Although the broker provides leverage trading as BTC-FX, the price range is totally different from BTCJPY. BTC-FX is not applicable to arbitrage.

Log files

All log files are saved under logs directory. To configure logging, edit nlog.conf.

File name Description
Rinjani.log Standard log file
Rinjani_debug.log Verbose logging, including all REST HTTP requests and responses in JSON format
Rinjani_arbitrager.log Arbitrage activity log
Rinjani_position.log BTC position log

Running the tests

Run unit tests under Rinjani.Tests project. The unit tests are safely executed with mocks, not against real exchange API.

To run unsafe tests against real exchange API, comment out Ignore attributes in BrokerApiTest.cs file.

License

This project is licensed under the MIT License - see the LICENSE file for details

Inspirations

Blackbird, which targets US exchanges.

About

Rinjani Bitcoin Arbitrager is a Proof-Of-Concept prototype of an automatic arbitrage trading system.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages