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.74k stars 750 forks source link

Using prices directly as opposed to price relative vector? #30

Closed ielashi closed 6 years ago

ielashi commented 6 years ago

I was looking through the code and I noticed, if I understand correctly, that the inputs to the neural network are the prices directly and not the price relative vector defined in eq(1) of the paper. Is this intentional? Did I misread the code?

I guess it doesn't matter too much since, relative to BTC, prices of all other assets are < 1, but was curious if this was on purpose.

Here's the code I am looking at, where the price relative vector is passed to traditional agents but not to the neural network.

def generate_history_matrix(self):
        inputs = self.__get_matrix_X()
        if self._agent_type == "traditional":
            inputs = np.concatenate([np.ones([1, 1, inputs.shape[2]]), inputs], axis=1)
            inputs = inputs[:, :, 1:] / inputs[:, :, :-1]
        return inputs
dexhunter commented 6 years ago

I was looking through the code and I noticed, if I understand correctly, that the inputs to the neural network are the prices directly and not the price relative vector defined in eq(1) of the paper. Is this intentional? Did I misread the code?

The price was handled inside network. You can see the code there

ZhengyaoJiang commented 6 years ago

@ielashi Please also note that, the "relative price" for traditional agent is also different from our normalization method. Check the "3.2 Price Tensor" if you like to see the details.