Theme Song
FRA : Elle me dit
CHN : 她对我说
ENG : She told me
JPN : 彼女は私に言う
GRE : Μου λέει
SPN : Ella me dijo
GER : Sie sagte mir
ITA : Lei mi dice
KRO : 그녀는 나에게 말한다
FRA : écris une chanson contente
CHN : 写一首欢快的歌
ENG : Write a happy song
JPN : 幸せな歌を書く
GRE : Γράψτε ένα χαρούμενο τραγούδι
SPN : Escribe una canción alegre
GER : Schreibe ein fröhliches Lied
ITA : Scrivi una canzone allegra
KRO : 쾌활한 노래 쓰기
FRA : Pas une chanson déprimante
CHN : 而不是悲伤的歌
ENG : Not a depressing song
JPN : 気のめいるような歌ではない
GRE : Όχι θλιβερό τραγούδι
SPN : No es una canción triste
GER : Kein trauriges Lied
ITA : Canzone non triste
KRO : 슬픈 노래가 아님
FRA : Une chanson que tout le monde aime
CHN : 一首让所有人都喜欢的歌
ENG : A song that everyone loves
JPN : みんなが大好きな曲
GRE : Ένα τραγούδι που αρέσει σε όλους
SPN : Una cancion que a todos les gusta
GER : Ein Lied, das jeder mag
ITA : Una canzone che piace a tutti
KRO : 모두가 좋아하는 노래
FRA : Elle me dit
CHN : 她对我说
ENG : She told me
JPN : 彼女は私に言う
GRE : Μου λέει
SPN : Ella me dijo
GER : Sie sagte mir
ITA : Lei mi dice
KRO : 그녀는 나에게 말한다
FRA : Tu deviendras milliardaire
CHN : 你将成为亿万富翁
ENG : You will become a millionaire
JPN : あなたは億万長者になります
GRE : Θα γίνετε δισεκατομμυριούχος
SPN : Te convertirás en multimillonario
GER : Sie werden Milliardär
ITA : Diventerai un miliardario
KRO : 당신은 억만 장자가 될 것입니다
FRA : Tu auras de quoi être fier
CHN : 你将为此感到骄傲
ENG : You will be proud
JPN : あなたは誇りに思うでしょう
GRE : Θα είσαι περήφανος για αυτό
SPN : Estarás orgulloso de ello
GER : Sie werden stolz darauf sein
ITA : Ne sarai orgoglioso/span>
KRO : 당신은 그것을 자랑스러워 할 것입니다
Due to below issues from Deriv.com - Interday High Frequency Trading Models Comparison Blooper, here I review the research by using same dataset as we can know from below Part I.
Here I use the βest model (ETS MNZ & MNZ) from above study but adjust the data size as we can know from next section.
The purpose of adjust the data size to be intraday :
Load Packages
if(!suppressPackageStartupMessages(require('BBmisc'))) {
install.packages('BBmisc', dependencies = TRUE, INSTALL_opts = '--no-lock')
}
suppressPackageStartupMessages(require('BBmisc'))
# suppressPackageStartupMessages(require('rmsfuns'))
pkgs <- c('devtools', 'knitr', 'kableExtra', 'tint', 'furrr', 'tidyr',
'devtools','readr', 'lubridate', 'data.table', 'reprex',
'feather', 'purrr', 'quantmod', 'tidyquant', 'tibbletime',
'timetk', 'plyr', 'dplyr', 'stringr', 'magrittr', 'tdplyr',
'tidyverse', 'memoise', 'htmltools', 'formattable', 'dtplyr',
'zoo', 'forecast', 'seasonal', 'seasonalview', 'rjson',
'rugarch', 'rmgarch', 'mfGARCH', 'sparklyr', 'jcolors',
'microbenchmark', 'dendextend', 'lhmetools', 'ggthemr',
'stringr', 'pacman', 'profmem', 'ggthemes', 'flyingfox',
'htmltools', 'echarts4r', 'viridis', 'hrbrthemes', 'gtools',
'fable', 'fabletools', 'Rfast', 'Metrics', 'MLmetrics')
suppressAll(lib(pkgs))
# load_pkg(pkgs)
.dtr <- 'C:/Users/User/Documents/GitHub/binary.com-interview-question-data/'
## Set the timezone but not change the datetime
Sys.setenv(TZ = 'Asia/Tokyo')
## options(knitr.table.format = 'html') will set all kableExtra tables to be 'html', otherwise need to set the parameter on every single table.
options(warn = -1, knitr.table.format = 'html')#, digits.secs = 6)
## https://stackoverflow.com/questions/39417003/long-vectors-not-supported-yet-abnor-in-rmd-but-not-in-r-script
knitr::opts_chunk$set(warning = FALSE, #cache = TRUE,
message = FALSE, cache.lazy = FALSE)
rm(pkgs)
## check if data path set
if(!exists('dtr')) {
dtr <- 'C:/Users/User/Documents/GitHub/binary.com-interview-question-data/'}
## save files if not exists
if(!file.exists(paste0(dtr, 'data/fx/USDJPY/dsmp.rds')) & exists('dsmp')) {
saveRDS(dsmp, paste0(dtr, 'data/fx/USDJPY/dsmp.rds'))}
## read files if not exists
if(!exists('dsmp')) {
dsmp <- readRDS(paste0(dtr, 'data/fx/USDJPY/dsmp.rds'))}
## plot sample data
dsmp[c(1:3, (nrow(dsmp)-3):nrow(dsmp)),] %>%
kbl(caption = '1 min Close Price Dataset', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
## https://public.tableau.com/en-us/gallery/100-color-palettes?gallery=votd
row_spec(0, background = 'DimGrey', color = 'gold', bold = TRUE) %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = 'Gray') %>%
column_spec(3, background = 'DarkGrey') %>%
column_spec(4, background = 'Gray') %>%
column_spec(5, background = 'DarkGrey') %>%
column_spec(6, background = '#4897D8') %>%
column_spec(7, background = '#556DAC') %>%
column_spec(8, background = '#92AAC7') %>%
column_spec(9, background = '#556DAC') %>%
column_spec(10, background = '#375E97') %>%
column_spec(11, background = 'CornflowerBlue') %>%
column_spec(12, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>% ##`full_width = FALSE` will auto adjust every single columns width to fit the table full width.
scroll_box(width = '100%', fixed_thead = TRUE, height = '400px')
| index | year | quarter | month | week | wkdays | wk_1m | dy_1m | hr_1m | sq | date | close |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 2015-01-05 00:01:00 | 2015 | 1 | 1 | 1 | Monday | 1 | 1 | 1 | 1 | 2015-01-05 | 120.5740 |
| 2015-01-05 00:02:00 | 2015 | 1 | 1 | 1 | Monday | 2 | 2 | 2 | 2 | 2015-01-05 | 120.5900 |
| 2015-01-05 00:03:00 | 2015 | 1 | 1 | 1 | Monday | 3 | 3 | 3 | 3 | 2015-01-05 | 120.6035 |
| 2018-07-06 23:57:00 | 2018 | 3 | 7 | 27 | Friday | 7197 | 1437 | 57 | 1324797 | 2018-07-06 | 110.4635 |
| 2018-07-06 23:58:00 | 2018 | 3 | 7 | 27 | Friday | 7198 | 1438 | 58 | 1324798 | 2018-07-06 | 110.4740 |
| 2018-07-06 23:59:00 | 2018 | 3 | 7 | 27 | Friday | 7199 | 1439 | 59 | 1324799 | 2018-07-06 | 110.4740 |
| 2018-07-07 00:00:00 | 2018 | 3 | 7 | 27 | Saturday | 7200 | 1440 | 60 | 1324800 | 2018-07-07 | 110.4740 |
source : 1324800 x 12
From above table, we can know the dataset gather from 2015-01-05 to 2018-07-07 which is used in Deriv.com - Interday High Frequency Trading Models Comparison Review (Part I).
ETS ModellingHere I start my 1st forecast date from 1st trading datetime of 2016 (2016-01-04 which is 2nd year in dataset) which is used in Deriv.com - Interday High Frequency Trading Models Comparison Review (Part I).
The default data size 7200 to forecast 1440 as we can know that’s the optimal volume of observation data as we know from Deriv.com - Interday High Frequency Trading Models Comparison Review (Part I) to compare with below seasonality.
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 1440 minutes (1440 minutes is a trading day).
auto.arima() from forecast packageRefer to above function or load below r function.
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 1440 mins (24 hrs * 60 mins = 1440 mins is a trading day).
tseas <- function(timeID, data = dsmp, data_len,
hrz1 = c(1440, 7200), hrz2 = 1440, .model) {
if(hrz1 == 1440) {
tmp <- llply(1:length(timeID), function(i) {
if(i == 1) {
cat('\n===========================================\n')
cat('train[', i, ']\n')
print(train <- dsmp[date < timeID[i]][(.N - (data_len - 1)):.N])
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
cat('\n-------------------------------------------\n')
cat('train_test[', i, ']\n')
print(train_test <- dsmp[sq %in% ctr])
sets <- train[, .(index, close)] %>%
as_tibble %>%
tk_ts(frequency = hrz1) %>%
ets(model = .model) %>%
forecast(h = hrz1) %>%
tk_tbl %>%
dplyr::mutate(index = train_test[(.N - hrz1 + 1):.N,]$index,
mk.price = train_test[(.N - hrz1 + 1):.N,]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
cat('\n-------------------------------------------\n')
cat('forecast[', i, ']\n')
print(sets %>% as.data.table)
fl_pth <- paste0(.dtr, 'data/fx/USDJPY/ts_ets_', data_len,
'_', hrz1, '.', as_date(sets$index[1]), '.rds')
saveRDS(sets, fl_pth)
cat('\n', i, '=', paste0('~/data/fx/USDJPY/ts_ets_', .model, '_',
data_len, '_', hrz1, '.',
as_date(sets$index[1]), '.rds saved!'))
cat('\n\n')
rm(sets)
} else if(i %in% seq(1, length(timeID), by = 6)[-1]) {
} else if(i == length(timeID)) {
} else {
lst_sq <- dsmp[date < timeID[i],][.N]$sq + 1
cat('\n===========================================\n')
cat('train[', i, ']\n')
print(train <- dsmp[(lst_sq - data_len + 1):lst_sq])
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
cat('\n-------------------------------------------\n')
cat('train_test[', i, ']\n')
print(train_test <- dsmp[sq %in% ctr])
sets <- train[, .(index, close)] %>%
as_tibble %>%
tk_ts(frequency = hrz1) %>%
ets(model = .model) %>%
forecast(h = hrz1) %>%
tk_tbl %>%
dplyr::mutate(index = train_test[(.N - hrz1 + 1):.N,]$index,
mk.price = train_test[(.N - hrz1 + 1):.N,]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
cat('\n-------------------------------------------\n')
cat('forecast[', i, ']\n')
print(sets %>% as.data.table)
fl_pth <- paste0(.dtr, 'data/fx/USDJPY/ts_ets_', data_len,
'_', hrz1, '.', as_date(sets$index[1]), '.rds')
saveRDS(sets, fl_pth)
cat('\n', i, '=', paste0('~/data/fx/USDJPY/ts_ets_', .model, '_',
data_len, '_', hrz1, '.',
as_date(sets$index[1]), '.rds saved!'))
cat('\n\n')
rm(sets)
}
})
} else if(hrz1 == 7200) {
tmp <- llply(1:length(timeID), function(i) {
if(i == 1) {
cat('\n===========================================\n')
cat('train[', i, ']\n')
print(train <- dsmp[date < timeID[i]][(.N - (data_len - 1)):.N])
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
cat('\n-------------------------------------------\n')
cat('train_test[', i, ']\n')
print(train_test <- dsmp[sq %in% ctr])
sets <- train[, .(index, close)] %>%
as_tibble %>%
tk_ts(frequency = hrz1) %>%
ets(model = .model) %>%
forecast(h = hrz1) %>%
tk_tbl %>%
dplyr::mutate(index = train_test[(.N - hrz1 + 1):.N,]$index,
mk.price = train_test[(.N - hrz1 + 1):.N,]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
cat('\n-------------------------------------------\n')
cat('forecast[', i, ']\n')
print(sets %>% as.data.table)
fl_pth <- paste0(.dtr, 'data/fx/USDJPY/ts_ets_', data_len,
'_', hrz1, '.', as_date(sets$index[1]), '.rds')
saveRDS(sets, fl_pth)
cat('\n', i, '=', paste0('~/data/fx/USDJPY/ts_ets_', .model, '_',
data_len, '_', hrz1, '.',
as_date(sets$index[1]), '.rds saved!'))
cat('\n\n')
rm(sets)
} else if(i > (length(timeID) - hrz1/hrz2) & i != length(timeID)) {
lst_sq <- dsmp[date < timeID[i],][.N]$sq + 1
## filter the length of forecasted data to fit with train_test data
## when the length of forecasted data more then length of test data.
#lst_date <- timeID[(length(timeID) - (hrz1/hrz2)):length(timeID)]
lst_date <- timeID[timeID >= timeID[i]]
lst_date_sq <- grep(
timeID[i], timeID[
(length(timeID) - (hrz1/hrz2 - 1)):length(timeID)])
cat('\n===========================================\n')
cat('train[', i, ']\n')
print(train <- dsmp[(lst_sq - data_len + 1):lst_sq])
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
cat('\n-------------------------------------------\n')
cat('train_test[', i, ']\n')
print(train_test <- dsmp[sq %in% ctr])
sets <- train[, .(index, close)] %>%
as_tibble %>%
tk_ts(frequency = hrz1) %>%
ets(model = .model) %>%
forecast(h = hrz1) %>%
tk_tbl
sets <- sets[1:(hrz1 - (hrz2 * lst_date_sq)),] %>%
dplyr::mutate(index = train_test[
(.N - (hrz1 - (hrz2 * lst_date_sq)) + 1):.N, ]$index,
mk.price = train_test[
(.N - (hrz1 - (hrz2 * lst_date_sq)) + 1):.N, ]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
cat('\n-------------------------------------------\n')
cat('forecast[', i, ']\n')
print(sets %>% as.data.table)
fl_pth <- paste0(.dtr, 'data/fx/USDJPY/ts_ets_', data_len,
'_', hrz1, '.', as_date(sets$index[1]), '.rds')
saveRDS(sets, fl_pth)
cat('\n', i, '=', paste0('~/data/fx/USDJPY/ts_ets_', .model, '_',
data_len, '_', hrz1, '.',
as_date(sets$index[1]), '.rds saved!'))
cat('\n\n')
rm(sets)
} else if(i %in% seq(1, length(timeID), by = 6)[-1]) {
} else if(i == length(timeID)) {
} else {
lst_sq <- dsmp[date < timeID[i],][.N]$sq + 1
cat('\n===========================================\n')
cat('train[', i, ']\n')
print(train <- dsmp[(lst_sq - data_len + 1):lst_sq])
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
cat('\n-------------------------------------------\n')
cat('train_test[', i, ']\n')
print(train_test <- dsmp[sq %in% ctr])
sets <- train[, .(index, close)] %>%
as_tibble %>%
tk_ts(frequency = hrz1) %>%
ets(model = .model) %>%
forecast(h = hrz1) %>%
tk_tbl %>%
dplyr::mutate(index = train_test[(.N - hrz1 + 1):.N,]$index,
mk.price = train_test[(.N - hrz1 + 1):.N,]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
cat('\n-------------------------------------------\n')
cat('forecast[', i, ']\n')
print(sets %>% as.data.table)
fl_pth <- paste0(.dtr, 'data/fx/USDJPY/ts_ets_', data_len,
'_', hrz1, '.', as_date(sets$index[1]), '.rds')
saveRDS(sets, fl_pth)
cat('\n', i, '=', paste0('~/data/fx/USDJPY/ts_ets_', .model, '_',
data_len, '_', hrz1, '.',
as_date(sets$index[1]), '.rds saved!'))
cat('\n\n')
rm(sets)
}
})
} else {
}
return(tmp)
}
intra_1440 <- function(timeID, data = dsmp, data_len,
hrz1 = 60, .model, vb = TRUE) {
## data_len 1440; hrz1 = 60
intr <- data_len/hrz1
tmp <- llply(1:length(timeID), function(i) {
if(i == 1) {
tmp2 <-llply(1:intr, function(j) {
if(j == 1) {
train <- dsmp[date < timeID[i]][(.N - (data_len - 1)):.N]
} else {
lst_sq <- dsmp[date < timeID[i]][(.N - (hrz1 * (intr - j + 1) - 1))]$sq
train <- dsmp[lst_sq:(lst_sq + data_len - 1)]
}
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
if(vb == TRUE) {
cat('\n===========================================\n')
cat('train[', i, '-', j, ']\n')
print(train)
}
train_test <- dsmp[sq %in% ctr]
if(vb == TRUE) {
cat('\n-------------------------------------------\n')
cat('train_test[', i, '-', j, ']\n')
print(train_test)
}
sets <- train[, .(index, close)] %>%
as_tibble %>%
tk_ts(frequency = hrz1) %>%
ets(model = .model) %>%
forecast(h = hrz1) %>%
tk_tbl %>%
dplyr::mutate(index = train_test[(.N - hrz1 + 1):.N,]$index,
mk.price = train_test[(.N - hrz1 + 1):.N,]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
if(vb == TRUE) {
cat('\n-------------------------------------------\n')
cat('forecast[', i, '-', j, ']\n')
print(sets %>% as.data.table)
}
fl_pth <- paste0(
.dtr, 'data/fx/USDJPY/intraday/ts_ets_', .model, '_', data_len,
'_', hrz1, '.p', j, '.', as_date(sets$index[1]), '.rds')
saveRDS(sets, fl_pth)
cat('\n', i, '-', j, '=',
paste0('~/data/fx/USDJPY/intraday/ts_ets_', .model, '_',
data_len, '_', hrz1, '.p', j, '.',
as_date(sets$index[1]), '.rds saved!'))
cat('\n\n')
rm(sets)
})
return(tmp2)
} else if(i %in% seq(1, length(timeID), by = 6)[-1]) {
} else if(i == length(timeID)) {
} else {
tmp2 <-llply(1:intr, function(j) {
if(j == 1) {
lst_sq <- dsmp[date < timeID[i],][.N]$sq + 1
} else {
lst_sq <- dsmp[date < timeID[i],][.N]$sq + 1 + hrz1 * (j - 1)
}
train <- dsmp[(lst_sq - data_len + 1):lst_sq]
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
if(vb == TRUE) {
cat('\n===========================================\n')
cat('train[', i, '-', j, ']\n')
print(train)
}
train_test <- dsmp[sq %in% ctr]
if(vb == TRUE) {
cat('\n-------------------------------------------\n')
cat('train_test[', i, '-', j, ']\n')
print(train_test)
}
sets <- train[, .(index, close)] %>%
as_tibble %>%
tk_ts(frequency = hrz1) %>%
ets(model = .model) %>%
forecast(h = hrz1) %>%
tk_tbl %>%
dplyr::mutate(index = train_test[(.N - hrz1 + 1):.N,]$index,
mk.price = train_test[(.N - hrz1 + 1):.N,]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
if(vb == TRUE) {
cat('\n-------------------------------------------\n')
cat('forecast[', i, '-', j, ']\n')
print(sets %>% as.data.table)
}
fl_pth <- paste0(
.dtr, 'data/fx/USDJPY/intraday/ts_ets_', .model, '_', data_len,
'_', hrz1, '.p', j, '.', as_date(sets$index[1]), '.rds')
saveRDS(sets, fl_pth)
cat('\n', i, '-', j, '=',
paste0('~/data/fx/USDJPY/intraday/ts_ets_', .model, '_',
data_len, '_', hrz1, '.p', j, '.',
as_date(sets$index[1]), '.rds saved!'))
cat('\n\n')
rm(sets)
})
return(tmp2)
}
})
return(tmp)
}
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/tseas.R')
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 1440
hrz2 <- 1440
llply(ets.m, function(md) {
tseas(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
hrz2 = hrz2, .model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/'), pattern = '^ts_ets_MNN_1440_1440.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 1440)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2016-01-04 00:01:00 | 120.2200 | 120.208 |
| 2 | 2016-01-04 00:02:00 | 120.2200 | 120.208 |
| 3 | 2016-01-04 00:03:00 | 120.2200 | 120.208 |
| 1438 | 2016-01-04 23:58:00 | 119.4535 | 120.208 |
| 1439 | 2016-01-04 23:59:00 | 119.4450 | 120.208 |
| 1440 | 2016-01-05 00:00:00 | 119.4530 | 120.208 |
source : 1440 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 720 mins (12 hrs * 60 mins = 720 mins is half trading day).
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 720
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_720.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 720)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2016-01-04 00:01:00 | 120.2200 | 120.208 |
| 2 | 2016-01-04 00:02:00 | 120.2200 | 120.208 |
| 3 | 2016-01-04 00:03:00 | 120.2200 | 120.208 |
| 718 | 2016-01-04 11:58:00 | 118.9050 | 120.208 |
| 719 | 2016-01-04 11:59:00 | 118.8765 | 120.208 |
| 720 | 2016-01-04 12:00:00 | 118.8800 | 120.208 |
source : 720 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 480 mins (8 hrs * 60 mins = 480 mins is 8 hours in a trading day).
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 480
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_480.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 480)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2016-01-04 00:01:00 | 120.2200 | 120.208 |
| 2 | 2016-01-04 00:02:00 | 120.2200 | 120.208 |
| 3 | 2016-01-04 00:03:00 | 120.2200 | 120.208 |
| 478 | 2016-01-04 07:58:00 | 119.3670 | 120.208 |
| 479 | 2016-01-04 07:59:00 | 119.3810 | 120.208 |
| 480 | 2016-01-04 08:00:00 | 119.3885 | 120.208 |
source : 480 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 360 mins (6 hrs * 60 mins = 360 mins is 6 hours in a trading day).
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 360
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_360.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 360)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2017-06-09 06:01:00 | 110.2445 | 110.237 |
| 2 | 2017-06-09 06:02:00 | 110.2605 | 110.237 |
| 3 | 2017-06-09 06:03:00 | 110.2620 | 110.237 |
| 358 | 2017-06-09 11:58:00 | 110.3850 | 110.237 |
| 359 | 2017-06-09 11:59:00 | 110.3775 | 110.237 |
| 360 | 2017-06-09 12:00:00 | 110.3790 | 110.237 |
source : 360 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 240 mins (4 hrs * 60 mins = 240 mins is 4 hours in a trading day).
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 240
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_240.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 240)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2016-01-04 00:01:00 | 120.2200 | 120.208 |
| 2 | 2016-01-04 00:02:00 | 120.2200 | 120.208 |
| 3 | 2016-01-04 00:03:00 | 120.2200 | 120.208 |
| 238 | 2016-01-04 03:58:00 | 120.0205 | 120.208 |
| 239 | 2016-01-04 03:59:00 | 120.0300 | 120.208 |
| 240 | 2016-01-04 04:00:00 | 119.9450 | 120.208 |
source : 240 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 180 mins (3 hrs * 60 mins = 180 mins is 3 hours in a trading day).
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 180
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_180.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 180)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2018-03-30 03:01:00 | 106.4765 | 106.4817 |
| 2 | 2018-03-30 03:02:00 | 106.4880 | 106.4817 |
| 3 | 2018-03-30 03:03:00 | 106.4820 | 106.4817 |
| 178 | 2018-03-30 05:58:00 | 106.2140 | 106.4817 |
| 179 | 2018-03-30 05:59:00 | 106.2130 | 106.4817 |
| 180 | 2018-03-30 06:00:00 | 106.2320 | 106.4817 |
source : 180 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 120 mins (2 hrs * 60 mins = 120 mins is 2 hours in a trading day).
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 120
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_120.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 120)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2016-08-29 20:01:00 | 102.1715 | 102.1637 |
| 2 | 2016-08-29 20:02:00 | 102.1675 | 102.1637 |
| 3 | 2016-08-29 20:03:00 | 102.1465 | 102.1637 |
| 118 | 2016-08-29 21:58:00 | 101.9625 | 102.1637 |
| 119 | 2016-08-29 21:59:00 | 101.9695 | 102.1637 |
| 120 | 2016-08-29 22:00:00 | 101.9745 | 102.1637 |
source : 120 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 60 mins (1 hr * 60 mins = 60 mins is 1 hour in a trading day).
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 60
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_60.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 60)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2018-02-07 00:01:00 | 109.5340 | 109.5435 |
| 2 | 2018-02-07 00:02:00 | 109.5650 | 109.5435 |
| 3 | 2018-02-07 00:03:00 | 109.5570 | 109.5435 |
| 58 | 2018-02-07 00:58:00 | 109.6780 | 109.5435 |
| 59 | 2018-02-07 00:59:00 | 109.7050 | 109.5435 |
| 60 | 2018-02-07 01:00:00 | 109.6945 | 109.5435 |
source : 60 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 30 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 30
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_30.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 30)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2017-01-26 00:01:00 | 113.2650 | 113.261 |
| 2 | 2017-01-26 00:02:00 | 113.2620 | 113.261 |
| 3 | 2017-01-26 00:03:00 | 113.2795 | 113.261 |
| 28 | 2017-01-26 00:28:00 | 113.3025 | 113.261 |
| 29 | 2017-01-26 00:29:00 | 113.2880 | 113.261 |
| 30 | 2017-01-26 00:30:00 | 113.2870 | 113.261 |
source : 30 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 20 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 20
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_20.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 20)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2018-04-12 03:01:00 | 106.8290 | 106.8198 |
| 2 | 2018-04-12 03:02:00 | 106.8085 | 106.8198 |
| 3 | 2018-04-12 03:03:00 | 106.8085 | 106.8198 |
| 18 | 2018-04-12 03:18:00 | 106.7110 | 106.8198 |
| 19 | 2018-04-12 03:19:00 | 106.7040 | 106.8198 |
| 20 | 2018-04-12 03:20:00 | 106.7260 | 106.8198 |
source : 20 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 15 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 15
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_15.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 15)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2016-06-15 02:16:00 | 106.0410 | 106.0411 |
| 2 | 2016-06-15 02:17:00 | 106.0240 | 106.0411 |
| 3 | 2016-06-15 02:18:00 | 106.0060 | 106.0411 |
| 13 | 2016-06-15 02:28:00 | 106.0210 | 106.0411 |
| 14 | 2016-06-15 02:29:00 | 106.0120 | 106.0411 |
| 15 | 2016-06-15 02:30:00 | 106.0205 | 106.0411 |
source : 15 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 10 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 10
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_10.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 10)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2018-04-18 03:11:00 | 107.0615 | 107.0543 |
| 2 | 2018-04-18 03:12:00 | 107.0755 | 107.0543 |
| 3 | 2018-04-18 03:13:00 | 107.0855 | 107.0543 |
| 8 | 2018-04-18 03:18:00 | 107.1230 | 107.0543 |
| 9 | 2018-04-18 03:19:00 | 107.1195 | 107.0543 |
| 10 | 2018-04-18 03:20:00 | 107.1275 | 107.0543 |
source : 10 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 8 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 8
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_8.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 8)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2016-05-04 13:13:00 | 106.8070 | 106.8169 |
| 2 | 2016-05-04 13:14:00 | 106.8020 | 106.8169 |
| 3 | 2016-05-04 13:15:00 | 106.7955 | 106.8169 |
| 6 | 2016-05-04 13:18:00 | 106.7970 | 106.8169 |
| 7 | 2016-05-04 13:19:00 | 106.8155 | 106.8169 |
| 8 | 2016-05-04 13:20:00 | 106.7935 | 106.8169 |
source : 8 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 6 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 6
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_6.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
smp %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 6)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price |
|---|---|---|
| 2016-02-01 00:01:00 | 121.2675 | 121.129 |
| 2016-02-01 00:02:00 | 121.2360 | 121.129 |
| 2016-02-01 00:03:00 | 121.2585 | 121.129 |
| 2016-02-01 00:04:00 | 121.2880 | 121.129 |
| 2016-02-01 00:05:00 | 121.2500 | 121.129 |
| 2016-02-01 00:06:00 | 121.2455 | 121.129 |
source : 6 x 3
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 5 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 5
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_5.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
smp %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 5)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 4 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 4
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_4.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
smp %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 4)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 3 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 3
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_3.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
smp %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 3)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 2 mins in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 2
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_2.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
smp %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 2)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (1440 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_1440.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1440
hrz1 <- 1
llply(ets.m, function(md) {
intra_1440(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1440_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 1440 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price |
|---|---|---|
| 2016-01-04 00:01:00 | 120.220 | 120.2080 |
| 2016-01-05 00:01:00 | 119.449 | 119.4530 |
| 2016-01-06 00:01:00 | 119.061 | 119.0605 |
| 2016-01-07 00:01:00 | 118.477 | 118.4770 |
| 2016-01-08 00:01:00 | 117.665 | 117.6655 |
| 2016-01-11 00:01:00 | 117.182 | 117.2420 |
source : 6 x 3
I set the length of data as Daily (5 days * 1440 mins = 7200 mins which is 5 trading days) to forecast 720 mins (12 hrs * 60 mins = 720 mins is half trading day).
# --------- eval=FALSE ---------
## set all models provided by ets function.
if(!exists('ets.m')) ets.m <- 'MNN'
if(!exists('intra_7200')) source('function/intra_7200.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 7200
hrz1 <- 720
llply(ets.m, function(md) {
intra_7200(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_7200_720.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 7200 forecast 720)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price | |
|---|---|---|---|
| 1 | 2016-08-26 00:01:00 | 100.5295 | 100.5295 |
| 2 | 2016-08-26 00:02:00 | 100.5295 | 100.5295 |
| 3 | 2016-08-26 00:03:00 | 100.5295 | 100.5295 |
| 718 | 2016-08-26 11:58:00 | 100.4645 | 100.5295 |
| 719 | 2016-08-26 11:59:00 | 100.4720 | 100.5295 |
| 720 | 2016-08-26 12:00:00 | 100.4685 | 100.5295 |
source : 720 x 3
I set the length of data as Daily (5 days * 1440 mins = 7200 mins which is 5 trading days) to forecast 360 mins (6 hrs * 60 mins = 360 mins is half trading day).
# --------- eval=FALSE ---------
## set all models provided by ets function.
if(!exists('ets.m')) ets.m <- 'MNN'
if(!exists('intra_7200')) source('function/intra_7200.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 7200
hrz1 <- 360
llply(ets.m, function(md) {
intra_7200(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_7200_360.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 7200 forecast 360)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (5 days * 1440 mins = 7200 mins which is 5 trading days) to forecast 180 mins (3 hrs * 60 mins = 180 mins is half trading day).
# --------- eval=FALSE ---------
## set all models provided by ets function.
if(!exists('ets.m')) ets.m <- 'MNN'
if(!exists('intra_7200')) source('function/intra_7200.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 7200
hrz1 <- 180
llply(ets.m, function(md) {
intra_7200(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_7200_180.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 7200 forecast 180)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (5 days * 1440 mins = 7200 mins which is 5 trading days) to forecast 60 mins (3 hrs * 60 mins = 60 mins is half trading day).
# --------- eval=FALSE ---------
## set all models provided by ets function.
if(!exists('ets.m')) ets.m <- 'MNN'
if(!exists('intra_7200')) source('function/intra_7200.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 7200
hrz1 <- 60
llply(ets.m, function(md) {
intra_7200(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_7200_60.p_[0-9]{0,}.[0-9]{4}')[1]
if(all(is.na(fl))){
smp <- NA
} else {
smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
data.frame(smp)[
c(1:3, (nrow(smp)-2):nrow(smp)),] %>%
kbl(caption = 'Data Sample (ETS MNN 7200 forecast 60)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
#column_spec(3, background = 'LightSlateGrey') %>%
#column_spec(3, background = '#556DAC') %>%
column_spec(3, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (1200 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1200
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1200_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 1200 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (1080 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 1080
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1080_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 1080 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
I set the length of data as Daily (960 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 960
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_960_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 960 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price |
|---|---|---|
| 2016-01-04 00:02:00 | 120.220 | 120.2104 |
| 2016-01-05 00:01:00 | 119.449 | 119.4530 |
| 2016-01-06 00:01:00 | 119.061 | 119.0605 |
| 2016-01-07 00:01:00 | 118.477 | 118.4769 |
| 2016-01-08 00:01:00 | 117.665 | 117.6655 |
| 2016-01-11 00:02:00 | 117.183 | 117.1844 |
I set the length of data as Daily (840 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 840
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_840_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 840 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price |
|---|---|---|
| 2016-02-01 00:01:00 | 121.2675 | 121.1290 |
| 2016-02-02 00:01:00 | 121.0180 | 121.0090 |
| 2016-02-03 00:01:00 | 119.9710 | 119.9625 |
| 2016-02-04 00:01:00 | 117.8940 | 117.8950 |
| 2016-02-05 00:01:00 | 116.7770 | 116.7750 |
| 2016-02-08 00:02:00 | 116.8525 | 116.8475 |
I set the length of data as Daily (720 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 720
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_720_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 720 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price |
|---|---|---|
| 2016-01-04 00:02:00 | 120.220 | 120.2104 |
| 2016-01-05 00:01:00 | 119.449 | 119.4530 |
| 2016-01-06 00:01:00 | 119.061 | 119.0605 |
| 2016-01-07 00:01:00 | 118.477 | 118.4768 |
| 2016-01-08 00:01:00 | 117.665 | 117.6655 |
| 2016-01-11 00:02:00 | 117.183 | 117.1843 |
I set the length of data as Daily (600 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 600
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_600_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 600 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price |
|---|---|---|
| 2016-01-04 00:02:00 | 120.220 | 120.2104 |
| 2016-01-05 00:01:00 | 119.449 | 119.4530 |
| 2016-01-06 00:01:00 | 119.061 | 119.0605 |
| 2016-01-07 00:01:00 | 118.477 | 118.4770 |
| 2016-01-08 00:01:00 | 117.665 | 117.6655 |
| 2016-01-11 00:02:00 | 117.183 | 117.1841 |
I set the length of data as Daily (480 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 480
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_480_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 480 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| index | mk.price | fc.price |
|---|---|---|
| 2016-01-04 00:02:00 | 120.220 | 120.2104 |
| 2016-01-05 00:01:00 | 119.449 | 119.4530 |
| 2016-01-06 00:01:00 | 119.061 | 119.0605 |
| 2016-01-07 00:01:00 | 118.477 | 118.4769 |
| 2016-01-08 00:01:00 | 117.665 | 117.6655 |
| 2016-01-11 00:02:00 | 117.183 | 117.1872 |
source : 6 x 3
I set the length of data as Daily (360 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 360
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_360_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 360 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| index | mk.price | fc.price |
|---|---|---|
| 2016-01-04 00:01:00 | 120.220 | 120.2080 |
| 2016-01-05 00:01:00 | 119.449 | 119.4528 |
| 2016-01-06 00:01:00 | 119.061 | 119.0605 |
| 2016-01-07 00:01:00 | 118.477 | 118.4766 |
| 2016-01-08 00:01:00 | 117.665 | 117.6656 |
| 2016-01-11 00:01:00 | 117.182 | 117.2420 |
source : 6 x 3
I set the length of data as Daily (240 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 240
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_240_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 240 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price |
|---|---|---|
| 2016-01-04 00:02:00 | 120.220 | 120.2104 |
| 2016-01-05 00:01:00 | 119.449 | 119.4528 |
| 2016-01-06 00:01:00 | 119.061 | 119.0605 |
| 2016-01-07 00:01:00 | 118.477 | 118.4763 |
| 2016-01-08 00:01:00 | 117.665 | 117.6655 |
| 2016-01-11 00:02:00 | 117.183 | 117.1820 |
source : 6 x 3
I set the length of data as Daily (180 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 180
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_180_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 180 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
| index | mk.price | fc.price |
|---|---|---|
| 2016-01-04 00:02:00 | 120.220 | 120.2104 |
| 2016-01-05 00:01:00 | 119.449 | 119.4527 |
| 2016-01-06 00:01:00 | 119.061 | 119.0605 |
| 2016-01-07 00:01:00 | 118.477 | 118.4760 |
| 2016-01-08 00:01:00 | 117.665 | 117.6656 |
| 2016-01-11 00:02:00 | 117.183 | 117.1820 |
source : 6 x 3
I set the length of data as Daily (120 mins which is 1 trading days) to forecast 1 min in advance.
# --------- eval=FALSE ---------
ets.m <- 'MNN'
source('function/intra_min.R')
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 120
hrz1 <- 1
llply(ets.m, function(md) {
intra_min(timeID = timeID, dsmp,
data_len = data_len, hrz1 = hrz1,
.model = md)
})
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_120_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
if(all(is.na(fl))){
smp <- NA
} else {
smp <- ldply(fl, function(x) {
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
})
smp %>%
kbl(caption = 'Data Sample (ETS MNN 120 forecast 1)', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
}
Here I read the saved models. As some have mentioned a possible way is using git interactive staging. This is great when you have files with different extensions
$ git add -A
$ git status
Source : git add -A和 git add . git add -u的区别
$ git add -i
staged unstaged path
1: unchanged +0/-1 TODO
2: unchanged +1/-1 index.html
3: unchanged +5/-1 lib/simplegit.rb
*** Commands ***
1: status 2: update 3: revert 4: add untracked
5: patch 6: diff 7: quit 8: help
What now>
If you press 2 then enter you will get a list of available files to be added:
What now> 2
staged unstaged path
1: unchanged +0/-1 TODO
2: unchanged +1/-1 index.html
3: unchanged +5/-1 lib/simplegit.rb
Update>>
Now you just have to insert the number of the files you want to add, so if we wanted to add TODO and index.html we would type 1,2
Update>> 1,2
staged unstaged path
* 1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
3: unchanged +5/-1 lib/simplegit.rb
Update>>
You see the * before the number? that means that the file was added.
Now imagine that you have 7 files and you want to add them all except the 7th? Sure we could type 1,2,3,4,5,6 but imagine instead of 7 we have 16, that would be quite cumbersome, the good thing we don’t need to type them all because we can use ranges,by typing 1-6
Update>> 1-6
staged unstaged path
* 1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
* 3: unchanged +5/-1 lib/simplegit.rb
* 4: unchanged +5/-1 file4.html
* 5: unchanged +5/-1 file5.html
* 6: unchanged +5/-1 file6.html
7: unchanged +5/-1 file7.html
Update>>
We can even use multiple ranges, so if we want from 1 to 3 and from 5 to 7 we type 1-3, 5-7:
Update>> 1-3, 5-7
staged unstaged path
* 1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
* 3: unchanged +5/-1 lib/simplegit.rb
4: unchanged +5/-1 file4.html
* 5: unchanged +5/-1 file5.html
* 6: unchanged +5/-1 file6.html
* 7: unchanged +5/-1 file7.html
Update>>
We can also use this to unstage files, if we type -number, so if we wanted to unstage file number 1 we would type -1:
Update>> -1
staged unstaged path
1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
* 3: unchanged +5/-1 lib/simplegit.rb
4: unchanged +5/-1 file4.html
* 5: unchanged +5/-1 file5.html
* 6: unchanged +5/-1 file6.html
* 7: unchanged +5/-1 file7.html
Update>>
And as you can imagine we can also unstage a range of files, so if we type -range all the files on that range would be unstaged. If we wanted to unstage all the files from 5 to 7 we would type -5-7:
Update>> -5-7
staged unstaged path
1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
* 3: unchanged +5/-1 lib/simplegit.rb
4: unchanged +5/-1 file4.html
5: unchanged +5/-1 file5.html
6: unchanged +5/-1 file6.html
7: unchanged +5/-1 file7.html
Update>>
Source : How to add multiple files to Git at the same time.
You can commit all files by doing a `git add .` or just specifying the directory that they're in: `git add ./folder/` or to add all files that begin with "test": `git add test*`
Source : How to add or commit specific files without specifying their full path?
## Get all files.
fls <- paste0(.dtr, 'data/fx/USDJPY/') %>%
list.files(., pattern = '^ts_ets_MNN_7200_1440.[0-9]{4}')
fls_pth <- paste0(.dtr, 'data/fx/USDJPY/', fls)
mds_ets_MNN_7200_1440 <- ldply(1:length(fls), function(i) {
nms <- fls[i] %>%
str_replace_all('.rds', '') %>%
str_split('_|\\.') %>%
.[[1]]
nms <- nms
names(nms) <- c('t_series', 'model', 'sub_model',
'data_min', 'fc_min', 'date')
datset2 <- t(nms) %>%
data.frame %>%
mutate(model =factor(model), sub_model = factor(sub_model),
data_min = as.numeric(data_min),
fc_min = as.numeric(fc_min),
part = 1,
date = as_date(date))
datset <- read_rds(fls_pth[i])
res <- tibble(datset2, datset) %>%
dplyr::select(index, t_series, model, sub_model, data_min,
fc_min, part, date, mk.price, fc.price)
res <- res[!is.na('mk.price'),]
cat(nms, '\n')
return(res)
}) %>%
as_tibble
## https://tysonbarrett.com/jekyll/update/2019/10/06/datatable_memory/
## http://brooksandrew.github.io/simpleblog/articles/advanced-data-table/
## https://atrebas.github.io/post/2019-03-03-datatable-dplyr/
saveRDS(mds_ets_MNN_7200_1440,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_7200_1440.rds'))
## Get all files.
fls <- paste0(.dtr, 'data/fx/USDJPY/intraday/') %>%
list.files(., pattern = '^ts_ets_MNN_')
fls_pth <- paste0(.dtr, 'data/fx/USDJPY/intraday/', fls)
mds_ets_MNN_intraday <- ldply(1:length(fls), function(i) {
nms <- fls[i] %>%
str_replace_all('.rds', '') %>%
str_split('_|\\.') %>%
.[[1]]
nms <- nms[-6]
names(nms) <- c('t_series', 'model', 'sub_model',
'data_min', 'fc_min', 'part', 'date')
datset2 <- t(nms) %>%
data.frame %>%
mutate(model =factor(model), sub_model = factor(sub_model),
data_min = as.numeric(data_min),
fc_min = as.numeric(fc_min),
part = as.numeric(part),
date = as_date(date))
datset <- read_rds(fls_pth[i])
res <- tibble(datset2, datset) %>%
dplyr::select(index, t_series, model, sub_model, data_min,
fc_min, part, date, mk.price, fc.price)
res <- res[!is.na('mk.price'),]
cat(nms, '\n')
return(res)
}) %>%
as_tibble
## https://tysonbarrett.com/jekyll/update/2019/10/06/datatable_memory/
## http://brooksandrew.github.io/simpleblog/articles/advanced-data-table/
## https://atrebas.github.io/post/2019-03-03-datatable-dplyr/
saveRDS(mds_ets_MNN_intraday, paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday.rds'))
if(!exists('mds_ets_MNN_7200_1440')) {
mds_ets_MNN_7200_1440 <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_7200_1440.rds')) }
if(!exists('mds_ets_MNN_intraday')) {
mds_ets_MNN_intraday <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday.rds')) }
mds_ets_MNN_intraday <- rbind(mds_ets_MNN_7200_1440, mds_ets_MNN_intraday) %>%
as.data.table
mds_ets_MNN_intraday <- mds_ets_MNN_intraday[order(index, part, data_min, fc_min)]
saveRDS(mds_ets_MNN_intraday, paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday.rds'))
rm(mds_ets_MNN_7200_1440)
if(file.exists(paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_7200_1440.rds'))) {
file.remove(paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_7200_1440.rds')) }
rm(list = ls())
if(!exists('mds_ets_MNN_intraday')) {
mds_ets_MNN_intraday <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday.rds')) }
mds_ets_MNN_intraday_cmp <- mds_ets_MNN_intraday %>%
#tidyr::unite(model, t_series:part) %>%
tidyr::unite(model, t_series:fc_min) %>%
as.data.table %>%
.[, .(index, model, mk.price, fc.price)] %>% as.data.table
mds_ets_MNN_intraday_cmp <- as.data.table(mds_ets_MNN_intraday_cmp)
## ----------------------------------------
## fromLast = FALSE
mds_ets_MNN_intraday_cmp_fLF <- unique(
mds_ets_MNN_intraday_cmp[, .(index, model, mk.price, fc.price)], fromLast = FALSE)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday_cmp_fLF,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_cmp_fLF.rds'))
## ----------------------------------------
## fromLast = TRUE
mds_ets_MNN_intraday_cmp_fLT <- unique(
mds_ets_MNN_intraday_cmp[, .(index, model, mk.price, fc.price)], fromLast = TRUE)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday_cmp_fLT,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_cmp_fLT.rds'))
## ----------------------------------------
## convert to long format for plot chart
## fromLast = FALSE
prc <- unique(mds_ets_MNN_intraday_cmp[, .(index, model, mk.price)], fromLast = FALSE)
prc <- prc[, model := 'actual'][]
setnames(prc, old = 'mk.price', new = 'price')
prc <- unique(prc, fromLast = FALSE)
mds_ets_MNN_intraday_grph <- unique(
mds_ets_MNN_intraday_cmp[, .(index, model, fc.price)], fromLast = FALSE)
setnames(mds_ets_MNN_intraday_grph, old = 'fc.price', new = 'price')
mds_ets_MNN_intraday_grph <- rbind(mds_ets_MNN_intraday_grph, prc)
mds_ets_MNN_intraday_grph_fLF <- data.table(mds_ets_MNN_intraday_grph)[order(index)]
rm(prc)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday_grph_fLF,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_grph_fLF.rds'))
## ----------------------------------------
## fromLast = TRUE
prc <- unique(mds_ets_MNN_intraday_cmp[, .(index, model, mk.price)], fromLast = TRUE)
prc <- prc[, model := 'actual'][]
setnames(prc, old = 'mk.price', new = 'price')
prc <- unique(prc, fromLast = TRUE)
mds_ets_MNN_intraday_grph <- unique(
mds_ets_MNN_intraday_cmp[, .(index, model, fc.price)], fromLast = TRUE)
setnames(mds_ets_MNN_intraday_grph, old = 'fc.price', new = 'price')
mds_ets_MNN_intraday_grph <- rbind(mds_ets_MNN_intraday_grph, prc)
mds_ets_MNN_intraday_grph_fLT <- data.table(mds_ets_MNN_intraday_grph)[order(index)]
rm(prc)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday_grph_fLT,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_grph_fLT.rds'))
if(!exists('mds_ets_MNN_intraday')) {
mds_ets_MNN_intraday <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday.rds')) }
## plot sample data
mds_ets_MNN_intraday[c(1:3, (nrow(mds_ets_MNN_intraday)-3):nrow(mds_ets_MNN_intraday)),] %>%
kbl(caption = 'Data Sample (ETS MNN 7200/1440 from "2016-01-04" to "2018-07-06" forecast intraday)', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
## https://public.tableau.com/en-us/gallery/100-color-palettes?gallery=votd
row_spec(0, background = 'DimGrey', color = 'gold', bold = TRUE) %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = 'Gray') %>%
column_spec(3, background = 'DarkGrey') %>%
column_spec(4, background = 'Gray') %>%
column_spec(5, background = 'DarkGrey') %>%
column_spec(6, background = '#4897D8') %>%
column_spec(7, background = '#375E97') %>%
column_spec(8, background = 'CornflowerBlue') %>%
column_spec(9, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(10, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>% ##`full_width = FALSE` will auto adjust every single columns width to fit the table full width.
scroll_box(width = '100%', fixed_thead = TRUE, height = '400px')
| index | t_series | model | sub_model | data_min | fc_min | part | date | mk.price | fc.price |
|---|---|---|---|---|---|---|---|---|---|
| 2016-01-04 00:01:00 | ts | ets | MNN | 1440 | 1 | 1 | 2016-01-04 | 120.220 | 120.2080 |
| 2016-01-04 00:01:00 | ts | ets | MNN | 1440 | 6 | 1 | 2016-01-04 | 120.220 | 120.2080 |
| 2016-01-04 00:01:00 | ts | ets | MNN | 1440 | 8 | 1 | 2016-01-04 | 120.220 | 120.2080 |
| 2018-07-07 00:00:00 | ts | ets | MNN | 1440 | 15 | 96 | 2018-07-06 | 110.474 | 110.4192 |
| 2018-07-07 00:00:00 | ts | ets | MNN | 1440 | 10 | 144 | 2018-07-06 | 110.474 | 110.4571 |
| 2018-07-07 00:00:00 | ts | ets | MNN | 1440 | 8 | 180 | 2018-07-06 | 110.474 | 110.4586 |
| 2018-07-07 00:00:00 | ts | ets | MNN | 1440 | 6 | 240 | 2018-07-06 | 110.474 | 110.4796 |
source : 18745921 x 10
There has a small mistake in previous paper Deriv.com - Interday High Frequency Trading Models Comparison Review (Part I) but doesn’t affect since I only want to compare the models and here I use the same MNN model and filter unique(fromLast = FALSE) and unique(fromLast = TRUE).
if(!exists('mds_ets_MNN_intraday_grph_fLF')) {
mds_ets_MNN_intraday_grph_fLF <- readRDS(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_grph_fLF.rds')) }
if(!exists('mds_ets_MNN_intraday_grph_fLT')) {
mds_ets_MNN_intraday_grph_fLT <- readRDS(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_grph_fLT.rds')) }
data.frame(mds_ets_MNN_intraday_grph_fLF)[
c(1:5, (nrow(mds_ets_MNN_intraday_grph_fLF)-5):nrow(mds_ets_MNN_intraday_grph_fLF)),] %>%
kbl(caption = 'Data Sample', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = 'grey') %>%
column_spec(3, background = '#556DAC') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| index | model | price | |
|---|---|---|---|
| 1 | 2016-01-04 00:01:00 | ts_ets_MNN_7200_1440 | 120.2080 |
| 2 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_1 | 120.2080 |
| 3 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_10 | 120.2080 |
| 4 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_120 | 120.2080 |
| 5 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_15 | 120.2080 |
| 15913492 | 2018-07-07 00:00:00 | ts_ets_MNN_1440_60 | 110.4234 |
| 15913493 | 2018-07-07 00:00:00 | ts_ets_MNN_1440_720 | 110.6322 |
| 15913494 | 2018-07-07 00:00:00 | ts_ets_MNN_1440_8 | 110.4586 |
| 15913495 | 2018-07-07 00:00:00 | ts_ets_MNN_7200_720 | 110.6322 |
| 15913496 | 2018-07-07 00:00:00 | ts_ets_MNN_7200_720 | 110.4740 |
| 15913497 | 2018-07-07 00:00:00 | actual | 110.4740 |
source : 15913497 x 3
data.frame(mds_ets_MNN_intraday_grph_fLT)[
c(1:6, (nrow(mds_ets_MNN_intraday_grph_fLT)-5):nrow(mds_ets_MNN_intraday_grph_fLT)),] %>%
kbl(caption = 'Data Sample', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = 'grey') %>%
column_spec(3, background = '#556DAC') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| index | model | price | |
|---|---|---|---|
| 1 | 2016-01-04 00:01:00 | ts_ets_MNN_7200_1440 | 120.2080 |
| 2 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_1 | 120.2080 |
| 3 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_10 | 120.2080 |
| 4 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_120 | 120.2080 |
| 5 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_15 | 120.2080 |
| 6 | 2016-01-04 00:01:00 | ts_ets_MNN_1440_180 | 120.2080 |
| 15913492 | 2018-07-07 00:00:00 | ts_ets_MNN_1440_60 | 110.4234 |
| 15913493 | 2018-07-07 00:00:00 | ts_ets_MNN_1440_720 | 110.6322 |
| 15913494 | 2018-07-07 00:00:00 | ts_ets_MNN_1440_8 | 110.4586 |
| 15913495 | 2018-07-07 00:00:00 | ts_ets_MNN_7200_720 | 110.6322 |
| 15913496 | 2018-07-07 00:00:00 | ts_ets_MNN_7200_720 | 110.4740 |
| 15913497 | 2018-07-07 00:00:00 | actual | 110.4740 |
source : 15913497 x 3
unique(x, fromLast = FALSE) Dataset## https://www.r-graph-gallery.com/line-chart-several-groups-ggplot2.html
plt <- mds_ets_MNN_intraday_grph_fLF %>%
ggplot(aes(x = index, y = price, group = model, color = model)) +
geom_line() +
labs(title = '1 min Open Price Forecasting',
subtitle = paste('From', range(unique(mds_ets_MNN_intraday_grph_fLF$index))[1L],
'to', range(unique(mds_ets_MNN_intraday_grph_fLF$index))[2L]),
caption = "Data source: fxcm") +
ylab('Exchange Rates USD/JPY') +
theme_economist() +
theme(legend.position = 'right')
#ggplotly(plt)
plt
Due to the high volume of data, here I skip the line chart.
unique(x, fromLast = TRUE) Dataset## https://www.r-graph-gallery.com/line-chart-several-groups-ggplot2.html
plt <- mds_ets_MNN_intraday_grph_fLT %>%
ggplot(aes(x = index, y = price, group = model, color = model)) +
geom_line() +
labs(title = '1 min Open Price Forecasting',
subtitle = paste('From', range(unique(mds_ets_MNN_intraday_grph_fLT$index))[1L],
'to', range(unique(mds_ets_MNN_intraday_grph_fLT$index))[2L]),
caption = "Data source: fxcm") +
ylab('Exchange Rates USD/JPY') +
theme_economist() +
theme(legend.position = 'right')
#ggplotly(plt)
plt
Due to the high volume of data, here I skip the line chart.
unique(x, fromLast = FALSE) DatasetBelow table compares the models.
rm(list = ls())
## report for mds_ets_MNN_intraday_cmp_fLF
if(!exists('mds_ets_MNN_intraday_cmp_fLF')) {
mds_ets_MNN_intraday_cmp_fLF <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_cmp_fLF.rds')) }
if(!is.data.table('mds_ets_MNN_intraday_cmp_fLF')) {
mds_ets_MNN_intraday_cmp_fLF %<>% as.data.table }
mds_ets_MNN_intraday_cmp_fLF <- unique(
mds_ets_MNN_intraday_cmp_fLF, fromLast = FALSE, by = c('index', 'model')) %>%
na.omit
rp_fLF <- mds_ets_MNN_intraday_cmp_fLF[, {
mk.price = mk.price
fc.price = fc.price
.SD[, .(.N,
mae = MLmetrics::MAE(y_true = mk.price, y_pred = fc.price),
mape = MLmetrics::MAPE(y_true = mk.price, y_pred = fc.price),
rmse = MLmetrics::RMSE(y_true = mk.price, y_pred = fc.price),
smape = Metrics::smape(actual = mk.price, predicted = fc.price),
mse = MLmetrics::MSE(y_true = mk.price, y_pred = fc.price)),
by=.(model)]}][order(model), ]
## report
saveRDS(rp_fLF, paste0(.dtr, 'data/fx/USDJPY/rp_fLF.rds'))
rp_fLF <- readRDS(paste0(.dtr, 'data/fx/USDJPY/rp_fLF.rds'))
rp_tbl <- rp_fLF %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Accurcy Report (Dataset from "2016-01-04" to "2018-07-06" Forecasted Up to Max 1440 mins)', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
#column_spec(1, background = 'CornflowerBlue') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'LightSlateGrey') %>%
column_spec(3, background = 'Gainsboro') %>%
column_spec(4, background = 'LightGray') %>%
column_spec(5, background = 'Gainsboro') %>%
column_spec(6, background = 'LightGray') %>%
column_spec(7, background = 'Gainsboro') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
##`full_width = FALSE` will auto adjust every single columns width to fit the table full width.
scroll_box(width = '100%', fixed_thead = TRUE, height = '400px')
rp_tbl
| model | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|
| ts_ets_MNN_1440_1 | 850925 | 0.0116135 (rank: 1) | 0.0001056 (rank: 1) | 0.0196293 (rank: 1) | 0.0001056 (rank: 1) | 0.0003853 (rank: 1) |
| ts_ets_MNN_1440_10 | 936012 | 0.0261097 (rank: 4) | 0.0002374 (rank: 4) | 0.0439667 (rank: 4) | 0.0002374 (rank: 4) | 0.0019331 (rank: 4) |
| ts_ets_MNN_1440_120 | 936008 | 0.0876931 (rank: 9) | 0.0007977 (rank: 9) | 0.142061 (rank: 9) | 0.0007976 (rank: 9) | 0.0201813 (rank: 9) |
| ts_ets_MNN_1440_15 | 936005 | 0.0315207 (rank: 5) | 0.0002866 (rank: 5) | 0.0527373 (rank: 5) | 0.0002866 (rank: 5) | 0.0027812 (rank: 5) |
| ts_ets_MNN_1440_180 | 936004 | 0.1090491 (rank: 10) | 0.0009924 (rank: 10) | 0.1758124 (rank: 10) | 0.0009922 (rank: 10) | 0.03091 (rank: 10) |
| ts_ets_MNN_1440_20 | 936008 | 0.036005 (rank: 6) | 0.0003275 (rank: 6) | 0.0602137 (rank: 6) | 0.0003275 (rank: 6) | 0.0036257 (rank: 6) |
| ts_ets_MNN_1440_240 | 936004 | 0.1239933 (rank: 11) | 0.0011291 (rank: 11) | 0.2000525 (rank: 11) | 0.0011289 (rank: 11) | 0.040021 (rank: 11) |
| ts_ets_MNN_1440_30 | 936008 | 0.0442656 (rank: 7) | 0.0004027 (rank: 7) | 0.0733471 (rank: 7) | 0.0004026 (rank: 7) | 0.0053798 (rank: 7) |
| ts_ets_MNN_1440_360 | 936004 | 0.1484447 (rank: 12) | 0.0013515 (rank: 12) | 0.2372316 (rank: 12) | 0.0013513 (rank: 12) | 0.0562789 (rank: 12) |
| ts_ets_MNN_1440_480 | 936004 | 0.1871978 (rank: 13) | 0.0017046 (rank: 13) | 0.2854502 (rank: 13) | 0.0017041 (rank: 13) | 0.0814818 (rank: 13) |
| ts_ets_MNN_1440_6 | 936012 | 0.0208291 (rank: 2) | 0.0001894 (rank: 2) | 0.0352063 (rank: 2) | 0.0001894 (rank: 2) | 0.0012395 (rank: 2) |
| ts_ets_MNN_1440_60 | 936008 | 0.0623901 (rank: 8) | 0.0005676 (rank: 8) | 0.1026414 (rank: 8) | 0.0005675 (rank: 8) | 0.0105353 (rank: 8) |
| ts_ets_MNN_1440_720 | 936004 | 0.2254901 (rank: 14) | 0.0020559 (rank: 14) | 0.3519291 (rank: 14) | 0.002055 (rank: 14) | 0.1238541 (rank: 14) |
| ts_ets_MNN_1440_8 | 936012 | 0.0236924 (rank: 3) | 0.0002155 (rank: 3) | 0.0405026 (rank: 3) | 0.0002155 (rank: 3) | 0.0016405 (rank: 3) |
| ts_ets_MNN_7200_1440 | 936004 | 0.3237977 (rank: 16) | 0.002952 (rank: 16) | 0.4913689 (rank: 16) | 0.0029499 (rank: 16) | 0.2414434 (rank: 16) |
| ts_ets_MNN_7200_720 | 936005 | 0.2258944 (rank: 15) | 0.0020595 (rank: 15) | 0.3523549 (rank: 15) | 0.0020585 (rank: 15) | 0.124154 (rank: 15) |
source :
from above models we know the βest model.
unique(x, fromLast = TRUE) DatasetBelow table compares the models.
rm(list = ls())
## report for mds_ets_MNN_intraday_cmp_fLT
if(!exists('mds_ets_MNN_intraday_cmp_fLT')) {
mds_ets_MNN_intraday_cmp_fLT <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_cmp_fLT.rds')) }
if(!is.data.table('mds_ets_MNN_intraday_cmp_fLT')) {
mds_ets_MNN_intraday_cmp_fLT %<>% as.data.table }
mds_ets_MNN_intraday_cmp_fLT <- unique(
mds_ets_MNN_intraday_cmp_fLT, fromLast = TRUE, by = c('index', 'model')) %>%
na.omit
rp_fLT <- mds_ets_MNN_intraday_cmp_fLT[, {
mk.price = mk.price
fc.price = fc.price
.SD[, .(.N,
mae = MLmetrics::MAE(y_true = mk.price, y_pred = fc.price),
mape = MLmetrics::MAPE(y_true = mk.price, y_pred = fc.price),
rmse = MLmetrics::RMSE(y_true = mk.price, y_pred = fc.price),
smape = Metrics::smape(actual = mk.price, predicted = fc.price),
mse = MLmetrics::MSE(y_true = mk.price, y_pred = fc.price)),
by=.(model)]}][order(model), ]
## report
saveRDS(rp_fLT, paste0(.dtr, 'data/fx/USDJPY/rp_fLT.rds'))
rp_fLT <- readRDS(paste0(.dtr, 'data/fx/USDJPY/rp_fLT.rds'))
rp_tbl <- rp_fLT %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Accurcy Report (Forecasted 1440 mins)', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
#column_spec(1, background = 'CornflowerBlue') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'LightSlateGrey') %>%
column_spec(3, background = 'Gainsboro') %>%
column_spec(4, background = 'LightGray') %>%
column_spec(5, background = 'Gainsboro') %>%
column_spec(6, background = 'LightGray') %>%
column_spec(7, background = 'Gainsboro') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
##`full_width = FALSE` will auto adjust every single columns width to fit the table full width.
scroll_box(width = '100%', fixed_thead = TRUE, height = '400px')
rp_tbl
| model | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|
| ts_ets_MNN_1440_1 | 853801 | 0.012137 (rank: 1) | 0.0001103 (rank: 1) | 0.023317 (rank: 1) | 0.0001103 (rank: 1) | 0.0005437 (rank: 1) |
| ts_ets_MNN_1440_10 | 939592 | 0.0266157 (rank: 4) | 0.0002419 (rank: 4) | 0.0456574 (rank: 4) | 0.0002419 (rank: 4) | 0.0020846 (rank: 4) |
| ts_ets_MNN_1440_120 | 939596 | 0.0879918 (rank: 9) | 0.0008003 (rank: 9) | 0.1423749 (rank: 9) | 0.0008002 (rank: 9) | 0.0202706 (rank: 9) |
| ts_ets_MNN_1440_15 | 939599 | 0.0320082 (rank: 5) | 0.0002909 (rank: 5) | 0.0541282 (rank: 5) | 0.0002909 (rank: 5) | 0.0029299 (rank: 5) |
| ts_ets_MNN_1440_180 | 939600 | 0.1092829 (rank: 10) | 0.0009943 (rank: 10) | 0.1759537 (rank: 10) | 0.0009942 (rank: 10) | 0.0309597 (rank: 10) |
| ts_ets_MNN_1440_20 | 939596 | 0.0364745 (rank: 6) | 0.0003316 (rank: 6) | 0.0614091 (rank: 6) | 0.0003316 (rank: 6) | 0.0037711 (rank: 6) |
| ts_ets_MNN_1440_240 | 939600 | 0.1241567 (rank: 11) | 0.0011304 (rank: 11) | 0.2000916 (rank: 11) | 0.0011302 (rank: 11) | 0.0400366 (rank: 11) |
| ts_ets_MNN_1440_30 | 939596 | 0.0447015 (rank: 7) | 0.0004065 (rank: 7) | 0.0742782 (rank: 7) | 0.0004065 (rank: 7) | 0.0055172 (rank: 7) |
| ts_ets_MNN_1440_360 | 939600 | 0.1485413 (rank: 12) | 0.0013522 (rank: 12) | 0.2371252 (rank: 12) | 0.001352 (rank: 12) | 0.0562284 (rank: 12) |
| ts_ets_MNN_1440_480 | 939600 | 0.1871554 (rank: 13) | 0.001704 (rank: 13) | 0.2852255 (rank: 13) | 0.0017036 (rank: 13) | 0.0813536 (rank: 13) |
| ts_ets_MNN_1440_6 | 939592 | 0.0213556 (rank: 2) | 0.0001941 (rank: 2) | 0.0373323 (rank: 2) | 0.0001941 (rank: 2) | 0.0013937 (rank: 2) |
| ts_ets_MNN_1440_60 | 939596 | 0.0627605 (rank: 8) | 0.0005708 (rank: 8) | 0.1032182 (rank: 8) | 0.0005707 (rank: 8) | 0.010654 (rank: 8) |
| ts_ets_MNN_1440_720 | 939600 | 0.22533 (rank: 14) | 0.0020542 (rank: 14) | 0.3514996 (rank: 14) | 0.0020533 (rank: 14) | 0.123552 (rank: 14) |
| ts_ets_MNN_1440_8 | 939592 | 0.0242083 (rank: 3) | 0.00022 (rank: 3) | 0.0423498 (rank: 3) | 0.00022 (rank: 3) | 0.0017935 (rank: 3) |
| ts_ets_MNN_7200_1440 | 939600 | 0.3240886 (rank: 16) | 0.0029543 (rank: 16) | 0.4914093 (rank: 16) | 0.0029522 (rank: 16) | 0.2414831 (rank: 16) |
| ts_ets_MNN_7200_720 | 943198 | 0.2273692 (rank: 15) | 0.0020721 (rank: 15) | 0.3538666 (rank: 15) | 0.0020712 (rank: 15) | 0.1252216 (rank: 15) |
source :
from above models we know the βest model.
rm(list = ls())
## report for rp_fLF and
if(!exists('rp_fLF')) {
rp_fLF <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp_fLF.rds')) %>%
as.data.table }
## report for rp_fLT and
if(!exists('rp_fLT')) {
rp_fLT <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp_fLT.rds')) %>%
as.data.table }
rp_fLF <- rp_fLF[, arrange := 'from_first'][]
rp_fLT <- rp_fLT[, arrange := 'from_last'][]
rp <- rbindlist(list(rp_fLF, rp_fLT))
rp <- rp[, .(model, arrange, N, mae, mape, rmse, smape, mse)]
rp %<>% unique
#sum <- rp[mae == min(mae) | mape == min(mape) | rmse == min(rmse) | smape == min(smape) | mse == min(mse)]
rp %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Accurcy Report (Initial Stage Comparison Dataset from "2016-01-04" to "2018-07-06")', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
#column_spec(1, background = 'CornflowerBlue') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'grey') %>%
column_spec(3, background = 'LightSlateGrey') %>%
column_spec(4, background = 'Gainsboro') %>%
column_spec(5, background = 'LightGray') %>%
column_spec(6, background = 'Gainsboro') %>%
column_spec(7, background = 'LightGray') %>%
column_spec(8, background = 'Gainsboro') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| model | arrange | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|---|
| ts_ets_MNN_1440_1 | from_first | 850925 | 0.0116135 (rank: 1) | 0.0001056 (rank: 1) | 0.0196293 (rank: 1) | 0.0001056 (rank: 1) | 0.0003853 (rank: 1) |
| ts_ets_MNN_1440_10 | from_first | 936012 | 0.0261097 (rank: 7) | 0.0002374 (rank: 7) | 0.0439667 (rank: 7) | 0.0002374 (rank: 7) | 0.0019331 (rank: 7) |
| ts_ets_MNN_1440_120 | from_first | 936008 | 0.0876931 (rank: 17) | 0.0007977 (rank: 17) | 0.142061 (rank: 17) | 0.0007976 (rank: 17) | 0.0201813 (rank: 17) |
| ts_ets_MNN_1440_15 | from_first | 936005 | 0.0315207 (rank: 9) | 0.0002866 (rank: 9) | 0.0527373 (rank: 9) | 0.0002866 (rank: 9) | 0.0027812 (rank: 9) |
| ts_ets_MNN_1440_180 | from_first | 936004 | 0.1090491 (rank: 19) | 0.0009924 (rank: 19) | 0.1758124 (rank: 19) | 0.0009922 (rank: 19) | 0.03091 (rank: 19) |
| ts_ets_MNN_1440_20 | from_first | 936008 | 0.036005 (rank: 11) | 0.0003275 (rank: 11) | 0.0602137 (rank: 11) | 0.0003275 (rank: 11) | 0.0036257 (rank: 11) |
| ts_ets_MNN_1440_240 | from_first | 936004 | 0.1239933 (rank: 21) | 0.0011291 (rank: 21) | 0.2000525 (rank: 21) | 0.0011289 (rank: 21) | 0.040021 (rank: 21) |
| ts_ets_MNN_1440_30 | from_first | 936008 | 0.0442656 (rank: 13) | 0.0004027 (rank: 13) | 0.0733471 (rank: 13) | 0.0004026 (rank: 13) | 0.0053798 (rank: 13) |
| ts_ets_MNN_1440_360 | from_first | 936004 | 0.1484447 (rank: 23) | 0.0013515 (rank: 23) | 0.2372316 (rank: 24) | 0.0013513 (rank: 23) | 0.0562789 (rank: 24) |
| ts_ets_MNN_1440_480 | from_first | 936004 | 0.1871978 (rank: 26) | 0.0017046 (rank: 26) | 0.2854502 (rank: 26) | 0.0017041 (rank: 26) | 0.0814818 (rank: 26) |
| ts_ets_MNN_1440_6 | from_first | 936012 | 0.0208291 (rank: 3) | 0.0001894 (rank: 3) | 0.0352063 (rank: 3) | 0.0001894 (rank: 3) | 0.0012395 (rank: 3) |
| ts_ets_MNN_1440_60 | from_first | 936008 | 0.0623901 (rank: 15) | 0.0005676 (rank: 15) | 0.1026414 (rank: 15) | 0.0005675 (rank: 15) | 0.0105353 (rank: 15) |
| ts_ets_MNN_1440_720 | from_first | 936004 | 0.2254901 (rank: 28) | 0.0020559 (rank: 28) | 0.3519291 (rank: 28) | 0.002055 (rank: 28) | 0.1238541 (rank: 28) |
| ts_ets_MNN_1440_8 | from_first | 936012 | 0.0236924 (rank: 5) | 0.0002155 (rank: 5) | 0.0405026 (rank: 5) | 0.0002155 (rank: 5) | 0.0016405 (rank: 5) |
| ts_ets_MNN_7200_1440 | from_first | 936004 | 0.3237977 (rank: 31) | 0.002952 (rank: 31) | 0.4913689 (rank: 31) | 0.0029499 (rank: 31) | 0.2414434 (rank: 31) |
| ts_ets_MNN_7200_720 | from_first | 936005 | 0.2258944 (rank: 29) | 0.0020595 (rank: 29) | 0.3523549 (rank: 29) | 0.0020585 (rank: 29) | 0.124154 (rank: 29) |
| ts_ets_MNN_1440_1 | from_last | 853801 | 0.012137 (rank: 2) | 0.0001103 (rank: 2) | 0.023317 (rank: 2) | 0.0001103 (rank: 2) | 0.0005437 (rank: 2) |
| ts_ets_MNN_1440_10 | from_last | 939592 | 0.0266157 (rank: 8) | 0.0002419 (rank: 8) | 0.0456574 (rank: 8) | 0.0002419 (rank: 8) | 0.0020846 (rank: 8) |
| ts_ets_MNN_1440_120 | from_last | 939596 | 0.0879918 (rank: 18) | 0.0008003 (rank: 18) | 0.1423749 (rank: 18) | 0.0008002 (rank: 18) | 0.0202706 (rank: 18) |
| ts_ets_MNN_1440_15 | from_last | 939599 | 0.0320082 (rank: 10) | 0.0002909 (rank: 10) | 0.0541282 (rank: 10) | 0.0002909 (rank: 10) | 0.0029299 (rank: 10) |
| ts_ets_MNN_1440_180 | from_last | 939600 | 0.1092829 (rank: 20) | 0.0009943 (rank: 20) | 0.1759537 (rank: 20) | 0.0009942 (rank: 20) | 0.0309597 (rank: 20) |
| ts_ets_MNN_1440_20 | from_last | 939596 | 0.0364745 (rank: 12) | 0.0003316 (rank: 12) | 0.0614091 (rank: 12) | 0.0003316 (rank: 12) | 0.0037711 (rank: 12) |
| ts_ets_MNN_1440_240 | from_last | 939600 | 0.1241567 (rank: 22) | 0.0011304 (rank: 22) | 0.2000916 (rank: 22) | 0.0011302 (rank: 22) | 0.0400366 (rank: 22) |
| ts_ets_MNN_1440_30 | from_last | 939596 | 0.0447015 (rank: 14) | 0.0004065 (rank: 14) | 0.0742782 (rank: 14) | 0.0004065 (rank: 14) | 0.0055172 (rank: 14) |
| ts_ets_MNN_1440_360 | from_last | 939600 | 0.1485413 (rank: 24) | 0.0013522 (rank: 24) | 0.2371252 (rank: 23) | 0.001352 (rank: 24) | 0.0562284 (rank: 23) |
| ts_ets_MNN_1440_480 | from_last | 939600 | 0.1871554 (rank: 25) | 0.001704 (rank: 25) | 0.2852255 (rank: 25) | 0.0017036 (rank: 25) | 0.0813536 (rank: 25) |
| ts_ets_MNN_1440_6 | from_last | 939592 | 0.0213556 (rank: 4) | 0.0001941 (rank: 4) | 0.0373323 (rank: 4) | 0.0001941 (rank: 4) | 0.0013937 (rank: 4) |
| ts_ets_MNN_1440_60 | from_last | 939596 | 0.0627605 (rank: 16) | 0.0005708 (rank: 16) | 0.1032182 (rank: 16) | 0.0005707 (rank: 16) | 0.010654 (rank: 16) |
| ts_ets_MNN_1440_720 | from_last | 939600 | 0.22533 (rank: 27) | 0.0020542 (rank: 27) | 0.3514996 (rank: 27) | 0.0020533 (rank: 27) | 0.123552 (rank: 27) |
| ts_ets_MNN_1440_8 | from_last | 939592 | 0.0242083 (rank: 6) | 0.00022 (rank: 6) | 0.0423498 (rank: 6) | 0.00022 (rank: 6) | 0.0017935 (rank: 6) |
| ts_ets_MNN_7200_1440 | from_last | 939600 | 0.3240886 (rank: 32) | 0.0029543 (rank: 32) | 0.4914093 (rank: 32) | 0.0029522 (rank: 32) | 0.2414831 (rank: 32) |
| ts_ets_MNN_7200_720 | from_last | 943198 | 0.2273692 (rank: 30) | 0.0020721 (rank: 30) | 0.3538666 (rank: 30) | 0.0020712 (rank: 30) | 0.1252216 (rank: 30) |
source : 32 x 8
In order to save the time, here I try to compare if the accuracy of the model by using 1 year dataset good enough.
if(!exists('mds_ets_MNN_intraday')) {
mds_ets_MNN_intraday <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday.rds')) }
mds_ets_MNN_intraday_1y <- mds_ets_MNN_intraday[date <= as_date('2016-12-31')]
saveRDS(mds_ets_MNN_intraday_1y, paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1y.rds'))
mds_ets_MNN_intraday_1y_cmp <- mds_ets_MNN_intraday_1y %>%
#tidyr::unite(model, t_series:part) %>%
tidyr::unite(model, t_series:fc_min) %>%
as.data.table %>%
.[, .(index, model, mk.price, fc.price)] %>% as.data.table
mds_ets_MNN_intraday_1y_cmp <- as.data.table(mds_ets_MNN_intraday_1y_cmp)
## ----------------------------------------
## fromLast = FALSE
mds_ets_MNN_intraday_1y_cmp_fLF <- unique(
mds_ets_MNN_intraday_1y_cmp[, .(index, model, mk.price, fc.price)], fromLast = FALSE)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday_1y_cmp_fLF,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1y_cmp_fLF.rds'))
## ----------------------------------------
## fromLast = TRUE
mds_ets_MNN_intraday_1y_cmp_fLT <- unique(
mds_ets_MNN_intraday_1y_cmp[, .(index, model, mk.price, fc.price)], fromLast = TRUE)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday_1y_cmp_fLT,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1y_cmp_fLT.rds'))
## ----------------------------------------
## convert to long format for plot chart
## fromLast = FALSE
prc <- unique(mds_ets_MNN_intraday_1y_cmp[, .(index, model, mk.price)], fromLast = FALSE)
prc <- prc[, model := 'actual'][]
setnames(prc, old = 'mk.price', new = 'price')
prc <- unique(prc, fromLast = FALSE)
mds_ets_MNN_intraday_1y_grph <- unique(
mds_ets_MNN_intraday_1y_cmp[, .(index, model, fc.price)], fromLast = FALSE)
setnames(mds_ets_MNN_intraday_1y_grph, old = 'fc.price', new = 'price')
mds_ets_MNN_intraday_1y_grph <- rbind(mds_ets_MNN_intraday_1y_grph, prc)
mds_ets_MNN_intraday_1y_grph_fLF <- data.table(mds_ets_MNN_intraday_1y_grph)[order(index)]
rm(prc)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday_1y_grph_fLF,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1y_grph_fLF.rds'))
## ----------------------------------------
## fromLast = TRUE
prc <- unique(mds_ets_MNN_intraday_1y_cmp[, .(index, model, mk.price)], fromLast = TRUE)
prc <- prc[, model := 'actual'][]
setnames(prc, old = 'mk.price', new = 'price')
prc <- unique(prc, fromLast = TRUE)
mds_ets_MNN_intraday_1y_grph <- unique(
mds_ets_MNN_intraday_1y_cmp[, .(index, model, fc.price)], fromLast = TRUE)
setnames(mds_ets_MNN_intraday_1y_grph, old = 'fc.price', new = 'price')
mds_ets_MNN_intraday_1y_grph <- rbind(mds_ets_MNN_intraday_1y_grph, prc)
mds_ets_MNN_intraday_1y_grph_fLT <- data.table(mds_ets_MNN_intraday_1y_grph)[order(index)]
rm(prc)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday_1y_grph_fLT,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1y_grph_fLT.rds'))
unique(x, fromLast = FALSE) DatasetBelow table compares the models.
rm(list = ls())
## report for mds_ets_MNN_intraday_1y_cmp_fLF
if(!exists('mds_ets_MNN_intraday_1y_cmp_fLF')) {
mds_ets_MNN_intraday_1y_cmp_fLF <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1y_cmp_fLF.rds')) }
if(!is.data.table('mds_ets_MNN_intraday_1y_cmp_fLF')) {
mds_ets_MNN_intraday_1y_cmp_fLF %<>% as.data.table }
mds_ets_MNN_intraday_1y_cmp_fLF <- unique(
mds_ets_MNN_intraday_1y_cmp_fLF, fromLast = FALSE, by = c('index', 'model')) %>%
na.omit
rp_1y_fLF <- mds_ets_MNN_intraday_1y_cmp_fLF[, {
mk.price = mk.price
fc.price = fc.price
.SD[, .(.N,
mae = MLmetrics::MAE(y_true = mk.price, y_pred = fc.price),
mape = MLmetrics::MAPE(y_true = mk.price, y_pred = fc.price),
rmse = MLmetrics::RMSE(y_true = mk.price, y_pred = fc.price),
smape = Metrics::smape(actual = mk.price, predicted = fc.price),
mse = MLmetrics::MSE(y_true = mk.price, y_pred = fc.price)),
by=.(model)]}][order(model), ]
## report
saveRDS(rp_1y_fLF, paste0(.dtr, 'data/fx/USDJPY/rp_1y_fLF.rds'))
unique(x, fromLast = TRUE) DatasetBelow table compares the models.
rm(list = ls())
## report for mds_ets_MNN_intraday_cmp_fLT
if(!exists('mds_ets_MNN_intraday_1y_cmp_fLT')) {
mds_ets_MNN_intraday_1y_cmp_fLT <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1y_cmp_fLT.rds')) }
if(!is.data.table('mds_ets_MNN_intraday_1y_cmp_fLT')) {
mds_ets_MNN_intraday_1y_cmp_fLT %<>% as.data.table }
mds_ets_MNN_intraday_1y_cmp_fLT <- unique(
mds_ets_MNN_intraday_1y_cmp_fLT, fromLast = TRUE, by = c('index', 'model')) %>%
na.omit
rp_1y_fLT <- mds_ets_MNN_intraday_1y_cmp_fLT[, {
mk.price = mk.price
fc.price = fc.price
.SD[, .(.N,
mae = MLmetrics::MAE(y_true = mk.price, y_pred = fc.price),
mape = MLmetrics::MAPE(y_true = mk.price, y_pred = fc.price),
rmse = MLmetrics::RMSE(y_true = mk.price, y_pred = fc.price),
smape = Metrics::smape(actual = mk.price, predicted = fc.price),
mse = MLmetrics::MSE(y_true = mk.price, y_pred = fc.price)),
by=.(model)]}][order(model), ]
## report
saveRDS(rp_1y_fLT, paste0(.dtr, 'data/fx/USDJPY/rp_1y_fLT.rds'))
rm(list = ls())
## report for rp_fLF and
if(!exists('rp_fLF')) {
rp_fLF <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp_fLF.rds')) %>%
as.data.table }
## report for rp_fLT and
if(!exists('rp_fLT')) {
rp_fLT <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp_fLT.rds')) %>%
as.data.table }
rp_fLF <- rp_fLF[, arrange := 'from_first'][]
rp_fLT <- rp_fLT[, arrange := 'from_last'][]
rp <- rbindlist(list(rp_fLF, rp_fLT))
rp <- rp[, .(model, arrange, N, mae, mape, rmse, smape, mse)]
rp %<>% unique
## report for rp_1y_fLF and
if(!exists('rp_1y_fLF')) {
rp_1y_fLF <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp_1y_fLF.rds')) %>%
as.data.table }
## report for rp_1y_fLT and
if(!exists('rp_1y_fLT')) {
rp_1y_fLT <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp_1y_fLT.rds')) %>%
as.data.table }
rp_1y_fLF <- rp_1y_fLF[, arrange := 'from_first'][]
rp_1y_fLT <- rp_1y_fLT[, arrange := 'from_last'][]
rp_1y <- rbindlist(list(rp_1y_fLF, rp_1y_fLT))
rp_1y <- rp_1y[, .(model, arrange, N, mae, mape, rmse, smape, mse)]
rp_1y %<>% unique
#sum <- rp[mae == min(mae) | mape == min(mape) | rmse == min(rmse) | smape == min(smape) | mse == min(mse)]
rp_1y %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Accurcy Report (1 Year Dataset from "2016-01-04" to "2016-12-31")', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
#column_spec(1, background = 'CornflowerBlue') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'grey') %>%
column_spec(3, background = 'LightSlateGrey') %>%
column_spec(4, background = 'Gainsboro') %>%
column_spec(5, background = 'LightGray') %>%
column_spec(6, background = 'Gainsboro') %>%
column_spec(7, background = 'LightGray') %>%
column_spec(8, background = 'Gainsboro') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| model | arrange | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|---|
| ts_ets_MNN_1440_1 | from_first | 374398 | 0.0135726 (rank: 2) | 0.0001248 (rank: 2) | 0.0235634 (rank: 2) | 0.0001248 (rank: 2) | 0.0005552 (rank: 2) |
| ts_ets_MNN_1440_10 | from_first | 374400 | 0.0310264 (rank: 8) | 0.0002852 (rank: 8) | 0.0535552 (rank: 8) | 0.0002852 (rank: 8) | 0.0028682 (rank: 8) |
| ts_ets_MNN_1440_120 | from_first | 374400 | 0.1046746 (rank: 18) | 0.0009631 (rank: 18) | 0.1716097 (rank: 18) | 0.000963 (rank: 18) | 0.0294499 (rank: 18) |
| ts_ets_MNN_1440_15 | from_first | 374400 | 0.0373874 (rank: 10) | 0.0003437 (rank: 10) | 0.064235 (rank: 10) | 0.0003437 (rank: 10) | 0.0041261 (rank: 10) |
| ts_ets_MNN_1440_180 | from_first | 374400 | 0.129417 (rank: 20) | 0.0011914 (rank: 20) | 0.2116718 (rank: 20) | 0.0011911 (rank: 20) | 0.044805 (rank: 20) |
| ts_ets_MNN_1440_20 | from_first | 374400 | 0.0427459 (rank: 12) | 0.0003931 (rank: 12) | 0.0730338 (rank: 12) | 0.0003931 (rank: 12) | 0.0053339 (rank: 12) |
| ts_ets_MNN_1440_240 | from_first | 374400 | 0.148679 (rank: 22) | 0.0013704 (rank: 22) | 0.245548 (rank: 22) | 0.00137 (rank: 22) | 0.0602938 (rank: 22) |
| ts_ets_MNN_1440_30 | from_first | 374400 | 0.0524834 (rank: 14) | 0.0004828 (rank: 14) | 0.0890827 (rank: 14) | 0.0004827 (rank: 14) | 0.0079357 (rank: 14) |
| ts_ets_MNN_1440_360 | from_first | 374400 | 0.1784428 (rank: 24) | 0.0016443 (rank: 24) | 0.2897381 (rank: 24) | 0.0016439 (rank: 24) | 0.0839482 (rank: 24) |
| ts_ets_MNN_1440_480 | from_first | 374400 | 0.2263737 (rank: 26) | 0.0020871 (rank: 26) | 0.3521562 (rank: 26) | 0.0020863 (rank: 26) | 0.124014 (rank: 26) |
| ts_ets_MNN_1440_6 | from_first | 374400 | 0.0247197 (rank: 4) | 0.0002272 (rank: 4) | 0.0428744 (rank: 4) | 0.0002272 (rank: 4) | 0.0018382 (rank: 4) |
| ts_ets_MNN_1440_60 | from_first | 374400 | 0.0738649 (rank: 16) | 0.0006797 (rank: 16) | 0.1238921 (rank: 16) | 0.0006796 (rank: 16) | 0.0153493 (rank: 16) |
| ts_ets_MNN_1440_720 | from_first | 374400 | 0.2755691 (rank: 28) | 0.0025449 (rank: 28) | 0.4395358 (rank: 30) | 0.0025432 (rank: 28) | 0.1931917 (rank: 30) |
| ts_ets_MNN_1440_8 | from_first | 374400 | 0.0281814 (rank: 6) | 0.0002591 (rank: 6) | 0.0494359 (rank: 6) | 0.0002591 (rank: 6) | 0.0024439 (rank: 6) |
| ts_ets_MNN_7200_1440 | from_first | 374400 | 0.4072728 (rank: 32) | 0.0037581 (rank: 32) | 0.6228677 (rank: 32) | 0.0037537 (rank: 32) | 0.3879641 (rank: 32) |
| ts_ets_MNN_7200_720 | from_first | 374400 | 0.275585 (rank: 30) | 0.0025451 (rank: 30) | 0.4395006 (rank: 28) | 0.0025434 (rank: 30) | 0.1931608 (rank: 28) |
| ts_ets_MNN_1440_1 | from_last | 374398 | 0.0135726 (rank: 2) | 0.0001248 (rank: 2) | 0.0235634 (rank: 2) | 0.0001248 (rank: 2) | 0.0005552 (rank: 2) |
| ts_ets_MNN_1440_10 | from_last | 374400 | 0.0310264 (rank: 8) | 0.0002852 (rank: 8) | 0.0535552 (rank: 8) | 0.0002852 (rank: 8) | 0.0028682 (rank: 8) |
| ts_ets_MNN_1440_120 | from_last | 374400 | 0.1046746 (rank: 18) | 0.0009631 (rank: 18) | 0.1716097 (rank: 18) | 0.000963 (rank: 18) | 0.0294499 (rank: 18) |
| ts_ets_MNN_1440_15 | from_last | 374400 | 0.0373874 (rank: 10) | 0.0003437 (rank: 10) | 0.064235 (rank: 10) | 0.0003437 (rank: 10) | 0.0041261 (rank: 10) |
| ts_ets_MNN_1440_180 | from_last | 374400 | 0.129417 (rank: 20) | 0.0011914 (rank: 20) | 0.2116718 (rank: 20) | 0.0011911 (rank: 20) | 0.044805 (rank: 20) |
| ts_ets_MNN_1440_20 | from_last | 374400 | 0.0427459 (rank: 12) | 0.0003931 (rank: 12) | 0.0730338 (rank: 12) | 0.0003931 (rank: 12) | 0.0053339 (rank: 12) |
| ts_ets_MNN_1440_240 | from_last | 374400 | 0.148679 (rank: 22) | 0.0013704 (rank: 22) | 0.245548 (rank: 22) | 0.00137 (rank: 22) | 0.0602938 (rank: 22) |
| ts_ets_MNN_1440_30 | from_last | 374400 | 0.0524834 (rank: 14) | 0.0004828 (rank: 14) | 0.0890827 (rank: 14) | 0.0004827 (rank: 14) | 0.0079357 (rank: 14) |
| ts_ets_MNN_1440_360 | from_last | 374400 | 0.1784428 (rank: 24) | 0.0016443 (rank: 24) | 0.2897381 (rank: 24) | 0.0016439 (rank: 24) | 0.0839482 (rank: 24) |
| ts_ets_MNN_1440_480 | from_last | 374400 | 0.2263737 (rank: 26) | 0.0020871 (rank: 26) | 0.3521562 (rank: 26) | 0.0020863 (rank: 26) | 0.124014 (rank: 26) |
| ts_ets_MNN_1440_6 | from_last | 374400 | 0.0247197 (rank: 4) | 0.0002272 (rank: 4) | 0.0428744 (rank: 4) | 0.0002272 (rank: 4) | 0.0018382 (rank: 4) |
| ts_ets_MNN_1440_60 | from_last | 374400 | 0.0738649 (rank: 16) | 0.0006797 (rank: 16) | 0.1238921 (rank: 16) | 0.0006796 (rank: 16) | 0.0153493 (rank: 16) |
| ts_ets_MNN_1440_720 | from_last | 374400 | 0.2755691 (rank: 28) | 0.0025449 (rank: 28) | 0.4395358 (rank: 30) | 0.0025432 (rank: 28) | 0.1931917 (rank: 30) |
| ts_ets_MNN_1440_8 | from_last | 374400 | 0.0281814 (rank: 6) | 0.0002591 (rank: 6) | 0.0494359 (rank: 6) | 0.0002591 (rank: 6) | 0.0024439 (rank: 6) |
| ts_ets_MNN_7200_1440 | from_last | 374400 | 0.4072728 (rank: 32) | 0.0037581 (rank: 32) | 0.6228677 (rank: 32) | 0.0037537 (rank: 32) | 0.3879641 (rank: 32) |
| ts_ets_MNN_7200_720 | from_last | 374400 | 0.275585 (rank: 30) | 0.0025451 (rank: 30) | 0.4395006 (rank: 28) | 0.0025434 (rank: 30) | 0.1931608 (rank: 28) |
source : 32 x 8
rp_1y_3.5y <- rbind(rp[order(mae, mape, rmse, smape, mse)][1:4], rp_1y[order(mae, mape, rmse, smape, mse)][1:4])
rp_1y_3.5y %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Accurcy Report (Comparison between 1 Year & 3.5 Year Dataset)', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
#column_spec(1, background = 'CornflowerBlue') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'grey') %>%
column_spec(3, background = 'LightSlateGrey') %>%
column_spec(4, background = 'Gainsboro') %>%
column_spec(5, background = 'LightGray') %>%
column_spec(6, background = 'Gainsboro') %>%
column_spec(7, background = 'LightGray') %>%
column_spec(8, background = 'Gainsboro') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| model | arrange | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|---|
| ts_ets_MNN_1440_1 | from_first | 850925 | 0.0116135 (rank: 1) | 0.0001056 (rank: 1) | 0.0196293 (rank: 1) | 0.0001056 (rank: 1) | 0.0003853 (rank: 1) |
| ts_ets_MNN_1440_1 | from_last | 853801 | 0.012137 (rank: 2) | 0.0001103 (rank: 2) | 0.023317 (rank: 2) | 0.0001103 (rank: 2) | 0.0005437 (rank: 2) |
| ts_ets_MNN_1440_6 | from_first | 936012 | 0.0208291 (rank: 5) | 0.0001894 (rank: 5) | 0.0352063 (rank: 5) | 0.0001894 (rank: 5) | 0.0012395 (rank: 5) |
| ts_ets_MNN_1440_6 | from_last | 939592 | 0.0213556 (rank: 6) | 0.0001941 (rank: 6) | 0.0373323 (rank: 6) | 0.0001941 (rank: 6) | 0.0013937 (rank: 6) |
| ts_ets_MNN_1440_1 | from_first | 374398 | 0.0135726 (rank: 4) | 0.0001248 (rank: 4) | 0.0235634 (rank: 4) | 0.0001248 (rank: 4) | 0.0005552 (rank: 4) |
| ts_ets_MNN_1440_1 | from_last | 374398 | 0.0135726 (rank: 4) | 0.0001248 (rank: 4) | 0.0235634 (rank: 4) | 0.0001248 (rank: 4) | 0.0005552 (rank: 4) |
| ts_ets_MNN_1440_6 | from_first | 374400 | 0.0247197 (rank: 8) | 0.0002272 (rank: 8) | 0.0428744 (rank: 8) | 0.0002272 (rank: 8) | 0.0018382 (rank: 8) |
| ts_ets_MNN_1440_6 | from_last | 374400 | 0.0247197 (rank: 8) | 0.0002272 (rank: 8) | 0.0428744 (rank: 8) | 0.0002272 (rank: 8) | 0.0018382 (rank: 8) |
From the table above, N is the sample data size, 3.5 years dataset is more accurate than 1 year dataset. However due to save the resource and time:
1 year dataset.from_first dataset.## Get all intraday files.
fls <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1080_1.p_[0-9]{0,}.[0-9]{4}|^ts_ets_MNN_1200_1.p_[0-9]{0,}.[0-9]{4}|^ts_ets_MNN_480_1.p_[0-9]{0,}.[0-9]{4}|^ts_ets_MNN_360_1.p_[0-9]{0,}.[0-9]{4}|^ts_ets_MNN_240_1.p_[0-9]{0,}.[0-9]{4}|^ts_ets_MNN_180_1.p_[0-9]{0,}.[0-9]{4}') %>%
sort
fls_pth <- paste0(.dtr, 'data/fx/USDJPY/intraday/', fls)
mds_ets_MNN_intraday_1min <- ldply(1:length(fls), function(i) {
nms <- fls[i] %>%
str_replace_all('.rds', '') %>%
str_split('_|\\.') %>%
.[[1]]
nms <- nms[-6]
names(nms) <- c('t_series', 'model', 'sub_model',
'data_min', 'fc_min', 'part', 'date')
datset2 <- t(nms) %>%
data.frame %>%
mutate(model =factor(model), sub_model = factor(sub_model),
data_min = as.numeric(data_min),
fc_min = as.numeric(fc_min),
part = as.numeric(part),
date = as_date(date))
datset <- read_rds(fls_pth[i])
res <- tibble(datset2, datset) %>%
dplyr::select(index, t_series, model, sub_model, data_min,
fc_min, part, date, mk.price, fc.price)
res <- res[!is.na('mk.price'),]
cat(i, '/', length(fls), '=', nms, '\n')
return(res)
}) %>%
as_tibble
## https://tysonbarrett.com/jekyll/update/2019/10/06/datatable_memory/
## http://brooksandrew.github.io/simpleblog/articles/advanced-data-table/
## https://atrebas.github.io/post/2019-03-03-datatable-dplyr/
saveRDS(mds_ets_MNN_intraday_1min, paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1min.rds'))
mds_ets_MNN_intraday_1min_1y <- mds_ets_MNN_intraday_1min[date <= as_date('2016-12-31')]
saveRDS(mds_ets_MNN_intraday_1min_1y, paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1min_1y.rds'))
## Get all intraday files.
fls <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_960_1.p_[0-9]{0,}.[0-9]{4}|^ts_ets_MNN_840_1.p_[0-9]{0,}.[0-9]{4}|^ts_ets_MNN_720_1.p_[0-9]{0,}.[0-9]{4}|^ts_ets_MNN_600_1.p_[0-9]{0,}.[0-9]{4}') %>%
sort
#'2016-02-14'
fls_pth <- paste0(.dtr, 'data/fx/USDJPY/intraday/', fls)
mds_ets_MNN_intraday2_1min <- ldply(1:length(fls), function(i) {
nms <- fls[i] %>%
str_replace_all('.rds', '') %>%
str_split('_|\\.') %>%
.[[1]]
nms <- nms[-6]
names(nms) <- c('t_series', 'model', 'sub_model',
'data_min', 'fc_min', 'part', 'date')
datset2 <- t(nms) %>%
data.frame %>%
mutate(model =factor(model), sub_model = factor(sub_model),
data_min = as.numeric(data_min),
fc_min = as.numeric(fc_min),
part = as.numeric(part),
date = as_date(date))
datset <- read_rds(fls_pth[i])
res <- tibble(datset2, datset) %>%
dplyr::select(index, t_series, model, sub_model, data_min,
fc_min, part, date, mk.price, fc.price)
res <- res[!is.na('mk.price'),]
cat(i, '/', length(fls), '=', nms, '\n')
return(res)
}) %>%
as_tibble
## https://tysonbarrett.com/jekyll/update/2019/10/06/datatable_memory/
## http://brooksandrew.github.io/simpleblog/articles/advanced-data-table/
## https://atrebas.github.io/post/2019-03-03-datatable-dplyr/
mds_ets_MNN_intraday2_1min %<>% arrange(index, data_min)
saveRDS(mds_ets_MNN_intraday2_1min, paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday2_1min.rds'))
#ts_ets_MNN_960_1.p_277.2016-06-14
#ts_ets_MNN_840_1.p_1316.2016-06-14
#ts_ets_MNN_720_1.p_103.2016-06-13
#ts_ets_MNN_600_1.p_839.2016-05-06
mds_ets_MNN_intraday2_1min_1y <- mds_ets_MNN_intraday2_1min[date <= as_date('2016-12-31')]
saveRDS(mds_ets_MNN_intraday2_1min_1y, paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday2_1min_1y.rds'))
rm(list = ls())
if(!exists('mds_ets_MNN_intraday_1min_1y')) {
mds_ets_MNN_intraday_1min_1y <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday_1min_1y.rds')) }
if(!exists('mds_ets_MNN_intraday2_1min_1y')) {
mds_ets_MNN_intraday2_1min_1y <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday2_1min_1y.rds')) }
mds_ets_MNN_intraday3_1min_1y <- rbind(mds_ets_MNN_intraday_1min_1y, mds_ets_MNN_intraday2_1min_1y)
saveRDS(mds_ets_MNN_intraday3_1min_1y, paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y.rds'))
mds_ets_MNN_intraday3_1min_1y <- readRDS(paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y.rds'))
mds_ets_MNN_intraday3_1min_1y_cmp <- mds_ets_MNN_intraday3_1min_1y %>%
#tidyr::unite(model, t_series:part) %>%
tidyr::unite(model, t_series:fc_min) %>%
as.data.table %>%
.[, .(index, model, mk.price, fc.price)] %>% as.data.table
mds_ets_MNN_intraday3_1min_1y_cmp <- as.data.table(mds_ets_MNN_intraday3_1min_1y_cmp)
## ----------------------------------------
## fromLast = FALSE
mds_ets_MNN_intraday3_1min_1y_cmp_fLF <- unique(
mds_ets_MNN_intraday3_1min_1y_cmp[, .(index, model, mk.price, fc.price)], fromLast = FALSE)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday3_1min_1y_cmp_fLF,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y_cmp_fLF.rds'))
## ----------------------------------------
## fromLast = TRUE
mds_ets_MNN_intraday3_1min_1y_cmp_fLT <- unique(
mds_ets_MNN_intraday3_1min_1y_cmp[, .(index, model, mk.price, fc.price)], fromLast = TRUE)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday3_1min_1y_cmp_fLT,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y_cmp_fLT.rds'))
## ----------------------------------------
## convert to long format for plot chart
## fromLast = FALSE
prc <- unique(mds_ets_MNN_intraday3_1min_1y_cmp[, .(index, model, mk.price)], fromLast = FALSE)
prc <- prc[, model := 'actual'][]
setnames(prc, old = 'mk.price', new = 'price')
prc <- unique(prc, fromLast = FALSE)
mds_ets_MNN_intraday3_1min_1y_grph <- unique(
mds_ets_MNN_intraday3_1min_1y_cmp[, .(index, model, fc.price)], fromLast = FALSE)
setnames(mds_ets_MNN_intraday3_1min_1y_grph, old = 'fc.price', new = 'price')
mds_ets_MNN_intraday3_1min_1y_grph <- rbind(mds_ets_MNN_intraday3_1min_1y_grph, prc)
mds_ets_MNN_intraday3_1min_1y_grph_fLF <- data.table(mds_ets_MNN_intraday3_1min_1y_grph)[order(index)]
rm(prc)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday3_1min_1y_grph_fLF,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y_grph_fLF.rds'))
## ----------------------------------------
## fromLast = TRUE
prc <- unique(mds_ets_MNN_intraday3_1min_1y_cmp[, .(index, model, mk.price)], fromLast = TRUE)
prc <- prc[, model := 'actual'][]
setnames(prc, old = 'mk.price', new = 'price')
prc <- unique(prc, fromLast = TRUE)
mds_ets_MNN_intraday3_1min_1y_grph <- unique(
mds_ets_MNN_intraday3_1min_1y_cmp[, .(index, model, fc.price)], fromLast = TRUE)
setnames(mds_ets_MNN_intraday3_1min_1y_grph, old = 'fc.price', new = 'price')
mds_ets_MNN_intraday3_1min_1y_grph <- rbind(mds_ets_MNN_intraday3_1min_1y_grph, prc)
mds_ets_MNN_intraday3_1min_1y_grph_fLT <- data.table(mds_ets_MNN_intraday3_1min_1y_grph)[order(index)]
rm(prc)
## save dataset in data.table format
saveRDS(mds_ets_MNN_intraday3_1min_1y_grph_fLT,
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y_grph_fLT.rds'))
if(!exists('mds_ets_MNN_intraday3_1min_1y')) {
mds_ets_MNN_intraday3_1min_1y <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y.rds')) }
## plot sample data
mds_ets_MNN_intraday3_1min_1y[c(1:3, (nrow(mds_ets_MNN_intraday3_1min_1y)-3):nrow(mds_ets_MNN_intraday3_1min_1y)),] %>%
kbl(caption = '1 Year Data Sample (ETS MNN intraday forecast 1min)', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
## https://public.tableau.com/en-us/gallery/100-color-palettes?gallery=votd
row_spec(0, background = 'DimGrey', color = 'gold', bold = TRUE) %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = 'Gray') %>%
column_spec(3, background = 'DarkGrey') %>%
column_spec(4, background = 'Gray') %>%
column_spec(5, background = 'DarkGrey') %>%
column_spec(6, background = '#4897D8') %>%
column_spec(7, background = '#375E97') %>%
column_spec(8, background = 'CornflowerBlue') %>%
column_spec(9, background = 'Gainsboro', color = 'goldenrod') %>%
column_spec(10, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>% ##`full_width = FALSE` will auto adjust every single columns width to fit the table full width.
scroll_box(width = '100%', fixed_thead = TRUE, height = '400px')
| .id | index | t_series | model | sub_model | data_min | fc_min | part | date | mk.price | fc.price |
|---|---|---|---|---|---|---|---|---|---|---|
| 180 | 2016-01-04 00:02:00 | ts | ets | MNN | 180 | 1 | 1 | 2016-01-04 | 120.2200 | 120.2104 |
| 180 | 2016-01-04 00:03:00 | ts | ets | MNN | 180 | 1 | 2 | 2016-01-04 | 120.2200 | 120.2200 |
| 180 | 2016-01-04 00:04:00 | ts | ets | MNN | 180 | 1 | 3 | 2016-01-04 | 120.2185 | 120.2200 |
| 1200 | 2016-12-31 23:57:00 | ts | ets | MNN | 1200 | 1 | 1437 | 2016-12-31 | 117.0270 | 117.0270 |
| 1200 | 2016-12-31 23:58:00 | ts | ets | MNN | 1200 | 1 | 1438 | 2016-12-31 | 117.0270 | 117.0270 |
| 1200 | 2016-12-31 23:59:00 | ts | ets | MNN | 1200 | 1 | 1439 | 2016-12-31 | 117.0270 | 117.0270 |
| 1200 | 2017-01-01 00:00:00 | ts | ets | MNN | 1200 | 1 | 1440 | 2017-01-01 | 117.0270 | 117.0270 |
source : 3742909 x 11
There has a small mistake in previous paper Deriv.com - Interday High Frequency Trading Models Comparison Review (Part I) but doesn’t affect since I only want to compare the models and here I use the same MNN model and filter unique(fromLast = FALSE) and unique(fromLast = TRUE).
if(!exists('mds_ets_MNN_intraday3_1min_1y_grph_fLF')) {
mds_ets_MNN_intraday3_1min_1y_grph_fLF <- readRDS(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y_grph_fLF.rds')) }
if(!exists('mds_ets_MNN_intraday3_1min_1y_grph_fLT')) {
mds_ets_MNN_intraday3_1min_1y_grph_fLT <- readRDS(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y_grph_fLT.rds')) }
data.frame(mds_ets_MNN_intraday3_1min_1y_grph_fLF)[
c(1:5, (nrow(mds_ets_MNN_intraday3_1min_1y_grph_fLF)-5):nrow(mds_ets_MNN_intraday3_1min_1y_grph_fLF)),] %>%
kbl(caption = '1 Year Data Sample', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = 'grey') %>%
column_spec(3, background = '#556DAC') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| index | model | price | |
|---|---|---|---|
| 1 | 2016-01-04 00:01:00 | ts_ets_MNN_360_1 | 120.2080 |
| 2 | 2016-01-04 00:01:00 | actual | 120.2200 |
| 3 | 2016-01-04 00:02:00 | ts_ets_MNN_180_1 | 120.2104 |
| 4 | 2016-01-04 00:02:00 | ts_ets_MNN_240_1 | 120.2104 |
| 5 | 2016-01-04 00:02:00 | ts_ets_MNN_360_1 | 120.2104 |
| 4117208 | 2016-12-31 23:59:00 | ts_ets_MNN_1080_1 | 117.0270 |
| 4117209 | 2016-12-31 23:59:00 | ts_ets_MNN_1200_1 | 117.0270 |
| 4117210 | 2016-12-31 23:59:00 | actual | 117.0270 |
| 4117211 | 2017-01-01 00:00:00 | ts_ets_MNN_1080_1 | 117.0270 |
| 4117212 | 2017-01-01 00:00:00 | ts_ets_MNN_1200_1 | 117.0270 |
| 4117213 | 2017-01-01 00:00:00 | actual | 117.0270 |
source : 4117213 x 3
data.frame(mds_ets_MNN_intraday3_1min_1y_grph_fLT)[
c(1:6, (nrow(mds_ets_MNN_intraday3_1min_1y_grph_fLT)-5):nrow(mds_ets_MNN_intraday3_1min_1y_grph_fLT)),] %>%
kbl(caption = '1 Year Data Sample', escape = FALSE) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = 'grey') %>%
column_spec(3, background = '#556DAC') %>%
column_spec(4, background = 'LightGray', color = 'goldenrod') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| index | model | price | |
|---|---|---|---|
| 1 | 2016-01-04 00:01:00 | ts_ets_MNN_360_1 | 120.2080 |
| 2 | 2016-01-04 00:01:00 | actual | 120.2200 |
| 3 | 2016-01-04 00:02:00 | ts_ets_MNN_180_1 | 120.2104 |
| 4 | 2016-01-04 00:02:00 | ts_ets_MNN_240_1 | 120.2104 |
| 5 | 2016-01-04 00:02:00 | ts_ets_MNN_360_1 | 120.2104 |
| 6 | 2016-01-04 00:02:00 | ts_ets_MNN_480_1 | 120.2104 |
| 4117208 | 2016-12-31 23:59:00 | ts_ets_MNN_1080_1 | 117.0270 |
| 4117209 | 2016-12-31 23:59:00 | ts_ets_MNN_1200_1 | 117.0270 |
| 4117210 | 2016-12-31 23:59:00 | actual | 117.0270 |
| 4117211 | 2017-01-01 00:00:00 | ts_ets_MNN_1080_1 | 117.0270 |
| 4117212 | 2017-01-01 00:00:00 | ts_ets_MNN_1200_1 | 117.0270 |
| 4117213 | 2017-01-01 00:00:00 | actual | 117.0270 |
source : 4117213 x 3
unique(x, fromLast = FALSE) Dataset## https://www.r-graph-gallery.com/line-chart-several-groups-ggplot2.html
plt <- mds_ets_MNN_intraday3_1min_1y_grph_fLF %>%
ggplot(aes(x = index, y = price, group = model, color = model)) +
geom_line() +
labs(title = '1 min Open Price Forecasting',
subtitle = paste('From', range(unique(mds_ets_MNN_intraday3_1min_1y_grph_fLF$index))[1L],
'to', range(unique(mds_ets_MNN_intraday3_1min_1y_grph_fLF$index))[2L]),
caption = "Data source: fxcm") +
ylab('Exchange Rates USD/JPY') +
theme_economist() +
theme(legend.position = 'right')
#ggplotly(plt)
plt
Due to the high volume of data, here I skip the line chart.
unique(x, fromLast = TRUE) Dataset## https://www.r-graph-gallery.com/line-chart-several-groups-ggplot2.html
plt <- mds_ets_MNN_intraday3_1min_1y_grph_fLT %>%
ggplot(aes(x = index, y = price, group = model, color = model)) +
geom_line() +
labs(title = '1 min Open Price Forecasting',
subtitle = paste('From', range(unique(mds_ets_MNN_intraday3_1min_1y_grph_fLT$index))[1L],
'to', range(unique(mds_ets_MNN_intraday3_1min_1y_grph_fLT$index))[2L]),
caption = "Data source: fxcm") +
ylab('Exchange Rates USD/JPY') +
theme_economist() +
theme(legend.position = 'right')
#ggplotly(plt)
plt
Due to the high volume of data, here I skip the line chart.
unique(x, fromLast = FALSE) DatasetBelow table compares the models.
rm(list = ls())
## report for mds_ets_MNN_intraday3_1min_1y_cmp_fLF
if(!exists('mds_ets_MNN_intraday3_1min_1y_cmp_fLF')) {
mds_ets_MNN_intraday3_1min_1y_cmp_fLF <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y_cmp_fLF.rds')) }
if(!is.data.table('mds_ets_MNN_intraday3_1min_1y_cmp_fLF')) {
mds_ets_MNN_intraday3_1min_1y_cmp_fLF %<>% as.data.table }
mds_ets_MNN_intraday3_1min_1y_cmp_fLF <- unique(
mds_ets_MNN_intraday3_1min_1y_cmp_fLF, fromLast = FALSE, by = c('index', 'model')) %>%
na.omit
rp3_1min_1y_fLF <- mds_ets_MNN_intraday3_1min_1y_cmp_fLF[, {
mk.price = mk.price
fc.price = fc.price
.SD[, .(.N,
mae = MLmetrics::MAE(y_true = mk.price, y_pred = fc.price),
mape = MLmetrics::MAPE(y_true = mk.price, y_pred = fc.price),
rmse = MLmetrics::RMSE(y_true = mk.price, y_pred = fc.price),
smape = Metrics::smape(actual = mk.price, predicted = fc.price),
mse = MLmetrics::MSE(y_true = mk.price, y_pred = fc.price)),
by=.(model)]}][order(model), ]
## report
saveRDS(rp3_1min_1y_fLF, paste0(.dtr, 'data/fx/USDJPY/rp3_1min_1y_fLF.rds'))
rp3_1min_1y_fLF <- readRDS(paste0(.dtr, 'data/fx/USDJPY/rp3_1min_1y_fLF.rds'))
rp3_1min_1y_tbl <- rp3_1min_1y_fLF %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Accurcy Report (1 Year Dataset Intraday Forecasted 1 min)', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
#column_spec(1, background = 'CornflowerBlue') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'LightSlateGrey') %>%
column_spec(3, background = 'Gainsboro') %>%
column_spec(4, background = 'LightGray') %>%
column_spec(5, background = 'Gainsboro') %>%
column_spec(6, background = 'LightGray') %>%
column_spec(7, background = 'Gainsboro') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
##`full_width = FALSE` will auto adjust every single columns width to fit the table full width.
scroll_box(width = '100%', fixed_thead = TRUE, height = '400px')
rp3_1min_1y_tbl
| model | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|
| ts_ets_MNN_1080_1 | 374296 | 0.0135525 (rank: 2) | 0.0001246 (rank: 2) | 0.0233866 (rank: 2) | 0.0001246 (rank: 2) | 0.0005469 (rank: 2) |
| ts_ets_MNN_1200_1 | 374296 | 0.0135521 (rank: 1) | 0.0001246 (rank: 1) | 0.0233844 (rank: 1) | 0.0001246 (rank: 1) | 0.0005468 (rank: 1) |
| ts_ets_MNN_180_1 | 374295 | 0.0135795 (rank: 10) | 0.0001248 (rank: 10) | 0.0234633 (rank: 10) | 0.0001248 (rank: 10) | 0.0005505 (rank: 10) |
| ts_ets_MNN_240_1 | 374295 | 0.0135735 (rank: 9) | 0.0001248 (rank: 9) | 0.0234467 (rank: 9) | 0.0001248 (rank: 9) | 0.0005497 (rank: 9) |
| ts_ets_MNN_360_1 | 374267 | 0.0135653 (rank: 8) | 0.0001247 (rank: 8) | 0.0234235 (rank: 8) | 0.0001247 (rank: 8) | 0.0005487 (rank: 8) |
| ts_ets_MNN_480_1 | 374275 | 0.0135592 (rank: 7) | 0.0001247 (rank: 7) | 0.0234082 (rank: 7) | 0.0001247 (rank: 7) | 0.0005479 (rank: 7) |
| ts_ets_MNN_600_1 | 374296 | 0.0135569 (rank: 6) | 0.0001246 (rank: 6) | 0.0234 (rank: 6) | 0.0001246 (rank: 6) | 0.0005476 (rank: 6) |
| ts_ets_MNN_720_1 | 374297 | 0.013556 (rank: 5) | 0.0001246 (rank: 5) | 0.0233952 (rank: 5) | 0.0001246 (rank: 5) | 0.0005473 (rank: 5) |
| ts_ets_MNN_840_1 | 374297 | 0.0135551 (rank: 4) | 0.0001246 (rank: 4) | 0.0233913 (rank: 4) | 0.0001246 (rank: 4) | 0.0005472 (rank: 4) |
| ts_ets_MNN_960_1 | 374295 | 0.0135531 (rank: 3) | 0.0001246 (rank: 3) | 0.0233885 (rank: 3) | 0.0001246 (rank: 3) | 0.000547 (rank: 3) |
source :
from above models we know the βest model.
unique(x, fromLast = TRUE) DatasetBelow table compares the models.
rm(list = ls())
## report for mds_ets_MNN_intraday_1min_1y_cmp_fLT
if(!exists('mds_ets_MNN_intraday3_1min_1y_cmp_fLT')) {
mds_ets_MNN_intraday3_1min_1y_cmp_fLT <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/mds_ets_MNN_intraday3_1min_1y_cmp_fLT.rds')) }
if(!is.data.table('mds_ets_MNN_intraday3_1min_1y_cmp_fLT')) {
mds_ets_MNN_intraday3_1min_1y_cmp_fLT %<>% as.data.table }
mds_ets_MNN_intraday3_1min_1y_cmp_fLT <- unique(
mds_ets_MNN_intraday3_1min_1y_cmp_fLT, fromLast = TRUE, by = c('index', 'model')) %>%
na.omit
rp3_1min_1y_fLT <- mds_ets_MNN_intraday3_1min_1y_cmp_fLT[, {
mk.price = mk.price
fc.price = fc.price
.SD[, .(.N,
mae = MLmetrics::MAE(y_true = mk.price, y_pred = fc.price),
mape = MLmetrics::MAPE(y_true = mk.price, y_pred = fc.price),
rmse = MLmetrics::RMSE(y_true = mk.price, y_pred = fc.price),
smape = Metrics::smape(actual = mk.price, predicted = fc.price),
mse = MLmetrics::MSE(y_true = mk.price, y_pred = fc.price)),
by=.(model)]}][order(model), ]
## report
saveRDS(rp3_1min_1y_fLT, paste0(.dtr, 'data/fx/USDJPY/rp3_1min_1y_fLT.rds'))
rp3_1min_1y_fLT <- readRDS(paste0(.dtr, 'data/fx/USDJPY/rp3_1min_1y_fLT.rds'))
rp3_1min_1y_tbl <- rp3_1min_1y_fLT %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Accurcy Report (1 Year Dataset Intraday Forecasted 1 mins)', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
#column_spec(1, background = 'CornflowerBlue') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'LightSlateGrey') %>%
column_spec(3, background = 'Gainsboro') %>%
column_spec(4, background = 'LightGray') %>%
column_spec(5, background = 'Gainsboro') %>%
column_spec(6, background = 'LightGray') %>%
column_spec(7, background = 'Gainsboro') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
##`full_width = FALSE` will auto adjust every single columns width to fit the table full width.
scroll_box(width = '100%', fixed_thead = TRUE, height = '400px')
rp3_1min_1y_tbl
| model | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|
| ts_ets_MNN_1080_1 | 374296 | 0.0135525 (rank: 2) | 0.0001246 (rank: 2) | 0.0233866 (rank: 2) | 0.0001246 (rank: 2) | 0.0005469 (rank: 2) |
| ts_ets_MNN_1200_1 | 374296 | 0.0135521 (rank: 1) | 0.0001246 (rank: 1) | 0.0233844 (rank: 1) | 0.0001246 (rank: 1) | 0.0005468 (rank: 1) |
| ts_ets_MNN_180_1 | 374295 | 0.0135795 (rank: 10) | 0.0001248 (rank: 10) | 0.0234633 (rank: 10) | 0.0001248 (rank: 10) | 0.0005505 (rank: 10) |
| ts_ets_MNN_240_1 | 374295 | 0.0135735 (rank: 9) | 0.0001248 (rank: 9) | 0.0234467 (rank: 9) | 0.0001248 (rank: 9) | 0.0005497 (rank: 9) |
| ts_ets_MNN_360_1 | 374267 | 0.0135653 (rank: 8) | 0.0001247 (rank: 8) | 0.0234235 (rank: 8) | 0.0001247 (rank: 8) | 0.0005487 (rank: 8) |
| ts_ets_MNN_480_1 | 374275 | 0.0135592 (rank: 7) | 0.0001247 (rank: 7) | 0.0234082 (rank: 7) | 0.0001247 (rank: 7) | 0.0005479 (rank: 7) |
| ts_ets_MNN_600_1 | 374296 | 0.0135569 (rank: 6) | 0.0001246 (rank: 6) | 0.0234 (rank: 6) | 0.0001246 (rank: 6) | 0.0005476 (rank: 6) |
| ts_ets_MNN_720_1 | 374297 | 0.013556 (rank: 5) | 0.0001246 (rank: 5) | 0.0233952 (rank: 5) | 0.0001246 (rank: 5) | 0.0005473 (rank: 5) |
| ts_ets_MNN_840_1 | 374297 | 0.0135551 (rank: 4) | 0.0001246 (rank: 4) | 0.0233913 (rank: 4) | 0.0001246 (rank: 4) | 0.0005472 (rank: 4) |
| ts_ets_MNN_960_1 | 374295 | 0.0135531 (rank: 3) | 0.0001246 (rank: 3) | 0.0233885 (rank: 3) | 0.0001246 (rank: 3) | 0.000547 (rank: 3) |
source :
from above models we know the βest model.
rm(list = ls())
## report for rp_1y_fLF and
if(!exists('rp_1y_fLF')) {
rp_1y_fLF <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp_1y_fLF.rds')) %>%
as.data.table }
## report for rp_1y_fLT and
if(!exists('rp_1y_fLT')) {
rp_1y_fLT <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp_1y_fLT.rds')) %>%
as.data.table }
## report for rp_1min_1y_fLF and
if(!exists('rp3_1min_1y_fLF')) {
rp3_1min_1y_fLF <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp3_1min_1y_fLF.rds')) %>%
as.data.table }
## report for rp_1min_1y_fLT and
if(!exists('rp3_1min_1y_fLT')) {
rp3_1min_1y_fLT <- read_rds(
paste0(.dtr, 'data/fx/USDJPY/rp3_1min_1y_fLT.rds')) %>%
as.data.table }
rp_1y_fLF <- rp_1y_fLF[, arrange := 'from_first'][]
rp_1y_fLT <- rp_1y_fLT[, arrange := 'from_last'][]
rp3_1min_1y_fLF <- rp3_1min_1y_fLF[, arrange := 'from_first'][]
rp3_1min_1y_fLT <- rp3_1min_1y_fLT[, arrange := 'from_last'][]
rp_1min_1y <- rbindlist(list(rp_1y_fLF, rp_1y_fLT, rp3_1min_1y_fLF, rp3_1min_1y_fLT))
rp_1min_1y <- rp_1min_1y[, .(model, arrange, N, mae, mape, rmse, smape, mse)]
rp_1min_1y %<>% unique
#sum <- rp_1min_1y[mae == min(mae) | mape == min(mape) | rmse == min(rmse) | smape == min(smape) | mse == min(mse)]
rp_1min_1y %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Accurcy Report (1 Year Dataset Initial Stage Comparison)', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
#column_spec(1, background = 'CornflowerBlue') %>%
column_spec(1, background = '#556DAC') %>%
column_spec(2, background = 'grey') %>%
column_spec(3, background = 'LightSlateGrey') %>%
column_spec(4, background = 'Gainsboro') %>%
column_spec(5, background = 'LightGray') %>%
column_spec(6, background = 'Gainsboro') %>%
column_spec(7, background = 'LightGray') %>%
column_spec(8, background = 'Gainsboro') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| model | arrange | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|---|
| ts_ets_MNN_1440_1 | from_first | 374398 | 0.0135726 (rank: 18) | 0.0001248 (rank: 18) | 0.0235634 (rank: 22) | 0.0001248 (rank: 18) | 0.0005552 (rank: 22) |
| ts_ets_MNN_1440_10 | from_first | 374400 | 0.0310264 (rank: 28) | 0.0002852 (rank: 28) | 0.0535552 (rank: 28) | 0.0002852 (rank: 28) | 0.0028682 (rank: 28) |
| ts_ets_MNN_1440_120 | from_first | 374400 | 0.1046746 (rank: 38) | 0.0009631 (rank: 38) | 0.1716097 (rank: 38) | 0.000963 (rank: 38) | 0.0294499 (rank: 38) |
| ts_ets_MNN_1440_15 | from_first | 374400 | 0.0373874 (rank: 30) | 0.0003437 (rank: 30) | 0.064235 (rank: 30) | 0.0003437 (rank: 30) | 0.0041261 (rank: 30) |
| ts_ets_MNN_1440_180 | from_first | 374400 | 0.129417 (rank: 40) | 0.0011914 (rank: 40) | 0.2116718 (rank: 40) | 0.0011911 (rank: 40) | 0.044805 (rank: 40) |
| ts_ets_MNN_1440_20 | from_first | 374400 | 0.0427459 (rank: 32) | 0.0003931 (rank: 32) | 0.0730338 (rank: 32) | 0.0003931 (rank: 32) | 0.0053339 (rank: 32) |
| ts_ets_MNN_1440_240 | from_first | 374400 | 0.148679 (rank: 42) | 0.0013704 (rank: 42) | 0.245548 (rank: 42) | 0.00137 (rank: 42) | 0.0602938 (rank: 42) |
| ts_ets_MNN_1440_30 | from_first | 374400 | 0.0524834 (rank: 34) | 0.0004828 (rank: 34) | 0.0890827 (rank: 34) | 0.0004827 (rank: 34) | 0.0079357 (rank: 34) |
| ts_ets_MNN_1440_360 | from_first | 374400 | 0.1784428 (rank: 44) | 0.0016443 (rank: 44) | 0.2897381 (rank: 44) | 0.0016439 (rank: 44) | 0.0839482 (rank: 44) |
| ts_ets_MNN_1440_480 | from_first | 374400 | 0.2263737 (rank: 46) | 0.0020871 (rank: 46) | 0.3521562 (rank: 46) | 0.0020863 (rank: 46) | 0.124014 (rank: 46) |
| ts_ets_MNN_1440_6 | from_first | 374400 | 0.0247197 (rank: 24) | 0.0002272 (rank: 24) | 0.0428744 (rank: 24) | 0.0002272 (rank: 24) | 0.0018382 (rank: 24) |
| ts_ets_MNN_1440_60 | from_first | 374400 | 0.0738649 (rank: 36) | 0.0006797 (rank: 36) | 0.1238921 (rank: 36) | 0.0006796 (rank: 36) | 0.0153493 (rank: 36) |
| ts_ets_MNN_1440_720 | from_first | 374400 | 0.2755691 (rank: 48) | 0.0025449 (rank: 48) | 0.4395358 (rank: 50) | 0.0025432 (rank: 48) | 0.1931917 (rank: 50) |
| ts_ets_MNN_1440_8 | from_first | 374400 | 0.0281814 (rank: 26) | 0.0002591 (rank: 26) | 0.0494359 (rank: 26) | 0.0002591 (rank: 26) | 0.0024439 (rank: 26) |
| ts_ets_MNN_7200_1440 | from_first | 374400 | 0.4072728 (rank: 52) | 0.0037581 (rank: 52) | 0.6228677 (rank: 52) | 0.0037537 (rank: 52) | 0.3879641 (rank: 52) |
| ts_ets_MNN_7200_720 | from_first | 374400 | 0.275585 (rank: 50) | 0.0025451 (rank: 50) | 0.4395006 (rank: 48) | 0.0025434 (rank: 50) | 0.1931608 (rank: 48) |
| ts_ets_MNN_1440_1 | from_last | 374398 | 0.0135726 (rank: 18) | 0.0001248 (rank: 18) | 0.0235634 (rank: 22) | 0.0001248 (rank: 18) | 0.0005552 (rank: 22) |
| ts_ets_MNN_1440_10 | from_last | 374400 | 0.0310264 (rank: 28) | 0.0002852 (rank: 28) | 0.0535552 (rank: 28) | 0.0002852 (rank: 28) | 0.0028682 (rank: 28) |
| ts_ets_MNN_1440_120 | from_last | 374400 | 0.1046746 (rank: 38) | 0.0009631 (rank: 38) | 0.1716097 (rank: 38) | 0.000963 (rank: 38) | 0.0294499 (rank: 38) |
| ts_ets_MNN_1440_15 | from_last | 374400 | 0.0373874 (rank: 30) | 0.0003437 (rank: 30) | 0.064235 (rank: 30) | 0.0003437 (rank: 30) | 0.0041261 (rank: 30) |
| ts_ets_MNN_1440_180 | from_last | 374400 | 0.129417 (rank: 40) | 0.0011914 (rank: 40) | 0.2116718 (rank: 40) | 0.0011911 (rank: 40) | 0.044805 (rank: 40) |
| ts_ets_MNN_1440_20 | from_last | 374400 | 0.0427459 (rank: 32) | 0.0003931 (rank: 32) | 0.0730338 (rank: 32) | 0.0003931 (rank: 32) | 0.0053339 (rank: 32) |
| ts_ets_MNN_1440_240 | from_last | 374400 | 0.148679 (rank: 42) | 0.0013704 (rank: 42) | 0.245548 (rank: 42) | 0.00137 (rank: 42) | 0.0602938 (rank: 42) |
| ts_ets_MNN_1440_30 | from_last | 374400 | 0.0524834 (rank: 34) | 0.0004828 (rank: 34) | 0.0890827 (rank: 34) | 0.0004827 (rank: 34) | 0.0079357 (rank: 34) |
| ts_ets_MNN_1440_360 | from_last | 374400 | 0.1784428 (rank: 44) | 0.0016443 (rank: 44) | 0.2897381 (rank: 44) | 0.0016439 (rank: 44) | 0.0839482 (rank: 44) |
| ts_ets_MNN_1440_480 | from_last | 374400 | 0.2263737 (rank: 46) | 0.0020871 (rank: 46) | 0.3521562 (rank: 46) | 0.0020863 (rank: 46) | 0.124014 (rank: 46) |
| ts_ets_MNN_1440_6 | from_last | 374400 | 0.0247197 (rank: 24) | 0.0002272 (rank: 24) | 0.0428744 (rank: 24) | 0.0002272 (rank: 24) | 0.0018382 (rank: 24) |
| ts_ets_MNN_1440_60 | from_last | 374400 | 0.0738649 (rank: 36) | 0.0006797 (rank: 36) | 0.1238921 (rank: 36) | 0.0006796 (rank: 36) | 0.0153493 (rank: 36) |
| ts_ets_MNN_1440_720 | from_last | 374400 | 0.2755691 (rank: 48) | 0.0025449 (rank: 48) | 0.4395358 (rank: 50) | 0.0025432 (rank: 48) | 0.1931917 (rank: 50) |
| ts_ets_MNN_1440_8 | from_last | 374400 | 0.0281814 (rank: 26) | 0.0002591 (rank: 26) | 0.0494359 (rank: 26) | 0.0002591 (rank: 26) | 0.0024439 (rank: 26) |
| ts_ets_MNN_7200_1440 | from_last | 374400 | 0.4072728 (rank: 52) | 0.0037581 (rank: 52) | 0.6228677 (rank: 52) | 0.0037537 (rank: 52) | 0.3879641 (rank: 52) |
| ts_ets_MNN_7200_720 | from_last | 374400 | 0.275585 (rank: 50) | 0.0025451 (rank: 50) | 0.4395006 (rank: 48) | 0.0025434 (rank: 50) | 0.1931608 (rank: 48) |
| ts_ets_MNN_1080_1 | from_first | 374296 | 0.0135525 (rank: 4) | 0.0001246 (rank: 4) | 0.0233866 (rank: 4) | 0.0001246 (rank: 4) | 0.0005469 (rank: 4) |
| ts_ets_MNN_1200_1 | from_first | 374296 | 0.0135521 (rank: 2) | 0.0001246 (rank: 2) | 0.0233844 (rank: 2) | 0.0001246 (rank: 2) | 0.0005468 (rank: 2) |
| ts_ets_MNN_180_1 | from_first | 374295 | 0.0135795 (rank: 22) | 0.0001248 (rank: 22) | 0.0234633 (rank: 20) | 0.0001248 (rank: 22) | 0.0005505 (rank: 20) |
| ts_ets_MNN_240_1 | from_first | 374295 | 0.0135735 (rank: 20) | 0.0001248 (rank: 20) | 0.0234467 (rank: 18) | 0.0001248 (rank: 20) | 0.0005497 (rank: 18) |
| ts_ets_MNN_360_1 | from_first | 374267 | 0.0135653 (rank: 16) | 0.0001247 (rank: 16) | 0.0234235 (rank: 16) | 0.0001247 (rank: 16) | 0.0005487 (rank: 16) |
| ts_ets_MNN_480_1 | from_first | 374275 | 0.0135592 (rank: 14) | 0.0001247 (rank: 14) | 0.0234082 (rank: 14) | 0.0001247 (rank: 14) | 0.0005479 (rank: 14) |
| ts_ets_MNN_600_1 | from_first | 374296 | 0.0135569 (rank: 12) | 0.0001246 (rank: 12) | 0.0234 (rank: 12) | 0.0001246 (rank: 12) | 0.0005476 (rank: 12) |
| ts_ets_MNN_720_1 | from_first | 374297 | 0.013556 (rank: 10) | 0.0001246 (rank: 10) | 0.0233952 (rank: 10) | 0.0001246 (rank: 10) | 0.0005473 (rank: 10) |
| ts_ets_MNN_840_1 | from_first | 374297 | 0.0135551 (rank: 8) | 0.0001246 (rank: 8) | 0.0233913 (rank: 8) | 0.0001246 (rank: 8) | 0.0005472 (rank: 8) |
| ts_ets_MNN_960_1 | from_first | 374295 | 0.0135531 (rank: 6) | 0.0001246 (rank: 6) | 0.0233885 (rank: 6) | 0.0001246 (rank: 6) | 0.000547 (rank: 6) |
| ts_ets_MNN_1080_1 | from_last | 374296 | 0.0135525 (rank: 4) | 0.0001246 (rank: 4) | 0.0233866 (rank: 4) | 0.0001246 (rank: 4) | 0.0005469 (rank: 4) |
| ts_ets_MNN_1200_1 | from_last | 374296 | 0.0135521 (rank: 2) | 0.0001246 (rank: 2) | 0.0233844 (rank: 2) | 0.0001246 (rank: 2) | 0.0005468 (rank: 2) |
| ts_ets_MNN_180_1 | from_last | 374295 | 0.0135795 (rank: 22) | 0.0001248 (rank: 22) | 0.0234633 (rank: 20) | 0.0001248 (rank: 22) | 0.0005505 (rank: 20) |
| ts_ets_MNN_240_1 | from_last | 374295 | 0.0135735 (rank: 20) | 0.0001248 (rank: 20) | 0.0234467 (rank: 18) | 0.0001248 (rank: 20) | 0.0005497 (rank: 18) |
| ts_ets_MNN_360_1 | from_last | 374267 | 0.0135653 (rank: 16) | 0.0001247 (rank: 16) | 0.0234235 (rank: 16) | 0.0001247 (rank: 16) | 0.0005487 (rank: 16) |
| ts_ets_MNN_480_1 | from_last | 374275 | 0.0135592 (rank: 14) | 0.0001247 (rank: 14) | 0.0234082 (rank: 14) | 0.0001247 (rank: 14) | 0.0005479 (rank: 14) |
| ts_ets_MNN_600_1 | from_last | 374296 | 0.0135569 (rank: 12) | 0.0001246 (rank: 12) | 0.0234 (rank: 12) | 0.0001246 (rank: 12) | 0.0005476 (rank: 12) |
| ts_ets_MNN_720_1 | from_last | 374297 | 0.013556 (rank: 10) | 0.0001246 (rank: 10) | 0.0233952 (rank: 10) | 0.0001246 (rank: 10) | 0.0005473 (rank: 10) |
| ts_ets_MNN_840_1 | from_last | 374297 | 0.0135551 (rank: 8) | 0.0001246 (rank: 8) | 0.0233913 (rank: 8) | 0.0001246 (rank: 8) | 0.0005472 (rank: 8) |
| ts_ets_MNN_960_1 | from_last | 374295 | 0.0135531 (rank: 6) | 0.0001246 (rank: 6) | 0.0233885 (rank: 6) | 0.0001246 (rank: 6) | 0.000547 (rank: 6) |
source : 52 x 8
sum <- rp_1min_1y[mae == min(mae) | mape == min(mape) | rmse == min(rmse) | smape == min(smape) | mse == min(mse)]
sum %>%
dplyr::mutate(
mae = ifelse(
rank(mae) <= 3,
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mae, 7), ' (rank: ', sprintf('%1.f', rank(mae)), ')'),
color = 'grey', italic = TRUE)),
mape = ifelse(
rank(mape) <= 3,
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mape, 7), ' (rank: ', sprintf('%1.f', rank(mape)), ')'),
color = 'grey', italic = TRUE)),
rmse = ifelse(
rank(rmse) <= 3,
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(rmse, 7), ' (rank: ', sprintf('%1.f', rank(rmse)), ')'),
color = 'grey', italic = TRUE)),
smape = ifelse(
rank(smape) <= 3,
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(smape, 7), ' (rank: ', sprintf('%1.f', rank(smape)), ')'),
color = 'grey', italic = TRUE)),
mse = ifelse(
rank(mse) <= 3,
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'darkgoldenrod', bold = TRUE),
cell_spec(
paste0(round(mse, 7), ' (rank: ', sprintf('%1.f', rank(mse)), ')'),
color = 'grey', italic = TRUE))) %>%
kbl(caption = 'Best Model', escape = FALSE) %>%
## https://www.w3schools.com/cssref/css_colors.asp
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue') %>%
column_spec(2, background = '#556DAC') %>%
column_spec(3, background = 'LightSlateGrey') %>%
column_spec(4, background = 'LightGray') %>%
column_spec(5, background = 'Gainsboro') %>%
column_spec(6, background = 'LightGray') %>%
column_spec(7, background = 'Gainsboro') %>%
column_spec(8, background = 'LightGray') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
kable_material(full_width = FALSE) %>%
scroll_box(width = '100%', fixed_thead = TRUE)
| model | arrange | N | mae | mape | rmse | smape | mse |
|---|---|---|---|---|---|---|---|
| ts_ets_MNN_1200_1 | from_first | 374296 | 0.0135521 (rank: 2) | 0.0001246 (rank: 2) | 0.0233844 (rank: 2) | 0.0001246 (rank: 2) | 0.0005468 (rank: 2) |
| ts_ets_MNN_1200_1 | from_last | 374296 | 0.0135521 (rank: 2) | 0.0001246 (rank: 2) | 0.0233844 (rank: 2) | 0.0001246 (rank: 2) | 0.0005468 (rank: 2) |
source : 2 x 8
From 4.2.3.2 Comparison between 1 Year & 3.5 Year Dataset, we can know the βest model based on the unique from_first dataset.
From table above, we know that ts_ets_MNN_1200_1 from_first is the βest model.
Next papers will compare tbats, midas, sarimax etc.
Deriv.com - Interday High Frequency Trading Models Comparison Review (Part III)
Beyond the future, will be publish Chinese Language thesis, there as a lot of online website language translator.
There has a small mistake in previous paper Deriv.com - Interday High Frequency Trading Models Comparison Review (Part I) but doesn’t affect since I only want to compare the models and here I use the same MNN model and filter unique(fromLast = FALSE) and unique(fromLast = TRUE).
It’s useful to record some information about how your file was created.
suppressMessages(require('dplyr', quietly = TRUE))
suppressMessages(require('magrittr', quietly = TRUE))
suppressMessages(require('formattable', quietly = TRUE))
suppressMessages(require('knitr', quietly = TRUE))
suppressMessages(require('kableExtra', quietly = TRUE))
sys1 <- devtools::session_info()$platform %>%
unlist %>% data.frame(Category = names(.), session_info = .)
rownames(sys1) <- NULL
sys2 <- data.frame(Sys.info()) %>%
dplyr::mutate(Category = rownames(.)) %>% .[2:1]
names(sys2)[2] <- c('Sys.info')
rownames(sys2) <- NULL
if (nrow(sys1) == 9 & nrow(sys2) == 8) {
sys2 %<>% rbind(., data.frame(
Category = 'Current time',
Sys.info = paste(as.character(lubridate::now('Asia/Tokyo')), 'JST🗾')))
} else {
sys1 %<>% rbind(., data.frame(
Category = 'Current time',
session_info = paste(as.character(lubridate::now('Asia/Tokyo')), 'JST🗾')))
}
sys <- cbind(sys1, sys2) %>%
kbl(caption = 'Additional session information:') %>%
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
column_spec(1, background = 'CornflowerBlue', color = 'red') %>%
column_spec(2, background = 'grey', color = 'black') %>%
column_spec(3, background = 'CornflowerBlue', color = 'blue') %>%
column_spec(4, background = 'grey', color = 'white') %>%
row_spec(9, bold = T, color = 'yellow', background = '#D7261E')
rm(sys1, sys2)
sys
| Category | session_info | Category | Sys.info |
|---|---|---|---|
| version | R version 4.0.5 (2021-03-31) | sysname | Windows |
| os | Windows 10 x64 | release | 10 x64 |
| system | x86_64, mingw32 | version | build 19042 |
| ui | RTerm | nodename | SCIBROKES-TRADI |
| language | (EN) | machine | x86-64 |
| collate | English_World.1252 | login | Owner |
| ctype | English_World.1252 | user | Owner |
| tz | Asia/Tokyo | effective_user | Owner |
| date | 2021-04-23 | Current time | 2021-04-23 21:21:36 JST<U+0001F5FE> |
ARCH in MeanARIMA(p,d,q)参数最优化Powered by - Copyright® Intellectual Property Rights of Sςιβrοκεrs Trαdιηg ®️ 経営企業