2018年1月18日木曜日

GDP, PAYEMS,PERMIT and S&P500


> kikan
[1] "1992-01-01::2017-09-30"
> summary(lm(apply.quarterly(SP5[kikan],mean)[,1] ~ apply.quarterly(PA[kikan],mean) * apply.quarterly(PERMIT[kikan],mean) * G[kikan] - apply.quarterly(PERMIT[kikan],mean) -G[kikan] ))

Call:
lm(formula = apply.quarterly(SP5[kikan], mean)[, 1] ~ apply.quarterly(PA[kikan],
    mean) * apply.quarterly(PERMIT[kikan], mean) * G[kikan] -
    apply.quarterly(PERMIT[kikan], mean) - G[kikan])

Residuals:
    Min      1Q  Median      3Q     Max
-356.42  -70.14  -14.41   74.25  265.08

Coefficients:
                                                                                 Estimate Std. Error t value Pr(>|t|) 
(Intercept)                                                                     4.085e+03  8.181e+02   4.993 2.62e-06 ***
apply.quarterly(PA[kikan], mean)                                               -5.823e-02  1.067e-02  -5.460 3.66e-07 ***
apply.quarterly(PA[kikan], mean):apply.quarterly(PERMIT[kikan], mean)           2.845e-05  3.573e-06   7.962 3.24e-12 ***
apply.quarterly(PA[kikan], mean):G[kikan]                                       2.596e-06  3.412e-07   7.608 1.81e-11 ***
apply.quarterly(PERMIT[kikan], mean):G[kikan]                                  -7.652e-04  6.821e-05 -11.218  < 2e-16 ***
apply.quarterly(PA[kikan], mean):apply.quarterly(PERMIT[kikan], mean):G[kikan]  3.642e-09  3.657e-10   9.959  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 124.1 on 97 degrees of freedom
Multiple R-squared:  0.9411, Adjusted R-squared:  0.938
F-statistic: 309.9 on 5 and 97 DF,  p-value: < 2.2e-16

2018年1月15日月曜日

purchase history.

---------------------------------------------------------------------------------------------

Fully Executed 13 Jan 2014 Buy
P-500589 FAS 300 shares
Outstanding Qty: 0 shares
Total Executed Qty: 300 shares 91.3799 USD
--------------------------------------------------------------------------------------------
Fully Executed 09 Jan 2014 Buy
P-449838 FAS 100 shares
Outstanding Qty: 0 shares
Total Executed Qty: 100 shares 91.6699 USD
---------------------------------------------------------------------------------------------
Fully Executed 09 Jan 2014 Buy
P-449832 SPXL 300 shares
Outstanding Qty: 0 shares
Total Executed Qty: 300 shares 62.2399 USD
---------------------------------------------------------------------------------------------
Fully Executed 02 Jan 2014 Buy
P-296549 SPXL 200 shares
Outstanding Qty: 0 shares
Total Executed Qty: 200 shares 62.56 USD
----------------------------------------------------------------------------------------------
Fully Executed 30 Dec 2013 Buy
P-262561 SPXL 500 shares
Outstanding Qty: 0 shares
Total Executed Qty: 500 shares 62.93 USD
---------------------------------------------------------------------------------------------
Fully Executed 26 Dec 2013 Buy
P-878321 FAS 500 shares
Outstanding Qty: 0 shares
Total Executed Qty: 500 shares 89.81 USD
---------------------------------------------------------------------------------------------
Fully Executed 26 Dec 2013 Buy
P-878316 SPXL 1,000 shares
Outstanding Qty: 0 shares
Total Executed Qty: 1,000 shares 62.66 USD
---------------------------------------------------------------------------------------------
Fully Executed 23 Dec 2013 Buy
P-864555 SPXL 500 shares
Outstanding Qty: 0 shares
Total Executed Qty: 500 shares 61.57 USD
------------------------------------------------------------------------------------------------
Fully Executed 23 Dec 2013 Buy
P-864552 FAS 500 shares
Outstanding Qty: 0 shares
Total Executed Qty: 500 shares 88.50 USD
------------------------------------------------------------------------------------------------
Fully Executed 20 Dec 2013 Buy
P-844082 FAS 500 shares
Outstanding Qty: 0 shares
Total Executed Qty: 500 shares 86.00 USD
--------------- -------------- ---------- ----- -----------------
Fully Executed 08 Dec 2013 Buy
P-600562 SPXL 500 shares
Outstanding Qty: 0 shares
Total Executed Qty: 500 shares 59.85 USD
-------------------------------------------------------------------------------------------------
Fully Executed 06 Dec 2013 Buy
P-600562(598416001) SPXL 500 shares
Outstanding Qty: 0 shares
Total Executed Qty: 500 shares 58.80USD



89.81 * 500 + 62.66 * 1000 + 61.57 * 500 + 88.5 * 500 + 86 * 500 + 59.85 * 500 + 58.8 * 500 + 62.93 * 500 + 62.56 * 200
=328902.00

62.66 * 1000 + 61.57 * 500 + 59.85 * 500 + 58.8 * 500  + 62.93 * 500   + 62.56 * 200 + 62.2399 * 300
=215418.97
215418.97 / 3500
= 61.55

89.81 * 500 + 88.5 * 500 + 86 * 500  + 91.6699 * 100 + 91.3799 * 300
= 168735.9600
168735.9600 / 1900
=88.81

3000 * 63.8
=191400.0
1500 * 90.30
=135450.00

2018年1月12日金曜日

managing portfolio - building portfolio table. - vol3


update the script to calculate both USD and JPY total.

x <- as.data.frame(tapply(read.csv("~/f4.csv")$quantity,read.csv("~/f4.csv")$ticker,sum))
colnames(x)[1] <- "shares"
z <- as.data.frame(tapply(read.csv("~/f4.csv")$quantity,read.csv("~/f4.csv")$ticker,sum))
colnames(z)[1] <- "shares"
z2 <- transform(z,ticker=rownames(z))
my_pf <- transform(z2,currency=mapply(function(x) read.csv("~/f4.csv")[grep(x,read.csv("~/f4.csv")$ticker),5][1],my_pf$ticker))
mapply(my_getsymbols,my_pf$currency,my_pf$ticker)     
my_pf <- transform(my_pf,total=mapply(function(x,y) x*last(get(as.character(y))[,4]),z2$shares,z2$ticker))
tapply(my_pf$total,my_pf$currency,sum)                 
getFX("USD/JPY")                                   
print("JPY TOTAL")
tapply(my_pf$total,my_pf$currency,sum)["JPY"] + tapply(my_pf$total,my_pf$currency,sum)["USD"] * last(USDJPY)
print("USD TOTAL")
tapply(my_pf$total,my_pf$currency,sum)["JPY"] /  last(USDJPY) + tapply(my_pf$total,my_pf$currency,sum)["USD"]
beep(2)