Skip to content

Commit b103d7a

Browse files
committed
update
1 parent 1af1c1d commit b103d7a

File tree

2 files changed

+110
-5
lines changed

2 files changed

+110
-5
lines changed

binary-Q1Inter-HFT-RV2.Rmd

+107
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,113 @@ if(exists('fl')) rm(fl)
18951895

18961896
## Intraday Seasonal Data
18971897

1898+
1899+
### 20Hr >> 1min
1900+
1901+
I set the length of data as Daily (`1200 mins` which is 1 trading days) to forecast `1 min` in advance.
1902+
1903+
```{r, eval = FALSE}
1904+
# --------- eval=FALSE ---------
1905+
ets.m <- 'MNN'
1906+
source('function/intra_min.R')
1907+
1908+
timeID <- unique(dsmp$date)
1909+
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
1910+
timeID %<>% .[. >= bse]
1911+
#timeID %<>% .[. >= as_date('2016-01-04')]
1912+
data_len <- 1200
1913+
hrz1 <- 1
1914+
1915+
llply(ets.m, function(md) {
1916+
intra_min(timeID = timeID, dsmp,
1917+
data_len = data_len, hrz1 = hrz1,
1918+
.model = md)
1919+
})
1920+
```
1921+
1922+
```{r 18hr-1min, warning = FALSE, message = FALSE, results = 'asis'}
1923+
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
1924+
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1200_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
1925+
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
1926+
1927+
if(all(is.na(fl))){
1928+
smp <- NA
1929+
1930+
} else {
1931+
smp <- ldply(fl, function(x) {
1932+
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
1933+
})
1934+
1935+
smp %>%
1936+
kbl(caption = 'Data Sample (ETS MNN 1200 forecast 1)', escape = FALSE) %>%
1937+
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
1938+
column_spec(1, background = '#556DAC') %>%
1939+
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
1940+
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
1941+
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
1942+
kable_material(full_width = FALSE) %>%
1943+
scroll_box(width = '100%', fixed_thead = TRUE)
1944+
}
1945+
```
1946+
1947+
```{r include = FALSE}
1948+
if(exists('smp')) rm(smp)
1949+
if(exists('fl')) rm(fl)
1950+
```
1951+
1952+
### 18Hr >> 1min
1953+
1954+
I set the length of data as Daily (`1080 mins` which is 1 trading days) to forecast `1 min` in advance.
1955+
1956+
```{r, eval = FALSE}
1957+
# --------- eval=FALSE ---------
1958+
ets.m <- 'MNN'
1959+
source('function/intra_min.R')
1960+
1961+
timeID <- unique(dsmp$date)
1962+
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
1963+
timeID %<>% .[. >= bse]
1964+
#timeID %<>% .[. >= as_date('2016-01-04')]
1965+
data_len <- 1080
1966+
hrz1 <- 1
1967+
1968+
llply(ets.m, function(md) {
1969+
intra_min(timeID = timeID, dsmp,
1970+
data_len = data_len, hrz1 = hrz1,
1971+
.model = md)
1972+
})
1973+
```
1974+
1975+
```{r 18hr-1min, warning = FALSE, message = FALSE, results = 'asis'}
1976+
#```{r, warning = FALSE, message = FALSE, results = 'asis'}
1977+
fl <- list.files(paste0(.dtr, 'data/fx/USDJPY/intraday/'), pattern = '^ts_ets_MNN_1080_1.p_[0-9]{0,}.[0-9]{4}')[1:6]
1978+
#smp <- readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', fl))
1979+
1980+
if(all(is.na(fl))){
1981+
smp <- NA
1982+
1983+
} else {
1984+
smp <- ldply(fl, function(x) {
1985+
readRDS(paste0(.dtr, 'data/fx/USDJPY/intraday/', x))
1986+
})
1987+
1988+
smp %>%
1989+
kbl(caption = 'Data Sample (ETS MNN 1080 forecast 1)', escape = FALSE) %>%
1990+
row_spec(0, background = 'DimGrey', color = 'yellow') %>%
1991+
column_spec(1, background = '#556DAC') %>%
1992+
column_spec(2, background = 'Gainsboro', color = 'goldenrod') %>%
1993+
column_spec(3, background = 'LightGray', color = 'goldenrod') %>%
1994+
kable_styling(bootstrap_options = c('striped', 'hover', 'condensed', 'responsive')) %>%
1995+
kable_material(full_width = FALSE) %>%
1996+
scroll_box(width = '100%', fixed_thead = TRUE)
1997+
}
1998+
```
1999+
2000+
```{r include = FALSE}
2001+
if(exists('smp')) rm(smp)
2002+
if(exists('fl')) rm(fl)
2003+
```
2004+
18982005
### 16Hr >> 1min
18992006

19002007
I set the length of data as Daily (`960 mins` which is 1 trading days) to forecast `1 min` in advance.

ets_MNN_MNZ_intraday.R

+3-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ timeID %<>% .[. >= bse]
6767
timeID %<>% .[. >= as_date('2016-12-12')]
6868
#timeID %<>% .[. <= as_date('2016-01-31')]
6969
timeID %<>% .[. >= as_date('2016-12-31')]
70-
data_len <- 600
70+
data_len <- 1080
7171
hrz1 <- 1
7272
intr <- data_len/hrz1
7373

@@ -76,10 +76,8 @@ llply(ets.m, function(md) {
7676
data_len = data_len, hrz1 = hrz1,
7777
.model = md, vb = FALSE)
7878
})
79-
#ts_ets_MNN_960_1.p_238.2016-10-19
80-
#ts_ets_MNN_840_1.p_912.2016-10-18
81-
#ts_ets_MNN_720_1.p_286.2016-10-14
82-
#ts_ets_MNN_600_1.p_774.2016-09-08
79+
#ts_ets_MNN_1080_1.p_504.2016-01-04
80+
#ts_ets_MNN_1200_1.p_473.2016-01-04
8381

8482
# --------- eval=FALSE ---------
8583
source('function/intra_1440.R')

0 commit comments

Comments
 (0)