Giter VIP home page Giter VIP logo

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

Purpose

A simple trading equity trading model on Interactive Brokers' API dealing with (pseudo) high-frequency data studies.

alt text

What's New

8 Jun 2015

  • Refactor and conform to PEP8 standards
  • New chart display with 4 subplots

Requirements

How to Use

  • classes folder contain the required class files
  • models folder contain a simple trading model
  • params folder contain files storing the various settings used
  • Run main.py to start the model

Key Concepts

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

  • Bootstrapping the model with historical data to derive usable strategy parameters
  • Resampling inhomogeneous time series to homogeneous time series
  • Selection of highly-correlated stock pair
  • The ability to short on one stock and long the other.
  • Using volatility ratio to detect up or down trend.
  • Fair valuation of security using beta, or the mean over some past interval.
  • One pandas DataFrame to store prices, another one to store indicator values.

Other functionalities:

  • Generate trade signals and place buy/sell market orders based on every incoming tick data.
  • Re-evaluating beta every some interval in seconds.

And greatly inspired by these papers:

And book:

Wrote a Book

I wrote a book titled 'Mastering Python for Finance', discussing the interfacing of IbPy to Interactive Brokers step by step. A number of other topics such as analytics, algorithmic trading ideas, big data and financial theory are also discussed. You might find it useful. It is available on major sales channels including Amazon, Safari Online and Barnes & Noble, in paperback, Kindle and ebook. Get it from:

Source codes and table of contents on GitHub:

Check out these awesome books too:

Wrote a Gateway

What about trading futures? Psst I've got you covered.

Simply called 'The Gateway', it is a C# application that exposes a socket and public API method calls for interfacing Python with futures markets including CME, CBOT, NYSE, Eurex and ICE.

More information on my GitHub: https://github.com/hftstrat/The-Gateway-code-samples

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
  • 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
  • Add in alphas(P/E, B/P ratios) and Kalman filter prediction

Disclaimer

  • Any securities listed is not a solicitation to trade
  • This model has not been proven to be profitable in a live account, and I will not be responsible for any outcome of your trades. Should you be profitable, thank you notes are welcomed.

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!

Email stuff here: [email protected]

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

Contributors

jamesmawm avatar

Watchers

Joseph 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.