Giter VIP home page Giter VIP logo

huba-v1's Introduction

What is this?

This repo holds the very first algo trading strategy I have developed and live traded from 2012 to 2016.

It was built using PyAlgoTrade with the Pair Trading / Stat Arb guidelines posted in Ernie Chan's Quantitative Trading book.

Why are you releasing it?

It created lower-than-expected live trading returns, so I moved on. I think it might be useful for others as learning material.

Even though it made some profits live, it wasn't up to my expectation: The initial capital trading this strategy was $40k. While continuously adding savings to the account, it ended up making $6k over the 3-year period. Even if we ignore the fact that additional was capital was deployed to the account the CAGR would be around 5%.

I made two other iterations of this strategy: huba-v2 and huba-v3 will be released shortly, with similar commentary.

What was the approach?

Finding cointegrated pairs and trading them long/short when they drift too far apart from their expected fair price. You can find all the details in Ernie's first and second book on the subject.

What did u do step by step?

  1. Purchased minute data from iqfeed, ingested it
  2. Implemented Statistical Arbitrage as discussed in the book
  3. Created a liquidity and price filter to filter out non-tradable stocks
  4. Created pairs for each equity sector
  5. Did a bruteforce on half of my data
  6. Picked the best looking pairs, which seemed to make sense
  7. Validated them on my other half of the data
  8. Picked the ones which still remained reasonable and put it into paper trading
  9. After gaining confidence put the best pairs to live trading
  10. Explored AD-Fuller tests, Hurst exponents, Earnings filters and bunch of other stup
  11. Profit of 6k after 4 years
  12. Moved on to zipline based implementation (huba-v2)

What have you learned from this?

  1. Max time in trade is a must. huba-v1 didn't have this implemented, but huba-v2 has this feature.
  2. Running this strategy for 3 years had a serious opportunity cost.
  3. Getting intra-day data was challenging and expensive at the time.
  4. Finding pairs by grid-search (even in the same industries) is expensive and often results from spurious discoveries.

What others can learn from this?

Some pairs I traded might still show correlation.

Why is the code not pythonic?

Coming from C/C++ background this was my first serious Python project.

How did you search for pairs?

The whole solution was migrated to PyPy so that we have reasonable speed. Then machines were crunching data for weeks. The pair-scan results are located here.

What's next?

Over time I have created two additional iterations of the StatArb strategy:

After these iterations I gave up and moved to Mean Reversion and Momentum Strategies.

Most recently I learned Options Trading and created a backtester service for income strategies.

I made this work, what shall I do now?

If you don't mind sharing with me, that is awesome.

Drop me a mail at tibor (d0t) kiss (at-sign) gmail (d0t) com.

If you don't feel like sharing, that's also fine. Enjoy the ride! :)

I have something to say publicly about this strategy.

Please use the Discussion Board.

Can I buy you a coffee?

Sure, thank you for your consideration!

What is HUBA?

It is a joke delivered as an acronym: Highly Unorthodox Broker Agent.

I must admit: nothing is unorthodox about this approach (it is well studied).

When I started developing this strategy Hungary's Minister of Economy Huba Gyorgy, Matolcsy started campaigning with his 'Unorthodox' approaches. I thought this project will be as qualified as his decisions, hence the name.

huba-v1's People

Contributors

tibkiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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