forked from KaroRonty/FinancialDeepLearning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALE_plots.R
100 lines (94 loc) · 4.42 KB
/
ALE_plots.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
library(signs)
library(tidyverse)
results <- list.files("Results", pattern = ".RDS") %>%
map(~readRDS(paste0("Results/", .x)) %>%
mutate(coin = .x)) %>%
reduce(full_join)
results_clean <- results %>%
mutate(crypto = case_when(str_detect(coin, "binance") ~ "Binance Coin",
str_detect(coin, "bitcoin") ~ "Bitcoin",
str_detect(coin, "eth") ~ "Ether",
str_detect(coin, "xrp") ~ "XRP",
str_detect(coin, "iota") ~ "IOTA")) %>%
mutate(model = case_when(str_detect(coin, "gru") ~ "GRU",
TRUE ~ "LSTM"))
results_clean %>%
filter(!(feature %in% c("sentiment_past", "volatility_10_day")),
model == "LSTM") %>%
ggplot(aes(x.values, f.values, color = crypto)) +
geom_line(size = 1) +
facet_wrap(~feature) +
scale_x_continuous(labels = signs_format(1, suffix = "%",
add_plusses = TRUE,
format = scales::percent)) +
scale_y_continuous(labels = signs_format(1, suffix = "%",
add_plusses = TRUE,
format = scales::percent)) +
labs(title = "Effect of price-related features to future 10-day average volatility",
subtitle = "LSTM model only",
x = "Percentual change in feature",
y = "Percentual change in future 10-day average volatility",
color = "Coin") +
theme_minimal() +
theme(legend.position = "bottom",
plot.title = element_text(margin = margin(10, 0, 15, 0)))
results_clean %>%
filter(!(feature %in% c("sentiment_past", "volatility_10_day")),
model == "GRU") %>%
ggplot(aes(x.values, f.values, color = crypto)) +
geom_line(size = 1) +
facet_wrap(~feature) +
scale_x_continuous(labels = signs_format(1, suffix = "%",
add_plusses = TRUE,
format = scales::percent)) +
scale_y_continuous(labels = signs_format(1, suffix = "%",
add_plusses = TRUE,
format = scales::percent)) +
labs(title = "Effect of price-related features to future 10-day average volatility",
subtitle = "GRU model only",
x = "Percentual change in feature",
y = "Percentual change in future 10-day average volatility",
color = "Coin") +
theme_minimal() +
theme(legend.position = "bottom",
plot.title = element_text(margin = margin(10, 0, 15, 0)))
results_clean %>%
filter(feature == "sentiment_past",
model == "LSTM") %>%
ggplot(aes(x.values, f.values, color = crypto)) +
geom_line(size = 1) +
geom_vline(xintercept = 0) +
scale_x_continuous(labels = signs_format(0.001,
add_plusses = TRUE,
format = scales::number)) +
scale_y_continuous(labels = signs_format(1, suffix = "%",
add_plusses = TRUE,
format = scales::percent)) +
labs(title = "Effect of 30-day sentiment to future 10-day average volatility",
subtitle = "LSTM model only",
x = "Sentiment score",
y = "Percentual change in future 10-day average volatility",
color = "Coin") +
theme_minimal() +
theme(legend.position = "bottom",
plot.title = element_text(margin = margin(10, 0, 15, 0)))
results_clean %>%
filter(feature == "sentiment_past",
model == "GRU") %>%
ggplot(aes(x.values, f.values, color = crypto)) +
geom_line(size = 1) +
geom_vline(xintercept = 0) +
scale_x_continuous(labels = signs_format(0.001,
add_plusses = TRUE,
format = scales::number)) +
scale_y_continuous(labels = signs_format(1, suffix = "%",
add_plusses = TRUE,
format = scales::percent)) +
labs(title = "Effect of 30-day sentiment to future 10-day average volatility",
subtitle = "GRU model only",
x = "Sentiment score",
y = "Percentual change in future 10-day average volatility",
color = "Coin") +
theme_minimal() +
theme(legend.position = "bottom",
plot.title = element_text(margin = margin(10, 0, 15, 0)))