-
Notifications
You must be signed in to change notification settings - Fork 20
/
prepareDataExploration.R
103 lines (92 loc) · 2.22 KB
/
prepareDataExploration.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Title : Prepare daily aspects for exploratory analysis.
# Created by: pablocc
# Created on: 30/09/2020
library(boot)
library(caret)
library(psych)
source("./analysis.r")
source("./indicatorPlots.r")
symbol <- "BTC-USD"
orbLimit <- 0
pxSelect <- c(
'MO',
'ME',
'VE',
'SU',
'MA',
'JU',
'SA'
)
pySelect <- c(
'ME',
'VE',
'SU',
'MA',
'JU',
'SA',
#'NN',
'UR',
'NE',
'PL'
)
aspectSelect <- c(
0,
30,
45,
60,
90,
120,
135,
150,
180
)
idCols <- c('Date', 'Hour')
setClassicAspectsSet8()
setPlanetsMOMEVESUMAJUNNSAURNEPL()
hourlyPlanets <- openHourlyPlanets('planets_11', clear = F)
#dailyAspectsRows <- dailyHourlyAspectsTablePrepare(hourlyPlanets, idCols, orbLimit)
dailyPlanets <- hourlyPlanets[Hour == 12,]
# dailyAspects <- dailyCombPlanetAspectsFactorsTable(
# dailyAspects = dailyAspectsRows,
# pxSelect = pxSelect,
# pySelect = pySelect,
# aspectSelect = aspectSelect,
# orbLimit = orbLimit
# )
splitDigits <- function (number) {
as.numeric(strsplit(as.character(number), "")[[1]])
}
vortexNumber <- function(number) {
baseNumber <- as.character(number)
while(str_count(baseNumber) > 1) {
baseNumber <- sum(splitDigits(baseNumber))
}
return(round(baseNumber, 0))
}
securityData <- mainOpenSecurity(
symbol, 2, 4, "%Y-%m-%d", "2010-01-01"
)
colNames <- colnames(dailyPlanets)
harColNames <- colNames[grep(".*H[0-9]+$", colNames)]
selAstroCols <- names
securityData[, prevMid := data.table::shift(Mid, 1)]
#securityData[, datePlain := format(Date, "%Y%m%d")]
#securityData[, dateNum := vortexNumber(datePlain), by=Date]
#securityData[, dateNum := paste0('n', dateNum)]
securityData[, priceDiff := Mid - prevMid]
securityData[, PriceAction := cut(priceDiff, c(-10000, 0, 10000), labels = c('bearish', 'bullish'))]
securityData <- securityData[!is.na(priceDiff),]
selAstroCols <- c('Date', harColNames)
selSecurityCols <- c('Date', 'Mid')
aspectView <- merge(
securityData[, ..selSecurityCols],
dailyPlanets[, ..selAstroCols]
)
varCorrelations <- aspectView[, -c(1)] %>%
cor() %>%
round(digits = 2)
finalCorrelations <- sort(varCorrelations[, 1])
# fwrite(
# aspectView,
# paste("./predictions/", symbol, "-planets-comb-aspects-factors-ma3-6-2orb.csv", sep = "")
# )