我想安排每日任务废弃并计算价格。
> cronR:::cron_rstudioaddin()
Loading required namespace: miniUI
Loading required namespace: shinyFiles
Listening on http://127.0.0.1:5145
Warning in normalizePath(input$rscript_repository, winslash = "/") :
path[1]="/cloud/project/Q": No such file or directory
RscriptRepository /cloud/project/Q does not exist, make sure this is an existing directory without spaces
Adding cronjob:
---------------
## cronR job
## id: job_a8c93b03178d613ed999810c61baa9c1
## tags: forex
## desc: Scraping data for algorithmic calculation.
0 0 * * * /opt/R/3.4.4/lib/R/bin/Rscript '/cloud/project/Q1App2/global.R' >> '/cloud/project/Q1App2/global.log' 2>&1
以下是我可重现任务的脚本......
suppressWarnings(require('cronR'))
suppressWarnings(require('xts'))
suppressWarnings(require('quantmod'))
suppressWarnings(require('lubridate'))
fx <- c('EURUSD=X', 'JPY=X', 'GBPUSD=X', 'CHF=X', 'CAD=X', 'AUDUSD=X')
wd <- c('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')
#'@ if(now('GMT') == today('GMT')) {
## https://finance.yahoo.com/quote/AUDUSD=X?p=AUDUSD=X
## Above link prove that https://finance.yahoo.com using GMT time zone.
if(weekdays(today('GMT'))%in% wd) {
for(i in seq(fx)) {
getSymbols(fx[i], from = (today('GMT') - 1) %m-% years(1),
to = (today('GMT') - 1))
}
rm(i)
}