tg12/FAIG

Training and predicting module(s)

Closed this issue · 13 comments

This is to initialise the procedure the make the training and predicting modules.
This aims to replace line# 170-351 of FAIG/faig.py.

Can you briefly explain the idea?

tg12 commented

Yeah sure, So the idea is that Forex is based on Markov Chains to some extent.

https://gist.github.com/tg12/d7efa579ceee4afbeaec97eb442a6b72

This shows a simple example that predicts the next value of a series of simple integers. The idea been that what is the probability of transitioning from one state (in our case price) to another state (or price).

My idea is that we read in the prices for the epic and use this to determine the probability of moving from one price to another whether it it be higher (buy) or lower (sell).

Should I be working on this module, or someone else is also working on it?

tg12 commented

If you have a go at this, That would be great. This would be done in the main faig.py (I think) as an alternative (or addition too) way to chose the accuracy of the trade.

Sure, will give it a try. Still trying to understand the Markov Chains.

Also, strongly suggest to separate faig.py into modules. It will help the future commits. Otherwise, everyone will make some changes in faig.py and you will need a lot effort to merge all of them.

tg12 commented

Yeah it is a hard subject to get your head around, But from the example I provided if you could get it working with floating point numbers as is the price instead of integers in the example there, That would be a good start. Then we just need to read the transitional matrix and read the highest state transition probability, Checking if it is higher than the prediction rating and then determining if it is higher or lower (buy/sell)....

This is a very good point about the modules. This project has taken on a life of its own from my initial hacky script so I am very happy to see it grow like this!

Could you help me to understand this?

From the example above, in the matrix result, it represents the probability to move from price i to price j.
For example, given below matrix, there is a probability of 67% for it to move from price 1 to price 1 (i.e. no changes), and 33% chance to move from price 1 to price 2.

However, how are we going to determine these prices, since they are continuously?

#0.67 0.33 0.00 0.00 0.00 0.00 0.00 0.00 0.00
#0.00 0.50 0.12 0.12 0.25 0.00 0.00 0.00 0.00
#0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00
#0.00 0.00 0.00 0.50 0.50 0.00 0.00 0.00 0.00
#0.00 0.20 0.00 0.00 0.20 0.60 0.00 0.00 0.00
#0.17 0.17 0.00 0.00 0.17 0.33 0.00 0.17 0.00
#0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00
#0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00
#0.00 0.33 0.00 0.00 0.00 0.33 0.00 0.00 0.33

tg12 commented

Yeah, So my "theory" and that is what it is. Read in the prices for say x minutes or x hours. Whatever it may be. We can test this later. Then check the prediction rating and if it is over the predicted value then we can determine if that price range is up or down and if we should buy/sell. Hope that helps!.

Could you comment on below understanding?
Given a epic, we will first assign a target high and low price for it.

Then we apply the Markov model. Instead having a long list of different price, we have 3 categories only,

  1. lower than predicted low
  2. between predicted low and high
  3. higher than predicted high

The existing price must be at category 2.

Then we apply the model to estimate the chance of it to move from category 2 to categories 1, 2 and 3. If the probability is high enough, we may open a position.

Pretty sure you're already going this route, but this implementation shouldn't be inside faig.py, but from an imported module.
Until we know that this is a preferred method, make this prediction algorithm selectable via a hardcoded switch, or (if it's easy for end-users to understand) a config item. That way, we can run both prediction algorithms side-by-side, and just change which is preferred in default.conf (or the hardcoded item). If one continually out-performs the other, then the lesser can eventually be dropped entirely

Not starting this yet. Still at a stage to understand the idea.

Wondering how far we got with this. I see a prediction module now...is this thw markov chain implementation?

tg12 commented

markov chain implementation, Nope. This would not work with this kind of investing.

tg12 commented

markov chain not viable at this time.