Coder Social home page Coder Social logo

sjqtentacles / high-frequency-trading-model-with-ib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamesmawm/high-frequency-trading-model-with-ib

0.0 1.0 1.0 1.02 MB

A high-frequency trading model using Interactive Brokers API with pairs and mean-reversion in Python

high-frequency-trading-model-with-ib's Introduction

Purpose

These files are intended for recruiters, headhunters and hiring managers in evaluating my proficiency in Python and looking to fill entry-level roles in automated trading strategy development, quantitative trading/developer/analyst/researcher, portfolio management/analyst, high-frequency trading, data analyst/visualization, and model validation.

Requirements

Key Concepts

At the present moment, this model utilizes statistical arbitrage incorporating these methodologies:

  • Cash-neutral strategy with long-short position
  • Bootstrap the model with historical data to derive usable strategy parameters
  • Bootstrapping takes some time, we need to bridge historical data with recent tick data
  • Transforming inhomogenous to homogeneous time series of 1 second intervals
  • Selection of highly-correlated stock pairs
  • Using volatility ratio to detect trending, mean-reversion or Brownian motion
  • Fair valuation by using beta of average 5 minute look-back price window
  • Fair valuation of stock A against more than 1 security (stock B, C...) is possible
  • Trade decisions based on mean-reversion, volatility ratio and deviation from fair prices

Other functionalities:

  • Generate trade signals and place buy/sell orders based on every incoming tick data
  • Re-evaluating beta every 30 seconds to account for small regime shifts

And greatly inspired by these papers:

And book:

Future Enhancements

I would love to extend this model in the unforeseeable future:

  • Extending to more than 2 securities and trade on optimum prices
  • Generate trade signals based on correlation and co-integration
  • Using PCA for next-period evaluation
  • Back-testing with zipline
  • Maybe include vector auto-regressions
  • Account for regime shifts (trending or mean-reverting states)
  • Account for structural breaks
  • Using EMA kernels instead of a rectangular one
  • Use and store rolling betas and standard deviations
  • Add in alphas(P/E, B/P ratios) and Kalman filter prediction
  • Storing of tick data in MongoDb for future back-tests.

What It Can Do

  • Establish connection to broker and request for tick data
  • Generate trade signals on each incoming tick
  • Open position with buy/sell orders, and reverse position
  • Display and update chart in real-time of stock A's last prices and fair prices using stock B

Disclaimer

  • Any securities listed is not a solicitation to trade
  • This model has not been proven to make money, and I will not be responsible for any outcome of your trading account

Is this HFT?

Sure, I had some questions "how is this high-frequency" or "not for UHFT" or "this is not front-running". Let's take a closer look at these definitions:

  • High-frequency finance: the studying of incoming tick data arriving at high frequencies, say hundreds of ticks per second. High frequency finance aims to derive stylized facts from high frequency signals.

  • High-frequency trading: the turnover of positions at high frequencies; positions are typically held at most in seconds, which amounts to hundreds of trades per second.

This models aims to incorporate the above two functions and present a simplistic view to traders who wish to automate their trades, get started in Python trading or use a free trading platform.

Final Notes

  • I haven't come across any complete high-frequency trading model lying around, so here's one to get started off the ground and running.
  • This model has never been used with a real account. All testing was done in demo account only.
  • The included strategy parameters are theoretical ideal conditions, which have not been adjusted for back-tested results.
  • This project is still a work in progress. A good model could take months or even years!
  • I possess a valid US EAD.

Email stuff here: [email protected]

high-frequency-trading-model-with-ib's People

Contributors

jamesmawm avatar

Watchers

 avatar

Forkers

obswork

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.