Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repair #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file modified 9781484221778.jpg 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Examples/cv-NelderMead-MACD.R 100644 → 100755
Empty file.
Empty file modified LICENSE.txt 100644 → 100755
Empty file.
Empty file modified Listings/Appendix B/B-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Appendix B/B-2.R 100644 → 100755
Empty file.
Empty file modified Listings/Appendix B/B-3.R 100644 → 100755
Empty file.
Empty file modified Listings/Appendix B/B-4.R 100644 → 100755
Empty file.
Empty file modified Listings/Appendix B/UNIX-mcTimeSeries.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-10.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-2.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-3.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-4.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-5.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-6.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-7.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-8.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 1/1-9.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-10 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-2.bat 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-3.bat 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-4.bat 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-5.bat 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-6.bat 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-7.txt 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-8.sh 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 10/10-9.sh 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 2/2-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 2/2-2.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 2/2-3.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 2/2-4.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 2/2-5.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 2/2-6.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 2/2-7.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 2/2-8.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 3/3-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 3/3-2.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 3/3-3.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 3/3-4.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 3/3-5.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 3/3-6.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 3/3-7.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 3/3-8.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 4/4-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 4/4-2.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 4/4-3.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 4/4-4.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 4/4-5.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-10.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-11.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-12.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-13.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-2.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-3.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-4.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-5.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-6.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-7.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-8.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 6/6-9.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 7/7-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 7/7-2.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 7/7-3.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 7/7-4.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 7/7-5.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 8/8-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 8/8-2.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 8/8-3.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 8/8-4.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 8/8-5.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 8/8-6.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 8/sampleOptimizeWrapper.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-1.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-10.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-11.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-2.xml 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-3.txt 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-4.txt 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-5.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-6.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-7.xml 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-8.R 100644 → 100755
Empty file.
Empty file modified Listings/Chapter 9/9-9.R 100644 → 100755
Empty file.
116 changes: 58 additions & 58 deletions Platform/S.R 100644 → 100755
@@ -1,58 +1,58 @@
S <-
c("MMM", "ABT", "ABBV", "ACN", "ACE", "ATVI", "ADBE", "ADT",
"AAP", "AES", "AET", "AFL", "AMG", "A", "GAS", "APD", "ARG",
"AKAM", "AA", "AGN", "ALXN", "ALLE", "ADS", "ALL", "GOOGL", "GOOG",
"ALTR", "MO", "AMZN", "AEE", "AAL", "AEP", "AXP", "AIG", "AMT",
"AMP", "ABC", "AME", "AMGN", "APH", "APC", "ADI", "AON", "APA",
"AIV", "AAPL", "AMAT", "ADM", "AIZ", "T", "ADSK", "ADP", "AN",
"AZO", "AVGO", "AVB", "AVY", "BHI", "BLL", "BAC", "BK", "BCR",
"BXLT", "BAX", "BBT", "BDX", "BBBY", "BRK-B", "BBY", "BIIB",
"BLK", "HRB", "BA", "BWA", "BXP", "BSX", "BMY", "BRCM", "BF-B",
"CHRW", "CA", "CVC", "COG", "CAM", "CPB", "COF", "CAH", "HSIC",
"KMX", "CCL", "CAT", "CBG", "CBS", "CELG", "CNP", "CTL", "CERN",
"CF", "SCHW", "CHK", "CVX", "CMG", "CB", "CI", "XEC", "CINF",
"CTAS", "CSCO", "C", "CTXS", "CLX", "CME", "CMS", "COH", "KO",
"CCE", "CTSH", "CL", "CPGX", "CMCSA", "CMCSK", "CMA", "CAG",
"COP", "CNX", "ED", "STZ", "GLW", "COST", "CCI", "CSRA", "CSX",
"CMI", "CVS", "DHI", "DHR", "DRI", "DVA", "DE", "DLPH", "DAL",
"XRAY", "DVN", "DO", "DFS", "DISCA", "DISCK", "DG", "DLTR", "D",
"DOV", "DOW", "DPS", "DTE", "DD", "DUK", "DNB", "ETFC", "EMN",
"ETN", "EBAY", "ECL", "EIX", "EW", "EA", "EMC", "EMR", "ENDP",
"ESV", "ETR", "EOG", "EQT", "EFX", "EQIX", "EQR", "ESS", "EL",
"ES", "EXC", "EXPE", "EXPD", "ESRX", "XOM", "FFIV", "FB", "FAST",
"FDX", "FIS", "FITB", "FSLR", "FE", "FISV", "FLIR", "FLS", "FLR",
"FMC", "FTI", "F", "FOSL", "BEN", "FCX", "FTR", "GME", "GPS",
"GRMN", "GD", "GE", "GGP", "GIS", "GM", "GPC", "GILD", "GS",
"GT", "GWW", "HAL", "HBI", "HOG", "HAR", "HRS", "HIG", "HAS",
"HCA", "HCP", "HP", "HES", "HPE", "HD", "HON", "HRL", "HST",
"HPQ", "HUM", "HBAN", "ITW", "ILMN", "IR", "INTC", "ICE", "IBM",
"IP", "IPG", "IFF", "INTU", "ISRG", "IVZ", "IRM", "JEC", "JBHT",
"JNJ", "JCI", "JPM", "JNPR", "KSU", "K", "KEY", "GMCR", "KMB",
"KIM", "KMI", "KLAC", "KSS", "KHC", "KR", "LB", "LLL", "LH",
"LRCX", "LM", "LEG", "LEN", "LVLT", "LUK", "LLY", "LNC", "LLTC",
"LMT", "L", "LOW", "LYB", "MTB", "MAC", "M", "MNK", "MRO", "MPC",
"MAR", "MMC", "MLM", "MAS", "MA", "MAT", "MKC", "MCD", "MHFI",
"MCK", "MJN", "WRK", "MDT", "MRK", "MET", "KORS", "MCHP", "MU",
"MSFT", "MHK", "TAP", "MDLZ", "MON", "MNST", "MCO", "MS", "MOS",
"MSI", "MUR", "MYL", "NDAQ", "NOV", "NAVI", "NTAP", "NFLX", "NWL",
"NFX", "NEM", "NWSA", "NWS", "NEE", "NLSN", "NKE", "NI", "NBL",
"JWN", "NSC", "NTRS", "NOC", "NRG", "NUE", "NVDA", "ORLY", "OXY",
"OMC", "OKE", "ORCL", "OI", "PCAR", "PH", "PDCO", "PAYX", "PYPL",
"PNR", "PBCT", "POM", "PEP", "PKI", "PRGO", "PFE", "PCG", "PM",
"PSX", "PNW", "PXD", "PBI", "PCL", "PNC", "RL", "PPG", "PPL",
"PX", "PCP", "PCLN", "PFG", "PG", "PGR", "PLD", "PRU", "PEG",
"PSA", "PHM", "PVH", "QRVO", "PWR", "QCOM", "DGX", "RRC", "RTN",
"O", "RHT", "REGN", "RF", "RSG", "RAI", "RHI", "ROK", "COL",
"ROP", "ROST", "RCL", "R", "CRM", "SNDK", "SCG", "SLB", "SNI",
"STX", "SEE", "SRE", "SHW", "SIG", "SPG", "SWKS", "SLG", "SJM",
"SNA", "SO", "LUV", "SWN", "SE", "STJ", "SWK", "SPLS", "SBUX",
"HOT", "STT", "SRCL", "SYK", "STI", "SYMC", "SYF", "SYY", "TROW",
"TGT", "TEL", "TE", "TGNA", "THC", "TDC", "TSO", "TXN", "TXT",
"HSY", "TRV", "TMO", "TIF", "TWX", "TWC", "TJX", "TMK", "TSS",
"TSCO", "RIG", "TRIP", "FOXA", "FOX", "TSN", "TYC", "USB", "UA",
"UNP", "UAL", "UNH", "UPS", "URI", "UTX", "UHS", "UNM", "URBN",
"VFC", "VLO", "VAR", "VTR", "VRSN", "VRSK", "VZ", "VRTX", "VIAB",
"V", "VNO", "VMC", "WMT", "WBA", "DIS", "WM", "WAT", "ANTM",
"WFC", "HCN", "WDC", "WU", "WY", "WHR", "WFM", "WMB", "WEC",
"WYN", "WYNN", "XEL", "XRX", "XLNX", "XL", "XYL", "YHOO", "YUM",
"ZBH", "ZION", "ZTS")
S <-
c("MMM", "ABT", "ABBV", "ACN", "ACE", "ATVI", "ADBE", "ADT",
"AAP", "AES", "AET", "AFL", "AMG", "A", "GAS", "APD", "ARG",
"AKAM", "AA", "AGN", "ALXN", "ALLE", "ADS", "ALL", "GOOGL", "GOOG",
"ALTR", "MO", "AMZN", "AEE", "AAL", "AEP", "AXP", "AIG", "AMT",
"AMP", "ABC", "AME", "AMGN", "APH", "APC", "ADI", "AON", "APA",
"AIV", "AAPL", "AMAT", "ADM", "AIZ", "T", "ADSK", "ADP", "AN",
"AZO", "AVGO", "AVB", "AVY", "BHI", "BLL", "BAC", "BK", "BCR",
"BXLT", "BAX", "BBT", "BDX", "BBBY", "BRK-B", "BBY", "BIIB",
"BLK", "HRB", "BA", "BWA", "BXP", "BSX", "BMY", "BRCM", "BF-B",
"CHRW", "CA", "CVC", "COG", "CAM", "CPB", "COF", "CAH", "HSIC",
"KMX", "CCL", "CAT", "CBG", "CBS", "CELG", "CNP", "CTL", "CERN",
"CF", "SCHW", "CHK", "CVX", "CMG", "CB", "CI", "XEC", "CINF",
"CTAS", "CSCO", "C", "CTXS", "CLX", "CME", "CMS", "COH", "KO",
"CCE", "CTSH", "CL", "CPGX", "CMCSA", "CMCSK", "CMA", "CAG",
"COP", "CNX", "ED", "STZ", "GLW", "COST", "CCI", "CSRA", "CSX",
"CMI", "CVS", "DHI", "DHR", "DRI", "DVA", "DE", "DLPH", "DAL",
"XRAY", "DVN", "DO", "DFS", "DISCA", "DISCK", "DG", "DLTR", "D",
"DOV", "DOW", "DPS", "DTE", "DD", "DUK", "DNB", "ETFC", "EMN",
"ETN", "EBAY", "ECL", "EIX", "EW", "EA", "EMC", "EMR", "ENDP",
"ESV", "ETR", "EOG", "EQT", "EFX", "EQIX", "EQR", "ESS", "EL",
"ES", "EXC", "EXPE", "EXPD", "ESRX", "XOM", "FFIV", "FB", "FAST",
"FDX", "FIS", "FITB", "FSLR", "FE", "FISV", "FLIR", "FLS", "FLR",
"FMC", "FTI", "F", "FOSL", "BEN", "FCX", "FTR", "GME", "GPS",
"GRMN", "GD", "GE", "GGP", "GIS", "GM", "GPC", "GILD", "GS",
"GT", "GWW", "HAL", "HBI", "HOG", "HAR", "HRS", "HIG", "HAS",
"HCA", "HCP", "HP", "HES", "HPE", "HD", "HON", "HRL", "HST",
"HPQ", "HUM", "HBAN", "ITW", "ILMN", "IR", "INTC", "ICE", "IBM",
"IP", "IPG", "IFF", "INTU", "ISRG", "IVZ", "IRM", "JEC", "JBHT",
"JNJ", "JCI", "JPM", "JNPR", "KSU", "K", "KEY", "GMCR", "KMB",
"KIM", "KMI", "KLAC", "KSS", "KHC", "KR", "LB", "LLL", "LH",
"LRCX", "LM", "LEG", "LEN", "LVLT", "LUK", "LLY", "LNC", "LLTC",
"LMT", "L", "LOW", "LYB", "MTB", "MAC", "M", "MNK", "MRO", "MPC",
"MAR", "MMC", "MLM", "MAS", "MA", "MAT", "MKC", "MCD", "MHFI",
"MCK", "MJN", "WRK", "MDT", "MRK", "MET", "KORS", "MCHP", "MU",
"MSFT", "MHK", "TAP", "MDLZ", "MON", "MNST", "MCO", "MS", "MOS",
"MSI", "MUR", "MYL", "NDAQ", "NOV", "NAVI", "NTAP", "NFLX", "NWL",
"NFX", "NEM", "NWSA", "NWS", "NEE", "NLSN", "NKE", "NI", "NBL",
"JWN", "NSC", "NTRS", "NOC", "NRG", "NUE", "NVDA", "ORLY", "OXY",
"OMC", "OKE", "ORCL", "OI", "PCAR", "PH", "PDCO", "PAYX", "PYPL",
"PNR", "PBCT", "POM", "PEP", "PKI", "PRGO", "PFE", "PCG", "PM",
"PSX", "PNW", "PXD", "PBI", "PCL", "PNC", "RL", "PPG", "PPL",
"PX", "PCP", "PCLN", "PFG", "PG", "PGR", "PLD", "PRU", "PEG",
"PSA", "PHM", "PVH", "QRVO", "PWR", "QCOM", "DGX", "RRC", "RTN",
"O", "RHT", "REGN", "RF", "RSG", "RAI", "RHI", "ROK", "COL",
"ROP", "ROST", "RCL", "R", "CRM", "SNDK", "SCG", "SLB", "SNI",
"STX", "SEE", "SRE", "SHW", "SIG", "SPG", "SWKS", "SLG", "SJM",
"SNA", "SO", "LUV", "SWN", "SE", "STJ", "SWK", "SPLS", "SBUX",
"HOT", "STT", "SRCL", "SYK", "STI", "SYMC", "SYF", "SYY", "TROW",
"TGT", "TEL", "TE", "TGNA", "THC", "TDC", "TSO", "TXN", "TXT",
"HSY", "TRV", "TMO", "TIF", "TWX", "TWC", "TJX", "TMK", "TSS",
"TSCO", "RIG", "TRIP", "FOXA", "FOX", "TSN", "TYC", "USB", "UA",
"UNP", "UAL", "UNH", "UPS", "URI", "UTX", "UHS", "UNM", "URBN",
"VFC", "VLO", "VAR", "VTR", "VRSN", "VRSK", "VZ", "VRTX", "VIAB",
"V", "VNO", "VMC", "WMT", "WBA", "DIS", "WM", "WAT", "ANTM",
"WFC", "HCN", "WDC", "WU", "WY", "WHR", "WFM", "WMB", "WEC",
"WYN", "WYNN", "XEL", "XRX", "XLNX", "XL", "XYL", "YHOO", "YUM",
"ZBH", "ZION", "ZTS")
Empty file modified Platform/SPdates.R 100644 → 100755
Empty file.
Empty file modified Platform/compute/MCinit.R 100644 → 100755
Empty file.
Empty file modified Platform/compute/functions.R 100644 → 100755
Empty file.
14 changes: 7 additions & 7 deletions Platform/config.R 100644 → 100755
@@ -1,11 +1,11 @@
DIR <- list()
DIR[["root"]] <- "~/Platform/"
DIR[["data"]] <- "~/Platform/stockdata/"
DIR[["function"]] <- "~/Platform/functions/"
DIR[["load"]] <- "~/Platform/load/"
DIR[["compute"]] <- "~/Platform/compute/"
DIR[["plan"]] <- "~/Platform/plan/"
DIR[["model"]] <- "~/Platform/model/"
DIR[["root"]] <- "~/Documents/automated-trading-with-r-master/Platform"
DIR[["data"]] <- "~/Documents/automated-trading-with-r-master/Platform/stockdata/"
DIR[["function"]] <- "~/Documents/automated-trading-with-r-master/Platform/functions/"
DIR[["load"]] <- "~/Documents/automated-trading-with-r-master/Platform/load/"
DIR[["compute"]] <- "~/Documents/automated-trading-with-r-master/Platform/compute/"
DIR[["plan"]] <- "~/Documents/automated-trading-with-r-master/Platform/plan/"
DIR[["model"]] <- "~/Documents/automated-trading-with-r-master/Platform/model/"

CONFIG <- list()

Expand Down
46 changes: 32 additions & 14 deletions Platform/functions/yahoo.R 100644 → 100755
@@ -1,30 +1,48 @@
# Listing 2.2



yahoo <- function(sym, current = TRUE,
a = 0, b = 1, c = 2000, d, e, f,
g = "d")
{

library(curl)
if(current){
f <- as.numeric(substr(as.character(Sys.time()), start = 1, stop = 4))
d <- as.numeric(substr(as.character(Sys.time()), start = 6, stop = 7)) - 1
e <- as.numeric(substr(as.character(Sys.time()), start = 9, stop = 10))
}

deb<-as.integer( as.POSIXct( Sys.time() ) ) -31622400*3
end<-as.integer( as.POSIXct( Sys.time() ) )
require(data.table)

url<-paste0("https://query1.finance.yahoo.com/v7/finance/download/",
sym,
"?period1=",deb,
"&period2=",end,
"&interval=1d",
"&events=history&crumb=0vlktCe/gti")
#https://query1.finance.yahoo.com/v7/finance/download/ACN?period1=1509220928&period2=1511902928&interval=1d&events=history&crumb=0vlktCe/gti
#https://query1.finance.yahoo.com/v7/finance/download/MMM?period1=1509220928&period2=1511902928&interval=1d&events=history&crumb=0vlktCe/gti
#https://query1.finance.yahoo.com/v7/finance/download/ACE?period1=1509220928&period2=1511902928&interval=1d&events=history&crumb=0vlktCe/gti
h <- new_handle(copypostfields = "moo=moomooo")

# Perform the request
req <- curl_fetch_memory("https://uk.finance.yahoo.com/quote/AAPL/history", handle = h)

# Show some outputs
cookie<-parse_headers(req$headers)[17]
cookie<-gsub("Set-Cookie: ","",cookie)
cookie<-strsplit(cookie, ";")[[1]][1]
tmp <- tempfile()
handle_setheaders(h,"cookie"=cookie)
tryCatch(
curl_download(url, tmp,handle=h),
error = function(err) print(paste0("MY_ERROR: ",err, ":'",url,"'"))
)
tryCatch(
suppressWarnings(
fread(paste0("http://ichart.yahoo.com/table.csv",
"?s=", sym,
"&a=", a,
"&b=", b,
"&c=", c,
"&d=", d,
"&e=", e,
"&f=", f,
"&g=", g,
"&ignore=.csv"), sep = ",")),
error = function(e) NULL
fread(tmp, sep = ",")),
error = function(err) print(paste0("MY_ERROR: ",err, ":'",url,"'"))
)
}

7 changes: 5 additions & 2 deletions Platform/invalid.R 100644 → 100755
@@ -1,2 +1,5 @@
invalid <-
character(0)
invalid <-
c("ACE", "ADT", "GAS", "ARG", "BHI", "BXLT", "BRCM", "CVC", "CAM",
"CPGX", "CMCSK", "DOW", "DD", "EMC", "HAR", "GMCR", "LLTC", "MHFI",
"MJN", "POM", "PCL", "PCP", "RAI", "SNDK", "STJ", "SPLS", "HOT",
"TE", "TSO", "TWC", "TYC", "WFM", "YHOO")
Empty file modified Platform/load.R 100644 → 100755
Empty file.
Empty file modified Platform/load/adjustClose.R 100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion Platform/load/dateUnif.R 100644 → 100755
Expand Up @@ -11,6 +11,7 @@ DATA[["Open"]] <- DATA[["High"]] <- DATA[["Low"]] <-
DATA[["Close"]] <- DATA[["Adj Close"]] <- DATA[["Volume"]] <- datetemp

for(s in S){
if (s != "invalid.R"){
for(i in rev(c("Open", "High", "Low", "Close", "Adj Close", "Volume"))){
temp <- data.frame(cbind(DATA[[s]][["Date"]], DATA[[s]][[i]]),
stringsAsFactors = FALSE)
Expand All @@ -34,7 +35,7 @@ for(s in S){
if( which( S == s ) %% 25 == 0 ){
cat( paste0(round(100 * which( S == s ) / length(S), 1), "% Complete\n") )
}

}
}

DATA <- lapply(DATA, function(v) zoo(v[,2:ncol(v)], strptime(v[,1], "%Y-%m-%d")))
Expand Down
Empty file modified Platform/load/fillInactive.R 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Platform/load/initial.R 100644 → 100755
Expand Up @@ -22,7 +22,7 @@ if(length(toload) != 0){

df <- yahoo(toload[i])

if(!is.null(df)) {
if(!is.null(df)&&!"V1" %in% colnames(df)) {
write.csv(df[nrow(df):1], file = paste0(toload[i], ".csv"),
row.names = FALSE)
} else {
Expand Down
2 changes: 2 additions & 0 deletions Platform/load/loadToMemory.R 100644 → 100755
Expand Up @@ -6,7 +6,9 @@ library(data.table)

DATA <- list()
for(i in S){
if (i != "invalid.R"){
suppressWarnings(
DATA[[i]] <- fread(paste0(i, ".csv"), sep = ","))
DATA[[i]] <- (DATA[[i]])[order(DATA[[i]][["Date"]], decreasing = FALSE)]
}
}
Empty file modified Platform/load/return.R 100644 → 100755
Empty file.
Empty file modified Platform/load/spClean.R 100644 → 100755
Empty file.
Empty file modified Platform/load/updateStocks.R 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Platform/model.R 100644 → 100755
@@ -1,4 +1,4 @@
source("~/Platform/config.R")
source("~/Documents/automated-trading-with-r-master/Platform/config.R")

setwd(DIR[["root"]])
cat("load.R\n\n")
Expand Down
9 changes: 8 additions & 1 deletion Platform/model/evaluateFunc.R 100644 → 100755
Expand Up @@ -51,12 +51,19 @@ evaluate <- function(PARAM, minVal = NA, maxVal = NA, y = 2014,
CLOSE <- DATA[["Close"]][period,]
OPEN <- DATA[["Open"]][period,]
SUBRETURN <- RETURN[period,]

ASV<-as.vector(CLOSE)
pol<-ncol(CLOSE)
plol<-length(ASV)
if(length(ASV)==0L||ncol(CLOSE)==0){
return(0)
}

# Compute inputs for long-only MACD as in Listing 7.2
# Code is optimized for speed using functions from caTools and zoo
require(caTools)

n1bis<-max(n1,ncol(CLOSE))
n2bis<-max(n2,ncol(CLOSE))
INDIC <- zoo(runmean(CLOSE, n1, endrule = "NA", align = "right") -
runmean(CLOSE, n2, endrule = "NA", align = "right"),
order.by = index(CLOSE))
Expand Down
Empty file modified Platform/model/optimize.R 100644 → 100755
Empty file.
Empty file modified Platform/model/optimizeFunc.R 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Platform/plan.R 100644 → 100755
@@ -1,4 +1,4 @@
source("~/Platform/config.R")
source("~/Documents/automated-trading-with-r-master/Platform/config.R")


setwd(DIR[["root"]])
Expand Down
7 changes: 4 additions & 3 deletions Platform/plan/decisionGen.R 100644 → 100755
Expand Up @@ -5,8 +5,9 @@ setwd(DIR[["plan"]])
# Normally declared by your strategy.
# Long-only MACD is computed with rollapply()
# here for sake of example.
n1 <- 5
n2 <- 34
maxo<-nrow(DATA[["Close"]])
n1 <- min(5,maxo)
n2 <- min(34,maxo)
nSharpe <- 20
shThresh <- 0.50

Expand Down Expand Up @@ -39,7 +40,7 @@ entryfunc <- function(v, shThresh){
cols <- ncol(INDIC)

ENTRY <- rollapply(cbind(INDIC, FAVOR),
function(v) entryfunc(v, cols),
function(v) entryfunc(v, shThresh),
by.column = FALSE,
width = 2,
align = "right")
Expand Down
Empty file modified Platform/trade.R 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Platform/update.R 100644 → 100755
@@ -1,4 +1,4 @@
source("~/Platform/config.R")
source("~/Documents/automated-trading-with-r-master/Platform/config.R")

setwd(DIR[["load"]])
cat("initial.R\n\n")
Expand Down
Empty file modified README.md 100644 → 100755
Empty file.
Empty file modified contributing.md 100644 → 100755
Empty file.