timesler / trading-feature-pretrainer

Code for generating pretrained deep learning networks equivalent to a wide variety of trading indicators, such as moving averages, MACD, RSI, and many more colorful metrics.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

trading-feature-pretrainer

This repo contains code for generating pretrained networks equivalent to a wide variety of trading indicators, such as moving averages, MACD, RSI, and many more colorful metrics.

The goal of this project is to generate neural networks that act as function approximators for an arbitrary set of deterministic transformations relevant to forex/stock/derivative market trading. These generated networks should form the input layers to networks built for specific purposes, such as policy gradient reinforcement learning trading agents. Depending on the application, generated network weights should be either fixed, making the generated networks act as generators of known features, or trained further in an application-specific context.

Note that although for some indicators, neural networks are at best function approximators (e.g., simple moving averages), other indicators can be represented exactly using carefully chosen neural network architectures and weights (e.g., exponential moving averages and moving average convergence divergence).

A simple illustration

Consider an exponential moving average, implemented by the following recursive equation:

EMAα(t) = αx(t) + (1 - α)EMAα(t - 1)

  where α = 2/(N + 1) for window N.

An exactly equivalent RNN can be constructed using a single recurrent neuron. The neuron accepts a single input, x, the hidden state is equivalent to EMAα(t - 1), and the output is equivalent to EMAα(t). From inspection of the equation above, the input and hidden state weights for the neuron are α and 1 - α, respectively.

Similarly, since Moving Average Convergence Divergence is defined as the difference between two exponential moving averages of different window sizes (say α and β), the following RNN is exactly equivalent:

About

Code for generating pretrained deep learning networks equivalent to a wide variety of trading indicators, such as moving averages, MACD, RSI, and many more colorful metrics.

License:MIT License


Languages

Language:Python 96.3%Language:Makefile 3.7%