ZhengyaoJiang / PGPortfolio

PGPortfolio: Policy Gradient Portfolio, the source code of "A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem"(https://arxiv.org/pdf/1706.10059.pdf).
GNU General Public License v3.0
1.73k stars 748 forks source link

Some detail in globaldatamatrix.py #102

Open felixenzogarofalo opened 6 years ago

felixenzogarofalo commented 6 years ago

In file pgportfolio.marketdata.globaldatamatrix line 80 we find: sql = ("SELECT date+300 AS date_norm, close FROM History WHERE"

I believe is better like this, for general purpose: sql = ("SELECT date+{period} AS date_norm, close FROM History WHERE":

That's the way I finded, in the following lines.

ErnstDinkelmann commented 6 years ago

@felixenzogarofalo , that is not correct. It is correct in the code. The data incoming from Poloniex: at datetime t, with a period of a, it reflects period t to t+a. So Close will be the Close price from t to t+a.

For the model, we want it to be backwards looking. So at datetime t, with period a, it should reflect the period t-a to t. So Close will be the Close price from t-a to t.

I've tested the above as I was looking at it as well. The 300 looks incorrect, but since the data always arrives in periods of 300 and with the above mentioned required for the period shift, it works.

To test, download a simple SQL Lite DB viewer and run the queries.