2019年4月24日水曜日

How to draw horizontal and vertical lines on candlechart.



How to draw horizontal and vertical lines on candlechart.

# candleChart(to.weekly(fas_shares * FAS[,4] +spxl_shares * SPXL[,4]),theme='white')
#
# draw candle chart.
#
candleChart(to.weekly(fas_shares * FAS[,4] +spxl_shares * SPXL[,4]+as.xts(fas_c2+fas_c3+fas_c4+spxl_c1+spxl_c2,index(fas_shares))),theme='white')
# t <- as.xts(rep(2150000,length(weekly_pf[,1])),index(weekly_pf))
# addTA(t,on=1,legend="",lty=2,order=10)
open_v <- as.vector(weekly_pf[1,1])
close_v <- as.vector(weekly_pf[length(weekly_pf[,1]),4])
ratio <- (close_v/open_v)**(1/length(weekly_pf[,1]))
t <- as.xts(open_v*ratio**(1:length(weekly_pf[,1])),index(weekly_pf))
addTA(t,on=1,legend="",lty=2,order=10)
plot(addLines(v=seq(1,length(index(weekly_pf)),26)))
plot(addLines(h=2100000))


2019年4月23日火曜日

EPS 2019APR23



eps_year_xts["2018::"][12] <- 168.4
 eps_year_xts["2018::"][11] 
#20#20-07-01 168.59
 eps_year_xts["2018::"][11]  <- 163.95
 eps_year_xts["2018::"][10]
#20#20-04-01 163.88
 eps_year_xts["2018::"][10]  <- 159.43
 eps_year_xts["2018::"][9]   <- 154.77
 eps_year_xts["2018::"][8]   <- 149.61
 eps_year_xts["2018::"][7]
#2019-07-01 140.95
 eps_year_xts["2018::"][7]   <- 137.93
 eps_year_xts["2018::"][6]   <- 135.11
 eps_year_xts["2018::"][5]   <- 132.47

2019年4月3日水曜日

how to use git

1. start


1.1 install

install homebrew before running any brew related commands.

$ brew cask install github

1.2 create repositry


create repositry at www.github. this process may includes 1) create accout. 2) make repositry with unique name. once they are completed each repositry should have URL like "https://github.com/<account_name>/<repositry_name>.git

2. clone


run clone command at the directory you have permission.

   $ git clone https://github.com/onomoto/misc.git

this command will create the directory below your current directory with the name of repositry, in this case, "misc".

3. add file into the repositry

you can do it either on the remote host or at your local machine.

3.1 remote host


upload interface is available at github.com. go to your repositry page and upload accordingly.

3.2 add and commit


$ git add <file_name>
$ git commit <file_name> -m '<update message>'

4. sync


when the remote host is updated by others or at the other local machine.

$ git pull

will download all update/added file to the local machine.

5.cancel update

5.1 checkout


$ git checkout .

revert all added but not commited updates in the current working directory.

5.2 rest


$git reset   # not tested yet

revert all commited but unpushed updates.


5.3 revert


$ git revert # not tested yet
$ git push # not tested yet

6. diff

6.1 before 'git add'


$  git diff


6.2 after 'git add'


$ git diff --cached

6.3 after 'git commit'


$ git diff HEAD^

6.4 compare remote and local


$ git fetch origin
$ git diff HEAD..origin/master
$ git diff --name-only  HEAD^ # just list file names

7 remote

7.1 confirm remote repositry name and location

$ git remote -v

origin https://github.com/<user_name>/<repositry_name> (fetch)

origin https://github.com/<user_name>/<repositry_name> (push)


7.2 check updates on the remote before 'git pull'


$ git fetch origin
$ git diff origin/master

7.3 check and change remote branch



$git branch
* dev
  master
$git remote 
origin
$git remote -v
origin https://github.com/onomoto/R (fetch)
origin https://github.com/onomoto/R (push)
$git branch --set-upstream-to=origin/0529 dev
Branch 'dev' set up to track remote branch '0529' from 'origin'.
$git branch -vv
* dev    5beb8ef [origin/0529] dc : automatically calculate the end date.
  master 4b65abf [origin/0529: behind 2] dc : remove() unnecessary object

8 log

$ git log

$ git log | grep -E '^comm|^Date'

commit 44ec2ea5afa194e15ec3b1c0fa75abefa9e5e880
Date:   Mon Apr 8 11:18:36 2019 +0900
commit 154631ebb482ba80972d91381dae5993c87ae426
Date:   Mon Apr 8 11:15:12 2019 +0900
commit 817671f045b45df8b33c411e94ddcfa2c9f01068
Date:   Mon Apr 8 10:50:05 2019 +0900
commit e53947c777256b442ba7f2989a126e303d98e4db
Date:   Mon Apr 8 10:11:22 2019 +0900

$git diff 44ec2ea5a..e53947c777 | grep diff
diff --git a/index/CSV/gitconfig.txt b/index/CSV/gitconfig.txt
diff --git a/index/CSV/test.txt b/index/CSV/test.txt
diff --git a/index/getsymbols_all.r b/index/getsymbols_all.r
diff --git a/index/nikkei_gspc_jpy.r b/index/nikkei_gspc_jpy.r


 $ git log --since=2019-04-10 --date=short  #日付指定で
 $ git log --since=2019-04-01 --until=2019-04-08 --date=short
 $ git log --since=2019-04-01T20:29:21+09:00 --until=2019-04-03T20:29:21+09:00   --date=iso


 $ git log -10  #件数指定

9 branch


$git branch
* master

10 Config

10.1 global


  $ git config --global user.email onomoto@me.com
  $ git config --global user.name "onomoto"


10.2 .gitigonore



.Rproj.user
.Rhistory
.RData
.Ruserdata
.DS_Store
.gitignore.swp
.gitignore
*.swp