2019年6月26日水曜日

Windows profile bug


Another important recommendation from our developers is to contact Microsoft directly. In other words, once any customer manages to reproduce the issue while collecting the requested log they should raise a ticket with Microsoft. Without analysis from MS we won’t be able to do anything on our side, so involving MS is crucial at this point. To speed things up, the customer should refer to advisory case # 117062115926216. 

2019年6月19日水曜日

EPS 2019JUN19



> eps_year_xts["2019::"]
             [,1]
2019-01-01 134.48
2019-04-01 137.14
2019-07-01 139.58
2019-10-01 150.77
2020-01-01 153.98
2020-04-01 158.28
2020-07-01 162.93
2020-10-01 167.58
> eps_year_xts["2019::"][1]
             [,1]
2019-01-01 134.48
> eps_year_xts["2019::"][1] <- 134.32
> eps_year_xts["2019::"][2] <- 137.01
> eps_year_xts["2019::"][3] <- 139.53
> eps_year_xts["2019::"][4] <- 150.72
> eps_year_xts["2019::"][5] <- 154.31
> eps_year_xts["2019::"][6] <- 158.70
> eps_year_xts["2019::"][7] <- 163.52
> eps_year_xts["2019::"][8] <- 168.46
> eps_year_xts["2019::"]
             [,1]
2019-01-01 134.32
2019-04-01 137.01
2019-07-01 139.53
2019-10-01 150.72
2020-01-01 154.31
2020-04-01 158.70
2020-07-01 163.52
2020-10-01 168.46

eps_year_xts["2019::"][1] <- 134.32
eps_year_xts["2019::"][2] <- 137.01
eps_year_xts["2019::"][3] <- 139.53
eps_year_xts["2019::"][4] <- 150.72
eps_year_xts["2019::"][5] <- 154.31
eps_year_xts["2019::"][6] <- 158.70
eps_year_xts["2019::"][7] <- 163.52
eps_year_xts["2019::"][8] <- 168.46

$cat eps.txt 
12/31/2020 $49.27 $45.10 15.65 17.17 $184.82 $168.46
9/30/2020 $47.66 $43.70 16.09 17.68 $179.67 $163.52
6/30/2020 $45.31 $41.13 16.55 18.22 $174.77 $158.70
3/31/2020 $42.58 $38.53 17.06 18.74 $169.53 $154.31
12/31/2019 $44.12 $40.16 17.53 19.19 $164.93 $150.72
9/30/2019 $42.76 $38.88 18.56 20.72 $155.84 $139.53
6/30/2019 $40.07 $36.74 18.72 21.11 $154.46 $137.01
3/31/2019 (98.2%) 2834.40 $37.98 $34.95 18.89 21.53 $153.04 $134.32

のとき

$tac eps.txt | awk '{gsub("\\$","",$NF);print "eps_year_xts[\"2019::\"]["NR"] <- "$NF}'
eps_year_xts["2019::"][1] <- 134.32
eps_year_xts["2019::"][2] <- 137.01
eps_year_xts["2019::"][3] <- 139.53
eps_year_xts["2019::"][4] <- 150.72
eps_year_xts["2019::"][5] <- 154.31
eps_year_xts["2019::"][6] <- 158.70
eps_year_xts["2019::"][7] <- 163.52

eps_year_xts["2019::"][8] <- 168.46

2019年6月18日火曜日

サトウキビ(砂糖キビ) -- sugarcane.



from 2019/3/26 conversation.

Cost for 3 acre plowing and planting.

  1. sugarcane varieties 
  2. worker wage,plow and planning 
  3. Fertilizer packages price = 40,000 baht for 1 acre.. ????
  4. Food pice 10,000 baht...

Harvest


  1. 3 acre = 90 ton
  2. selling price is 1 ton =900 baht.
  3. 90 ton * 900 bhat = 81,000 baht
  4. if add 2 more acre, 2 acre = 60 ton =  54,000 THB
  5. total 5 acre = 150 ton = 135,000 THB 
  6. 5 acre = 2.02343 ha.

Cost 2 acre to plow and plant

  1.  30,000 baht..
買取価格

上記「Harvest」と値が違うので注意。
  1. 自分で収穫、工場に納める場合 700 thb/t
  2. 収穫、輸送を依頼する場合 500 thb/t


2019年6月17日月曜日

CLI - composite leading indicator - USA, China and Europe Area


> summary(lm(cli_xts$oecd ~ cli_xts$usa + cli_xts$ea19 + cli_xts$china))

Call:
lm(formula = cli_xts$oecd ~ cli_xts$usa + cli_xts$ea19 + cli_xts$china)

Residuals:
     Min       1Q   Median       3Q      Max
-0.68475 -0.09634  0.03744  0.11972  0.41636

Coefficients:
              Estimate Std. Error t value Pr(>|t|) 
(Intercept)   9.265072   1.036438   8.939   <2e-16 ***
cli_xts$usa   0.402771   0.013317  30.246   <2e-16 ***
cli_xts$ea19  0.438171   0.012302  35.618   <2e-16 ***
cli_xts$china 0.065993   0.006695   9.857   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.1958 on 348 degrees of freedom
  (420 observations deleted due to missingness)
Multiple R-squared:  0.9577, Adjusted R-squared:  0.9573
F-statistic:  2624 on 3 and 348 DF,  p-value: < 2.2e-16

> last(cli_xts,n=12)
                       oecd           usa           china         ea19
2018-05-01 100.33250 100.47600 99.29018 100.53100
2018-06-01 100.22810 100.42840 99.13142 100.40680
2018-07-01 100.11390 100.36340 98.96715 100.28170
2018-08-01  99.98618 100.27230 98.80726 100.14970
2018-09-01  99.84174 100.13410 98.67062 100.01150
2018-10-01  99.68746  99.94146 98.57309  99.87226
2018-11-01  99.53398  99.71795 98.51999  99.73539
2018-12-01  99.38741  99.48866 98.50362  99.59542
2019-01-01  99.25877  99.28568 98.52641  99.45764
2019-02-01  99.15687  99.12820 98.58793  99.32590
2019-03-01  99.08728  99.01845 98.69128  99.20160
2019-04-01  99.03429  98.93993 98.80725  99.08523

for future reference.

> last(tmp.predict,n=6)
        SP5.Open SP5.High SP5.Low SP5.Close  SP5.Volume   spline      eps
 1 2019  2476.96  2708.95 2443.96   2704.10 80391630000 2906.849 2760.208
 2 2019  2702.32  2813.49 2681.83   2784.49 70183430000 2929.656 2779.348
 3 2019  2798.22  2860.31 2722.27   2834.40 78596280000 2956.669 2804.840
 4 2019  2848.63  2949.52 2848.63   2945.83 69604840000 2983.000 2829.000
 5 2019  2952.33  2954.13 2750.52   2752.06 76860120000 3010.000 2854.000
 6 2019  2751.53  2910.61 2728.81   2886.98 33703630000 3037.000 2879.000

2019年6月3日月曜日

EPS 2019JUN03


Download XLS from here.

> eps_year_xts["2019::"]
             [,1]
2019-01-01 134.74
2019-04-01 137.38
2019-07-01 140.00
2019-10-01 151.44
2020-01-01 154.73
2020-04-01 159.04
2020-07-01 163.53
2020-10-01 167.98

> eps_year_xts["2019-01-01"] <- 134.48
> eps_year_xts["2019-04-01"] <- 137.14
> eps_year_xts["2019-07-01"] <- 139.58
> eps_year_xts["2019-10-01"] <- 150.77
> eps_year_xts["2020-01-01"] <- 153.98
> eps_year_xts["2020-04-01"] <- 158.28
> eps_year_xts["2020-07-01"] <- 162.93
> eps_year_xts["2020-10-01"] <- 167.58

>  eps_year_xts["2019::"]
             [,1]
2019-01-01 134.48
2019-04-01 137.14
2019-07-01 139.58
2019-10-01 150.77
2020-01-01 153.98
2020-04-01 158.28
2020-07-01 162.93
2020-10-01 167.58

eps_year_xts["2019-01-01"] <- 134.48
eps_year_xts["2019-04-01"] <- 137.14
eps_year_xts["2019-07-01"] <- 139.58
eps_year_xts["2019-10-01"] <- 150.77
eps_year_xts["2020-01-01"] <- 153.98
eps_year_xts["2020-04-01"] <- 158.28
eps_year_xts["2020-07-01"] <- 162.93
eps_year_xts["2020-10-01"] <- 167.58


histogram performance comparison between cli 1 month delta positive and negative.







when "func()" is "cli_delta_vs_period_return_rate.r"

> hist(as.vector(func("minus","1970-01-01")[,1])-1,col=rgb(0.5,1,0),breaks=20,xlim=c(-0.6,0.5),ylim=c(0,7))
0111 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
[1] 11.34615
[1] 0.9858096
> par(new=T)
> hist(as.vector(func("plus","1970-01-01")[,1])-1,col=rgb(0.5,0,1,alpha=0.4),breaks=10,xlim=c(-0.6,0.5),ylim=c(0,7))

source code is as below.

#
# 1)pick up months whose clie_xts$oecd  is up from the previous
# 2)create the stream of flags, in which up is 1 and down is 0
# 3)compare SPX close price between the end month of cli_xts delta is plus(or minus) and its start.
# 4)return xts objects which contains. start month of period, updown ration, length of months and monthly average return during period.

func <- function(pm="plus",s="1970-01-01",l=1){
  w <- c()
  cat("0")
  cat(length(s))
  if(nchar(s) == 10){ # use nchar() to measure strings length, not length()
    cat("1")
    last_date <- last(index(cli_xts$oecd))
    start_date <- s
    period <- paste(start_date,last_date,sep='::')
  }else{
     # last_date <- l
     period <- s
  }
  # last_date <- last(index(cli_xts$oecd))
  # start_date <- s
  # period <- paste(start_date,last_date,sep='::')
  start_index <- 1
  iteration <- 0
  performance_val <- c()
  period_length <- c()
  lag_month <- l
  result <- c()
  rate <- c()
  plus_or_minus <- pm
  open_p <- c()
  close_p <- c()

# put flag on the months accoring to the parameter. for "minus" cli delta is less than ZERO, for plus the opposite.
  for(i in seq(1,length(diff(cli_xts$oecd,lag=lag_month)[period]),1,)){
    if(plus_or_minus == "minus"){
      if(as.vector(diff(cli_xts$oecd,lag=lag_month)[period])[i] < 0){  # up is "> 0"
        w <- append(w,1)
      }else{
        w <- append(w,0)
      }
    }else if(plus_or_minus == "plus"){
      if(as.vector(diff(cli_xts$oecd,lag=lag_month)[period])[i] > 0){  # up is "> 0"
        w <- append(w,1)
      }else{
        w <- append(w,0)
      }
    }else{
      stop("please use plus or minus as 1st parameter")
    }
  }
  month_flag <- 0 # status flag
# check stream and when flag is changes 0 to 1. it is the start of period.
  for(i in seq(1,length(diff(cli_xts$oecd,lag=lag_month)[period]),1,)){
    if(w[i] == 1){
      if(month_flag == 0){ # when w is 1 and month_flag is 0, the period starts
        month_flag <- 1
        start_price <- as.vector(to.monthly(SP5[period])[,1][i]) #dc 0531
        # print(index(to.monthly(SP5[period])[,4][i]))
        # cat("from ")
        # cat(as.character(as.Date(index(to.monthly(SP5[period])[,4][i]))))
        start_index <- i
      }
      # dc 0602 add output at the end of loop
      if(i == length(diff(cli_xts$oecd,lag=lag_month)[period])){
        # print("end of the loop")
        result <- append(result,as.xts(as.vector(to.monthly(SP5[period])[,4][i]) / start_price,index(to.monthly(SP5[period])[,4][i])))
                period_length <- append(period_length,i-start_index)
        performance_val <- append(performance_val,as.vector(to.monthly(SP5[period])[,4][i-1]) / start_price)
        open_p <- append(open_p,start_price)
        close_p <- append(close_p,as.vector(to.monthly(SP5[period])[,4][i-1]))
        rate <- append(rate,last(performance_val)**(1/last(period_length))-1)
      }
# check stream and when flag is changes 1 to 0. it is the start of period.
    }else if(w[i] ==0){
      if(month_flag == 1){ # when w is 0 and month_flag is 1, the period ends
        # cat(" ")
        # cat(i - start_index)
        # cat(" month(s)")
        # cat("\n")
        iteration <- iteration +1
        cat(iteration)
        cat(" ")
        result <- append(result,as.xts(as.vector(to.monthly(SP5[period])[,4][i-1]) / start_price,index(to.monthly(SP5[period])[,4][i-1])))
        # print(as.xts(as.vector(to.monthly(SP5[period])[,4][i]) / start_price,index(to.monthly(SP5[period])[,4][i])))
        # print(i - start_index)
        month_flag <- 0 # when period ends, intialize the flag.
        period_length <- append(period_length,i-start_index)
        performance_val <- append(performance_val,as.vector(to.monthly(SP5[period])[,4][i-1]) / start_price)
        open_p <- append(open_p,start_price)
        close_p <- append(close_p,as.vector(to.monthly(SP5[period])[,4][i-1]))
        rate <- append(rate,last(performance_val)**(1/last(period_length))-1)
      }
    }
  }
  cat("\n")
  print(mean(period_length))
  print(mean(performance_val))
  return(merge(result,period_length,rate,open_p,close_p))

}
# t_minus <- performance_val
# t_plus <- performance_val
func("minus","1970-01-01")




2019年6月2日日曜日

S&P 500 performance comparison between CLI 1 month delta is positive and negative.




The period when OECD Composite Leading Inditacor 1 month delta is positive and negative come one after another. Here to calculate S&P 500 return during those each period.

The parameter "minus" indicates this is period when CLI delta is negative. The result is they came 25 times since 1970/1/1. The average length is approx. 11.35 month and the average return is -1.41%.

On the other hand, positive have come 25 times. The average length is 11.8 month and the average return is 19.85%.

> func("minus","1970-01-01")
0111 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
[1] 11.34615
[1] 0.9858096
            result period_length          rate  open_p close_p
Sep 1970 0.9157072             9 -0.0097365802   92.06   84.30
Jan 1975 0.6634491            24 -0.0169506551  116.03   76.98
Jul 1977 0.9867239            14 -0.0009541901  100.18   98.85
Jun 1980 1.2136407            20  0.0097282501   94.13  114.24
Aug 1982 0.8803035            20 -0.0063541523  135.76  119.51
Nov 1984 1.0010403            10  0.0001039829  163.41  163.58
Jul 1986 1.3032344            17  0.0157013530  181.18  236.12
Mar 1988 0.7849672             7 -0.0339963144  329.81  258.89
Oct 1989 1.2255509            10  0.0205472899  277.72  340.36
Jan 1991 1.0362770            11  0.0032447523  331.89  343.93
Dec 1991 1.0547758             4  0.0134213316  395.43  417.09
Nov 1992 1.0395228             7  0.0055527568  414.95  431.35
Jun 1995 1.1773542             9  0.0183066251  462.69  544.75
Jan 1996 1.0937576             3  0.0303236982  581.50  636.02
Oct 1998 1.1598155            13  0.0114699680  947.28 1098.67
Sep 2001 0.6946176            18 -0.0200405678 1498.58 1040.94
Mar 2003 0.7875979            11 -0.0214722593 1076.92  848.18
May 2005 1.0579732            14  0.0040334726 1126.21 1191.50
Jun 2006 1.0001180             1  0.0001180284 1270.05 1270.20
Feb 2009 0.4885423            20 -0.0351826442 1504.66  735.09
Jun 2010 0.9479536             1 -0.0520464319 1087.30 1030.71
Nov 2011 0.9385236             9 -0.0070249109 1328.64 1246.96
Sep 2012 1.0547405             7  0.0076425915 1365.90 1440.67
Aug 2014 1.0690570             5  0.0134449700 1873.96 2003.37
Apr 2016 1.0031085            16  0.0001940004 2058.90 2065.30
Mar 2019 1.0599561            15  0.0034295890 2645.10 2784.49



> func("plus","1970-01-01")
0111 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
[1] 11.8
[1] 1.198459
            result period_length         rate  open_p close_p
Jan 1973 1.3763938            28  0.011474868   84.30  116.03
May 1976 1.3013769            16  0.016600207   76.98  100.18
Oct 1978 0.9423369            15 -0.003951666   98.85   93.15
Dec 1980 1.1883753             6  0.029182211  114.24  135.76
Jan 1984 1.3672189            17  0.018569047  119.52  163.41
Feb 1985 1.1075926             3  0.034649717  163.58  181.18
Aug 1987 1.3967474            13  0.026036742  236.12  329.80
Dec 1988 1.0727335             9  0.007831630  258.89  277.72
Feb 1990 0.9751147             4 -0.006280247  340.36  331.89
Aug 1991 1.1498066             7  0.020142134  343.91  395.43
Apr 1992 0.9950124             4 -0.001249244  417.03  414.95
Sep 1994 1.0727019            22  0.003195123  431.35  462.71
Oct 1995 1.0674621             4  0.016454915  544.75  581.50
Sep 1997 1.4893871            20  0.020117927  636.02  947.28
Mar 2000 1.3639946            17  0.018427587 1098.67 1498.58
Apr 2002 1.0345650             7  0.004866239 1040.94 1076.92
Mar 2004 1.3277960            12  0.023908021  848.18 1126.21
May 2006 1.0659588            12  0.005337085 1191.50 1270.09
Jun 2007 1.1836842            12  0.014151848 1270.06 1503.35
May 2010 1.4932221            15  0.027089509  729.57 1089.41
Feb 2011 1.2871884             8  0.032060761 1031.10 1327.22
Feb 2012 1.0952515             3  0.030792577 1246.91 1365.68
Mar 2014 1.2994239            18  0.014657552 1440.90 1872.34
Dec 2014 1.0273593             4  0.006770750 2004.07 2058.90
Nov 2017 1.2807753            19  0.013109691 2067.17 2647.58

their results are tested by "t.test()". p-value is 7.391e-05. Therefore they should be distiguised each other with the probability of 99.99261%

> t.test(func("plus","1970-01-01")[,1],func("minus","1970-01-01")[,1])
<skip>
Welch Two Sample t-test

data:  func("plus", "1970-01-01")[, 1] and func("minus", "1970-01-01")[, 1]
t = 4.3306, df = 48.714, p-value = 7.391e-05
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 0.1138069 0.3109339
sample estimates:
mean of x mean of y
1.1984592 0.9860888

There is a histogram in the next entry for the better comparison.

see source code github. commit id is d20207a