Skip to content

This project is an app that sorts through historical trade data for Bitcoin on two exchanges: Bitstamp and Coinbase. I then apply the three phases of financial analysis to determine if any arbitrage opportunities existed for Bitcoin.

Notifications You must be signed in to change notification settings

Analitico-771/bitcoin_arbitrage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues LinkedIn

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. Contact
  7. Acknowledgements

About The Project

This project is an app that sorts through historical trade data for Bitcoin on two exchanges: Bitstamp and Coinbase. I then apply the three phases of financial analysis to determine if any arbitrage opportunities existed for Bitcoin.

Built With

Getting Started

  • You don't need Python. You can install Anaconda and JupyterLab normally just like any other application on your computer. Follow the instructions for Anaconda, ensure that its working, then install JupyterLab.

  • I have placed Comments throughout the code so that you can follow the code and be able to replicate the app on your own. Also, so that you're able to contribute in the future :-)

Prerequisites

A text editor such as VS Code or Sublime Text

Installation

  1. Clone the repo

    git clone https://github.com/AnaIitico/bitcoin_arbitrage.git
  2. You don't need to install pip - Conda comes with pip and you can also use the command conda install 'package name'

  3. Install Conda according to the instructions based on your operating system. For windows users you MUST use the Administrator PowerShell. Users with AMD Processors MUST use the Administrator PowerShell 7 (X64) version

    Once installed Conda has an Admin PowerShell version shortcut - look on your Start menu for it. This shortcut will prove very useful at times when you need to install other apps or make adjustments to your installation

    Once installed you will see (base) on your terminal

  4. Activate Conda Dev environment

    conda activate dev

    You should now see (dev) on your terminal

  5. Install JupyterLabs

    pip install jupyterlab
    
  6. Run JupyterLab

    jupyter lab

    A browser window should open on localhost:8889/lab

Usage

This project is an app that sorts through historical trade data for Bitcoin on two exchanges: Bitstamp and Coinbase. I then apply the three phases of financial analysis to determine if any arbitrage opportunities existed for Bitcoin.

Roadmap

Here are some screenshots and code snippets of the working app

Exchange Comparison January 2018

Exchange January Screen Shot

Exchange Comparison March 2018 - With Analysis

Exchange March Screen Shot

Calculate Arbitrage Profits Snippet - for January 16 only

you can see the full code (with outputs) in the crypto_arbitrage.ipynb file

This code has been summarized into one block for convenience and there's an analysis at the end

  # For the date early in the dataset, measure the arbitrage spread between the two exchanges
  # by subtracting the lower-priced exchange from the higher-priced one
  arbitrage_spread_early=coinbase['Close'].loc['2018-01-16']-bitstamp['Close'].loc['2018-01-16']
  arbitrage_spread_early = arbitrage_spread_early[arbitrage_spread_early>0]
  # Use a conditional statement to generate the summary statistics for each arbitrage_spread DataFrame
  arbitrage_spread_early.describe()

  # For the date early in the dataset, calculate the spread returns by dividing the instances when the
  # arbitrage spread is positive (> 0) 
  # by the price of Bitcoin from the exchange you are buying on (the lower-priced exchange).
  spread_return_early=arbitrage_spread_early/bitstamp['Close'].loc['2018-01-16']
  # Review the spread return DataFrame
  spread_return_early.head()

  # For the date early in the dataset, determine the number of times your trades with positive returns 
  # exceed the 1% minimum threshold (.01) that you need to cover your costs
  profitable_trades_early=spread_return_early[spread_return_early>.01]
  # Review the first five profitable trades
  profitable_trades_early.head()

  # For the date early in the dataset, generate the summary statistics for the profitable trades
  # or you trades where the spread returns are are greater than 1%
  profitable_trades_early.describe()

  # For the date early in the dataset, calculate the potential profit per trade in dollars 
  # Multiply the profitable trades by the cost of the Bitcoin that was purchased
  profit_early=profitable_trades_early * bitstamp['Close'].loc['2018-01-16']
  # Drop any missing values from the profit DataFrame
  profit_per_trade_early=profit_early.dropna()
  # View the early profit DataFrame
  profit_per_trade_early

  # Generate the summary statistics for the early profit per trade DataFrame
  profit_per_trade_early.describe()

  # Plot the results for the early profit per trade DataFrame
  profit_per_trade_early.plot(figsize=(10, 7), title="Profit Per Trade - Jan 16")

  # Calculate the sum of the potential profits for the early profit per trade DataFrame
  profit_sum_early=profit_per_trade_early.sum()
  profit_sum_early

  # Use the cumsum function to calculate the cumulative profits over time for the early profit per
  # trade DataFrame
  cumulative_profit_early=profit_per_trade_early.cumsum()
  # Plot the cumulative sum of profits for the early profit per trade DataFrame
  cumulative_profit_early.plot(figsize=(10, 7), title="Cumulative Sum - January 16")

  #**Answer:** The profit information supports the trend in the narrowing of the spread
  #from January to March. As the spread narrows, so does the opportunity for profit,
  #as it is evident in the calculated results.

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contact

Jose Tollinchi - @josetollinchi - [email protected]

Project Link: https://github.com/AnaIitico/bitcoin_arbitrage

Acknowledgements

About

This project is an app that sorts through historical trade data for Bitcoin on two exchanges: Bitstamp and Coinbase. I then apply the three phases of financial analysis to determine if any arbitrage opportunities existed for Bitcoin.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published