Skip to content

This algorithm takes advantage of an arbitrage between certain dual-class shares that hold nearly identical market caps.

License

Notifications You must be signed in to change notification settings

Shivamkak19/Dual-Class-Arbitrage-Algorithm

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


dual-class shares to monitor

Project Description

This algorithm takes advantage of an arbitrage between certain dual-class shares that hold nearly identical market caps. Specifically, it identifies price discrepencies between publicly-traded shares in a dual-class structure and simultaneously marks both a short and a long position (for an example of dual-class structure, Google Class A: GOOG vs Google Class B: GOOGL, Berkshire Hathaway Class A: BERK.A, Berkshire Hathaway Class B: BERK.B). The underlying assumption is that the similar market caps of the dual-class shares will eventually drive share prices to converge, meaning either the long or the short will be able to return a profit.

Notes: I have hard-coded a list of popular dual-class shares in "shares.csv". This list can be adjusted to preference. Additionally, an account is recognized as a Pattern Day Trader if it makes 4 day trades in a 5 day period with an account balance < $25,000. For learning purposes, the scheduler is only set up to run trades within this strict limit.

*C# implementation is still in development. Instructions for the Python implementation are listed in sections below.


View Product · Report Bug · Request Feature

Table of Contents
  1. Getting Started
  2. Usage
  3. Roadmap
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

Built With

  • Alpaca-Py
  • Darqube
  • Scheduler
  • Pandas
  • Streamlit

(back to top)

Getting Started

Below, the set-up process is listed to run this project on your local machine. Note, the C# implementation is not yet live. Instructions for the Python implementation are included below.

Prerequisites

To run this project, you must download the latest version of the pip installer

  • pip install --upgrade pip

Installation

  1. Clone the repo

    git clone https://github.com/Shivamkak19/Dual-Class-Arbitrage-Algorithm.git
  2. Switch to py folder

    cd py
  3. Install dependencies

    pip install -r requirements.txt

(back to top)

Usage

This project was designed as a learning project for the purpose of exposure into the process of developing trading algorithms. Any usage must be compliant with Pattern Day Trading rules, and failure to comply to these standards will result in the user's Alpaca client being flagged and banned. Feel free to tinker with this algorithm and explore. Do make sure to replace the dummy text with your unique Client ID and secret key.

(back to top)

Roadmap

  • Designate target dual-class shares
  • Authenticate Alpaca API with Client ID and secret
  • Perform HTTP GET/POST requests to fetch information from Alpaca Trading Client
    • Set up functionality to order long position, short position, sell open positions, and cancel pending positions
  • Perform GET requests to Darqube API for live share pricing information
  • Create algorithm for margins at which to buy/sell short and long positions
  • Liquidate all holdings 5 minutes before closing bell
  • Set up Python Scheduler to send necessary API calls every 30 sec, open hours, Mon - Fri
  • Create simple user interface to manage holdings via Streamlit

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

(back to top)

Contributing

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

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

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

(back to top)

Acknowledgments

  • Adam Hayes, Investopedia contributor, for a thorough explanation of dual-class shares and arbitrage.
  • Article Link: Investopedia Article

(back to top)

About

This algorithm takes advantage of an arbitrage between certain dual-class shares that hold nearly identical market caps.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published