-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmin_pattern
More file actions
71 lines (61 loc) · 3.81 KB
/
Copy pathmin_pattern
File metadata and controls
71 lines (61 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
http://www.morganstanleyfa.com/public/projectfiles/cf8baa6e-b385-45aa-abd4-74ea5d34ade8.pdf
http://economistatlarge.com/portfolio-theory/r-optimized-portfolio
https://alphaism.wordpress.com/2012/05/04/finding-efficient-frontier-and-optimal-portfolio-in-r/
http://www.rinfinance.com/agenda/2012/workshop/DougMartin.pdf
https://systematicinvestor.wordpress.com/category/portfolio-construction/
http://www.rinfinance.com/agenda/2012/workshop/Carl+Peterson.pdf
http://www.r-bloggers.com/modeling-couch-potato-strategy/
http://www.r-bloggers.com/tag/portfolio-construction/
http://allthingsr.blogspot.in/2012/10/pull-yahoo-finance-key-statistics.html
http://cran.r-project.org/web/packages/DEoptim/vignettes/DEoptimPortfolioOptimization.pdf
http://economistatlarge.com/portfolio-theory/r-optimized-portfolio/r-code-graph-efficient-frontier
http://www.rinfinance.com/agenda/2012/workshop/Carl+Peterson.pdf
http://systematicinvestor.github.io/
https://systematicinvestor.wordpress.com/2014/08/
stock <- read.csv("C:/DataExport/CPST.txt",sep=",", header=TRUE)//importing minute data
tws <- twsConnect()
port<-twsPortfolioValue(reqAccountUpdates(tws))
write.csv(port,file="port.csv")# at working directory >this PC/Documents
list<-twsPortfolioValue(reqAccountUpdates(tws))[1]
//dataexport.afl
library(stockPortfolio)
library(quadprog)
stocks <- c( "SPY", "EFA", "IWM", "VWO", "LQD", "HYG")
afsi <- read.csv("C:/DataExport/AFSI.txt",header=T)
akrx <- read.csv("C:/DataExport/AKRX.txt",header=T)
#afsi <- read.csv("/home/octo/Desktop/DataExport/AFSI.txt",header=T)
#akrx <- read.csv("/home/octo/Desktop/DataExport/AKRX.txt",header=T)
# acco <- read.csv("/home/octo/Desktop/DataExport/ACCO.txt",header=T)
# acm <- read.csv("/home/octo/Desktop/DataExport/ACM.txt",header=T)
# advs <- read.csv("/home/octo/Desktop/DataExport/ADVS.txt",header=T)
# alg <- read.csv("/home/octo/Desktop/DataExport/ALG.txt",header=T)
# cno <- read.csv("/home/octo/Desktop/DataExport/CNO.txt",header=T)
# che <- read.csv("/home/octo/Desktop/DataExport/CHE.txt",header=T)
# wal <- read.csv("/home/octo/Desktop/DataExport/WAL.txt",header=T)
# data1<-read.table("/home/octo/Desktop/DataExport/AFSI.txt", sep=",", header=TRUE)
stocks<-cbind(afsi$Close[1:60000],akrx$Close[1:60000])
stocks<-cbind(afsi$Close[1:15000],akrx$Close[1:15000],acco$Close[1:15000],advs$Close[1:15000],alg$Close[1:15000],cno$Close[1:15000],che$Close[1:15000],wal$Close[1:15000])
colnames(stocks) <- c("afsi","akrx","acco","advs","alg","cno","che","wal")
stocks.df <- data.frame(stocks)
stocks$afsi<-afsi$Close[1:60000]
stocks$akrx<-akrx$Close[1:60000]
ret<-diff(log(stocks),lag=1)
dim(ret)
mu <- colMeans(ret)
sigma <- cov(ret)
library("PerformanceAnalytics")
****Pattern***
1. Clutter Volume
2. Range Bound
An inside day is one in which the broad market is currently trading inside of the prior day’s range. An outside day is the opposite where the market has managed to either make a new two day high or low and is trading outside of the prior day’s range. This matters a lot. Inside of the prior day’s range is usually a sign of a range bound market that is chopping around in fits and starts. This will generally frustrate the average daytrader because he/she will find excellent setups but they won’t seem to get moving. The trader will find that they will do better when the market has moved outside of the prior day’s range.
for(i in 2:length(stock$Open))
{
stock$liq[i]<-ifelse(quantile(stock$Volume[i-5:i])[4]<stock$Volume[i] & stock$Volume[i]/stock$Volume[i-1]>0,"L","IL")
#Clutter Vol
stock$rng[i]<-ifelse(stock$High[i-1]<stock$Open[i],"U",ifelse(stock$Open[i]<stock$Low[i-1],"D","R"))#R=range, U=upside and D=downside #Range
stock$lvl[i]<-ifelse(stock$Close[i-1]>stock$Open[i-1] & stock$Close[i]>stock$Close[i-1],"UP","DN")
}
afsi <- read.csv("C:/Users/PARTHA/Desktop/AAN.txt",header=T)
tail(afsi)
head(afsi)
summary(afsi)