-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_func.r
63 lines (46 loc) · 1.48 KB
/
test_func.r
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
test <- function() {
bw_tick <- streamData
bwnum <<- as.character(bw_tick$winNum[1]) # note this changes global var bwnum
tick_out <- paste(DATADIR,"/",index,"_ticks_bw_",bwnum,".csv",sep="")
write.csv(bw_tick, tick_out)
retList <- list()
retList$rnorm <- rnorm(10)
retList$bw <- bw
retList$sw <- sw
retList$streamData <- streamData
retList$bwnum <- bwnum
retList
}
# update each stream's digest for each new basic window
# Note: here the stream data are column based, i.e. AA, IBM, ...etc.
UpdateDigest <- function(chopChunk, bw_tick, bw_num)
{
for(j in 1:length(sym_list)) {
bwdat <- bw_tick[,j+2]
rw <- as.numeric(bwdat)
if (bw_num == 1) {
chopChunk[[j]] <- rw
}
else if (bw_num <= (sw/bw)) {
chopChunk[[j]] <- c(chopChunk[[j]], rw) # append to existing basicwin
}
else {
# override the oldest bw : do a shift update: should use a shift function
chopChunk[[j]] <- c(chopChunk[[j]][(bw+1):sw], rw)
}
} # end of n_stream
chopChunk
}
process_bw_ticks <- function(newdat, bwnum)
{
tick_data <- newdat
colnames(tick_data) <- c("timeStamp", "bwNum", sym_list)
cat("\n++++++++++++NEW BASIC WINDOW BEGIN+++++++++++++++++++++++++++++++\n")
cat("bwnum: ", bwnum, "\n");
tick_out <- paste(REPORTDIR,"/",index,"_ticks_bw_",bwnum,".csv",sep="")
cat("writing bw tick data to ", tick_out, " \n")
write.csv(tick_data, tick_out)
cat("\n++++++++++++NEW BASIC WINDOW END+++++++++++++++++++++++++++++++++\n")
# return
tick_data
}