Coder Social home page Coder Social logo

rados10 / ib-trading-models-and-backtester Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamesmawm/ib-trading-models-and-backtester

0.0 0.0 0.0 168 KB

Modular trading models with Interactive Brokers and backtester in Python

Python 100.00%

ib-trading-models-and-backtester's Introduction

Readme

This is an enhancement to the current version of High Frequency Trading Model with IB @ https://github.com/jamesmawm/High-Frequency-Trading-Model-with-IB.

In this version, I've decoupled modules, used functional programming styles, made things simpler and enable switching between different strategies. Oh, and a custom backtester too with bid/ask price simulated events (Zipline gave my code cancer).

Again, these files are for evaluation purposes only and do not constitute real profitable trading models.

Features

  • Reuse multiple strategies on the same IB framework. See src/Strat-Empty.py for a template.
  • src/Backtester/* contains custom backtester which reads in a CSV file. Supports limit orders-based strategies with bid ask price simulation.

Strategies

  • Strat-Pairs.py: Pairs trading through cointegration, using OLS and Pandas.
  • Strat-LmtOrdrs.py: Limit-order based strategy with GUI dashboard. Works with backtester.
  • Strat-CorrelRptr.py: Stores ticks in a dataframe and reports the correlations.

How To

  • Connecting to IB and getting live ticks in 3 simple steps:
self.ibhft = ibHFT.IbHFT()
self.ibhft.set_connection_with_api_gateway(False)
self.ibhft.start_data_stream(self.on_started
                                 , self.on_tick
                                 , STOCKS_TO_STREAM
                                 , self.on_position_changed)

  • Same 3 simple steps in getting historical data:
self.ibhft = ibHFT.IbHFT()
self.ibhft.set_connection_with_api_gateway(False)
self.ibhft.start_historical_data_stream(self.stocks_to_stream
                                  , self.duration
                                  , self.interval
                                  , self.process_historical_data)
  • For backtesting, same 3 simple steps:
self.ibhft = bt.Backtester()
self.ibhft.set_csv_file("ticks 10 mins - Jun 25 2014.csv")
self.ibhft.start_data_stream(self.on_started
                                 , self.on_tick
                                 , STOCKS_TO_STREAM
                                 , self.on_position_changed)

ib-trading-models-and-backtester's People

Contributors

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