Giter Site home page Giter Site logo

stjordanis / r-tseries-patterns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tr8dr/r-tseries-patterns

0.0 1.0 0.0 294 KB

trend / momentum and other patterns in financial timeseries

License: MIT License

R 0.86% Jupyter Notebook 97.20% C++ 1.94%

r-tseries-patterns's Introduction

Financial Timeseries Patterns library

This package will contain a collection of price pattern detectors (online and offline). I am starting this library by open sourcing one of the labeling algorithms I use.

A few years ago developed an algorithm to label momentum and trend patterns in intra-day or daily price data. In spite of its simplicity, has performed quite well as compared to a number of more complicated statistical approaches. As is not especially proprietary, hence thought to share this more broadly. I will be adding other pattern related algorithms to this library over time.

I use these algorithms for:

  • collecting price moves for pattern analysis
  • comparing online trend or MR signal versus optimum behavior as identified ex-post by this labeler
  • labels for supervised machine learning in learning momentum signals
  • studying market microstructure around large moves

AmplitudeBasedLabeler

The labeler behavior is defined by two parameters (which seem intuitive from a trading perspective):

  • minimum trend / momentum amplitude of interest
    • this should be some multiple of volatility / noise
  • maximum amount of noise allowed in move:
    • defined by maximum period where no new high (low) is achieved), as well as
    • no drawdown in move exceeding the minimum move amplitude

There are other ways to define noise or extension, but these choises resulted in a super-simple model, that works well. In addition an incremental OLS is performed to determine which points best fit the move, discarding outliers around the edges.

Examples

Below are some examples of the same (intra-day) data series, parameterized for more noise, less noise, higher or lower minimum amplitudes.

Labeling (minamp = 20bps, Tinactive = 5mins)

This was performed on 30sec bars (so 5mins = 10 bars)

labeler <- AmplitudeBasedLabeler$new (minamp = 20, Tinactive = 10)
labels <- labeler$label (df)
labeler$plot()

Graph of labels

Labeling (minamp = 20bps, Tinactive = 15mins)

This was performed on 30sec bars (so 15mins = 30 bars)

labeler <- AmplitudeBasedLabeler$new (minamp = 20, Tinactive = 30)
labels <- labeler$label (df)
labeler$plot()

Graph of labels

r-tseries-patterns's People

Contributors

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