Git Product home page Git Product logo

pairstrading's Introduction

The source code for this pairs trading depends on data from eoddata.com. The data is imported into the MongoDB and then initialized from the main program: realTimePairs.py

The system creates optimized pairs based on what parameters (days MA, standard deviations,...) created profitable trades.

We first look at what we will use to describe and track a pair. 1)The individual price stock histories 2)The ratio of the prices. (The ratio is simply one price divided by the other.) 3)The standard deviation of the ratio. 4)The moving average of the ratio. 5)The correlation of the price history of the two stocks 6)Though not a requirement we will be using the coefficient of variation - the standard deviation divided by the average.

Generally, when the ratio exceeds 2 standard deviations and is returning to correlation the trade is entered and when the correlation is near the original level, the trade is exited. But many arbitrary assumptions immediately come in view.

For example, decisions need to be made for determining if the pair is correlated at all. From which time period of the price history do we use to calculate the correlation? And for how long? Can't be too long ago since the landscape may have changed and is no longer valid. Can't be too recent since the overlap of the divergence will invalidate the calculation and we need that breakdown of correlation to make the pair trade. Thus, we would never find a correlated pair.Also, how correlated do we need the pair to be? 70%? 90%? Remember that the more correlated the pair the smaller 2 standard deviations will be and make the trade very short.

The point is that a pairs behavior is unique to each pair. For some, 2 standard deviations will create an opportunity. For others, 3 standard deviations is a better opportunity and some 1.75 standard deviations will be optimal. If we were to vary every variable listed above and move through the history we could classify the values used for the history as a profitable or not-profitable parameter set. At the end of the "calibration" step, we would keep only the most profitable parameters and use those for future searches.

Of course with any trading system, use at your own risk.

If you need more info, please contact me.

pairstrading's People

Contributors

mthamm avatar

Watchers

 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.