-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperfCalcs.R
More file actions
58 lines (43 loc) · 1.93 KB
/
Copy pathperfCalcs.R
File metadata and controls
58 lines (43 loc) · 1.93 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
#########################################################
## Compute performance from technicalsLoop.R output
## [in stockTechnicals folder]
perfSource = "/Users/ehren/Documents/StockAnalysis/stockTechnicals/"
destinationPath = "/Users/ehren/Documents/StockAnalysis/dailySummaries/"
perfFiles = list.files(path=perfSource,pattern=".csv")
fileDate <- Sys.Date()
fileCount = 0
dailyData <- read.zoo(paste(perfSource,"A.csv",sep=""), header = TRUE, sep = ",")
dailyData <- data.frame(dailyData[end(dailyData),])
dailyData <- data.frame(Symbols=NA,coredata(dailyData))
for (ii in perfFiles){
data <- read.zoo(paste(perfSource,ii,sep=""), header = TRUE, sep = ",")
data <- data[end(data),]
data <- data.frame(Date=index(data),coredata(data))
## ticker string
Symbol <- substr(ii,1,nchar(ii)-4)
data <- data.frame(Symbols=NA,coredata(data))
#start() and end() for xts indexes
data$Symbols[1] <- Symbol
names(data)[names(data) == 'Delt.1.arithmetic'] <- 'Delta-1'
names(data)[names(data) == 'Delt.5.arithmetic'] <- 'Delta-5'
names(data)[names(data) == 'atr'] <- 'ATR'
# newrow = as.data.frame(data[Sys.Date(),])
# newrow$ticker <- NA
# newrow$ticker[fileDate,] <- ticker
dailyData <- rbind(dailyData,data)
## Get the column with the max value for RSI
# RSIList <- data[max(data$RSI, na.rm=TRUE),]
##########################################
# get max of column max(data$RSI, na.rm=TRUE)
# And to sort:
#
# ozone[order(ozone$Solar.R),]
print(ii," completed.")
}
## Get data sorted for top ten biggest movers of the day...
dailyData[order(dailyData$Delt.1.arithmetic),]
topDecreases <- dailyData[(nrow(dailyData)-10:nrow(dailyData)),]
topIncreases <- dailyData[1:10,]
dailyDelt_1 <- rbind(topIncreases,topDecreases)
## Write the Daily Delts (1-day) to a .csv file at destintionPath location
write.table(dailyDelt_1, file=paste(destinationPath, fileDate,"_DailyDelt_1.csv",sep=""), na="", sep=",", row.names = FALSE)