• Stars
    star
    819
  • Rank 55,659 (Top 2 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 10 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automated Trading program that detects pairwise and triangular arbitrage opportunities on altcoin/bitcoin exchanges

cryptocurrency_arbitrage

A million dollars isn't cool. You know what's cool?

A BILLION DOLLARS

This is an automated trading program that detects pairwise and triangular arbitrage opportunities on altcoin/bitcoin exchanges. Compared to other bots out there, this one is fairly high-frequency (can trade up to once every 30 seconds or so).

This one handles a lot of the nasty market microstructure calculations like order volume sizing in illiquid orderbooks, transaction fees, situations where an orderbook is reversed, etc. It is easily extendible to support more exchanges and strategies.

Is it profitable?

I have made some money off of it, so yes. But automated order submission and confirmation have not been implemented.

Why are you giving it away for free?

  • With HFT bots, one has to be really careful with order confirmation - otherwise you could lose all your money in a matter of minutes if an exchange goes invsolvent or something. I wouldn't sleep well at night if I were running a scalping operation on my own.

  • I am of the opinion that the success of Bitcoin and altcoins are mutually exclusive and it is unwise to maintain sizeable positions in currencies that could become illiquid/unwanted very soon. I'd much rather put my money into passive investing, which takes considerably less work than trading.

  • That said, it's a grand shame to leave this code unused on my computer so I've put it up online for educational purposes. Designing and implementing this has taught me so much about financial markets and Bitcoin and that is a reward in its own right.

How do I use it?

Warning: I am not responsible for any losses you incur using this program. You should not run this without looking at the source code for the entire program and running the paper trading/backtesting framework first.

This program comes with two strategies. The first one is pairwise arbitrage, in which the price difference between a currency pair A_B between two different exchanges is exploited via instantaneous arbitrage (to circumvent 2 hour delay in blockchain confirmation). The nice thing about trading altcoins with altcoins is that you don't have to muck around (yet) with financial regulation or set up brokerage accounts or deal with exorbitant fiat withdrawal fees from the small number of exchanges who support it (of which the bid-ask spread is low anyway).

Run one of the following scripts:

main_pair.py - runs real-time paper or live trading.

main_pair_data.py - gathers and caches live market depths to be played back for backtesting

main_pair_backtest.py - runs backtest of trading strategies on gathered data

The second strategy is triangular arbitrage. It is nice because it can often be carried out on one exchange (i.e. such as CoinEx) and thus circumvents the time taken for blockchain confirmation (i.e. you can use new securities immediately).

The equivalent scripts are main_tri.py, main_tri_data.py, and main_tri_backtest.py, respectively.

Put your secret keys in config.py. Keep those safe.

Is there any documentation?

My code is sprinkled with liberal amounts of comments, for better or worse.

Credits

Some exchange access APIs included in this source code were not implemented by me.

If you find this program useful and would like to donate, I accept Bitcoin and Dogecoin!

BTC: 1MLX2kMhTSRiq3Uz7R2JsECreuQEmofQy6

DOGE: DE57RJrW9Qmq6pKXSTViP8QVmu63FxfHbM

More Repositories

1

tdb

Interactive, node-by-node debugging and visualization for TensorFlow
JavaScript
1,357
star
2

awesome-graphics

Curated list of computer graphics tutorials and resources
1,048
star
3

draw

TensorFlow Implementation of "DRAW: A Recurrent Neural Network For Image Generation"
Python
525
star
4

gumbel-softmax

categorical variational autoencoder using the Gumbel-Softmax estimator
Jupyter Notebook
425
star
5

normalizing-flows-tutorial

Tutorial on normalizing flows.
Jupyter Notebook
293
star
6

genadv_tutorial

TensorFlow tutorial on Generative Adversarial Models
Jupyter Notebook
255
star
7

maml-jax

Implementation of Model-Agnostic Meta-Learning (MAML) in Jax
Jupyter Notebook
188
star
8

svd3

Fast singular value decomposition, diagonalization, QR decomposition of 3x3 matrices.
Mathematica
148
star
9

nf-jax

Normalizing Flows in Jax
Jupyter Notebook
105
star
10

pt-jax

Path Tracing in JAX
Jupyter Notebook
69
star
11

e2c

TensorFlow impementation of: Embed to Control: A Locally Linear Latent Dynamics Model for Control from Raw Images
Python
65
star
12

RNN-dynamics

Code and report for APMA136 Final Project
MATLAB
19
star
13

pptx-export-notes

Exports plaintext speaker notes from Microsoft Powerpoint .pptx files
Python
19
star
14

variance_reduction

Implementation of Variance Reduction Techniques in Julia
Jupyter Notebook
11
star
15

graphjs

Mathematical Graph representation in JavaScript
CoffeeScript
6
star
16

pyN

Neuron(s)-based library in Python using numpy and Blender Game Engine.
Python
6
star
17

glsl-playground

Shadertoy-compatible fragment shader viewer.
C++
5
star
18

julia-NeuralNets

Spiking neural network simulator written in Julia.
Julia
5
star
19

NeuralNets

(Yet another) C++ Simulator for Neural Networks
C++
4
star
20

geneva

activation function inspired by the Geneva drive
Jupyter Notebook
4
star
21

Social-Docking

Metropolis Monte Carlo + General AMBER Force Field implemented in JavaScript
JavaScript
3
star
22

boxbot

C++ Framework for embodied cognition / robot simulation / reinforcement learning
C++
3
star
23

node-user-agents

Quick HTTP user agent headers for slightly-immoral-and-very-improper web scraping
JavaScript
3
star
24

chaos

Jupyter Notebook
3
star
25

Hanabi.jl

customizable game engine for Hanabi, written in Julia
Julia
3
star
26

adaptive-e2c

Capstone project (Brown University)
Python
2
star
27

discord_chatbot

text-based multiplayer discord game
Python
1
star
28

cpu-render

Dumb CPU renderer for debugging shadertoy shaders
C++
1
star
29

aibook

ALife book.
HTML
1
star
30

java-graph

A simple graph class + dijkstra's
Java
1
star
31

graphjs_viz

Adds support for drawing in the graphjs library
1
star
32

ericjang.github.io

HTML
1
star
33

google-scrubber

Command-Line Utility for Scraping Google Data
1
star
34

DockJS

Molecular Docking framework built on top of ChemJS
JavaScript
1
star