Ivsxk / RAT

62 stars 43 forks source link

Total asset from three-headed output #11

Open hanseul-jeong opened 3 years ago

hanseul-jeong commented 3 years ago

Hi, I have a question about total wealth. In your work, the output is summation of three heads initial, short, and reinvest vector, respectively.

The total sum of three heads is 1+(-1) + 1 = 1. But this value is not considered of total asset volume. The absolute asset is 3. So, i think it’s like managing three times asset.

(Of course, if the two output values are not zero for both positive and negative heads, respectively, then each absolute value will be offset because the final portfolio value is generated in addition. However, if you finally put short position, you will always use more than 1.)

For example, for 3 stocks, the final portfolio value is like this at time t, A_t = [0.8, -0.3, 0.5]. Abs(A_t) = 0.8 + -(-0.3) + 0.5 = 1.6. So, final portfolio vector have to be scaled by 1.6. Proper portfolio vector is A_t’ = [0.8/1.6, -0.3/1.6, 0.5/1.6].

If I misunderstood something, please let me know. Thank you!

Ivsxk commented 3 years ago

Hi, I have a question about total wealth. In your work, the output is summation of three heads initial, short, and reinvest vector, respectively.

The total sum of three heads is 1+(-1) + 1 = 1. But this value is not considered of total asset volume. The absolute asset is 3. So, i think it’s like managing three times asset.

(Of course, if the two output values are not zero for both positive and negative heads, respectively, then each absolute value will be offset because the final portfolio value is generated in addition. However, if you finally put short position, you will always use more than 1.)

For example, for 3 stocks, the final portfolio value is like this at time t, A_t = [0.8, -0.3, 0.5]. Abs(A_t) = 0.8 + -(-0.3) + 0.5 = 1.6. So, final portfolio vector have to be scaled by 1.6. Proper portfolio vector is A_t’ = [0.8/1.6, -0.3/1.6, 0.5/1.6].

If I misunderstood something, please let me know. Thank you!

The softmax function has limited the output of each head to nonnegative.

hanseul-jeong commented 3 years ago

The output i mean is final portfolio vector instead of output of softmax function.

In your codes, (EncoderDecoder class)

    out = self.linear_out(out)                    #[128,11,2*12+1]->[128,11,1]

    bias = self.bias.repeat(out.size()[0],1,1)    #[128,1,1]
    bias2 = self.bias2.repeat(out2.size()[0],1,1) #[128,1,1]

    out = torch.cat([bias,out],1)                 #[128,11,1] cat [128,1,1] -> [128,12,1]
    out2 = torch.cat([bias2,out2],1)              #[128,11,1] cat [128,1,1] -> [128,12,1]

    out = out.permute(0,2,1)                      #[128,1,12]
    out2 = out2.permute(0,2,1)                    #[128,1,12]

    out = F.softmax(out, dim = -1)
    out2 = F.softmax(out2, dim = -1)

    out = out*2
    out2 = -out2
    return out+out2                             #[128,1,12]

this output (return) could be negative value due to out2.

HanLi123 commented 3 years ago

@hanseul-jeong you are right, the sum of out+out2==1 does not guarantee the abs elementwise_sum==1

@Ivsxk I think she means not use leverage in portfolio

Ivsxk commented 3 years ago

Sorry about that I misunderstood your question. The final portfolio vector has no need to be scaled by 1.6. Someone borrows 0.3 for reinvesting, which does not mean she/he owns 1.6. The total asset volume belongs to she/he is 1.

hanseul-jeong commented 3 years ago

Abs(A_t) = 0.8 + -(-0.3) + 0.5 = 1.6.

In that case, i think, ignoring the 0.3 (borrowed ratio), the volume of total assets is 1.3.