Giter Club home page Giter Club logo

frama's Introduction

FRAMA (Fractal Adaptive Moving Average) in Python

Introduction

The aim of this repository is to provide functions of FRAMA written in python for both educational and industrial purposes. FRAMA is a state of the art Moving Average estimator(or was by the time u read this...). It is used in economics for stock prices and Wall Street stuff, but it can also be used from anyone as a better moving average algorithm. It works better on time series which present the same shape despite the length of the data timestamps type (sec, minutes, hours, days,...).

Libraries & Dependencies

  • Numpy

  • Compiled with Python 2.7.6

More Details

To present more details we will use a top-down approach. The algorithm uses an adaptive low-pass filter with one term alpha. So it should look something like this:

    for i in range(1,N):
        Filt[i+1] = alpha * InputPrice[i] + (1 - alpha) * Filt[i]

Now the problem is how do we calculate alpha at each step?

alpha is changed according to something called the fractal dimension.

So alpha is calculated as

eq1

The fractal dimension id D needs to be computed at every iteration step. The fractal dimension is defined by this relation:

eq2

where N1 and N2 are defined as:

    N1 = (max(v1) - min(v1)) / batch
    N2 = (max(v2) - min(v2)) / batch    

where v1 is a batch of the input and v2 is exactly the next batch of the input. batch is the number of data points per batch.

Now N3 is defined as

    N3 = (max([v1,v2]) - min([v1,v2])) / (2*batch)

and is the maximum over both batches and devided by the number of data points inside them.

Now, if you go from down up it will result in the code inside frama_numpy.py.

If still not satisfied from the explanation check the code and the References.

Results Galery

First example

Second example

Third example

Fourth example

Fifth example

Feel free to send me your own examples! Thanks!

References

  1. Ehlers, John. "FRAMA–Fractal Adaptive Moving Average." Technical Analysis of Stocks & Commodities (2005).

frama's People

Contributors

supernlogn avatar

Watchers

James Cloos 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.