GithubHelp home page GithubHelp logo

btc-arb's Introduction

Arbitrage Trading Bot

Why is this public?

This code was originally never meant to be made public because I created it and was using it myself. However, market conditions have changed and it's no longer very profitable to do this trade so I don't have a use for it anymore.

I decided to make it public because I haven't been very good at building up a public portfolio of my work and this may contribute. It was only ever intended for my eyes only so comments and docstrings are minimal and there are some pretty ugly logs spewed out into the terminal which was my crude but effective way of monitoring a trade.

What does/did it do?

The arbitrage involves 3 currencies, the Rand, Bitcoin and usually USD but I sometimes used EUR too.

Essentially, due to capital controls in South Africa, there is a profit to be made if you can get Rand out of the country (relatively easy but lots of red tape). One first buys USD and then uses the USD to buy Bitcoin in the foreign market. The bitcoin is then sent back into South Africa where it is sold for a profit (hopefully).

This project served to automate this process for me and more importantly time the buys/sells optimally to optimise profits. The most complex part of it involves placing an order on an exchange and then monitoring that order (by polling) to check if it has been filled or if it's moved from the top of the order book.

The biggest challenge was handling all the different states that the order might be in while ensuring that money is not lost. I used this code for about 2 years and it did very well for me.

Code breakdown

Most of the magic happens in models/trade.py and models/base_trade.py. This is where the core algorithm for starting, monitoring and completing a trade lives.

There are a lot of integrations with 3rd parties and exchanges so each has its own module. The ones that I didn't use much just have some simple wrappers but the three that I used most are created with an object-oriented approach, namely: integrations/luno.py, integrations/valr.py and integrations/bitstamp.py

There are also object-oriented models of an "order" for each major exchange.

I ran this code on an aws hosted linux server and would just execute the trades by running the scripts via the terminal via SSH.

btc-arb's People

Contributors

dylansharp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.