trds <- read.csv("C:\\Zorro\\Log\\testtrades.csv", stringsAsFactors=TRUE)
trds$Open <- as.POSIXct(trds$Open, tz="GMT")
trds$Close <- as.POSIXct(trds$Close, tz="GMT")
#install.packages("stringi") #do it once
require(stringi)
for (i in levels(trds[,"Name"])) {
for (j in levels(trds[,"Asset"])) {
nice.asset.name <- stri_replace_all(str=j, replacement="-", fixed="/")
png.file.name <- paste(sep="",i,"_",nice.asset.name,".png")
png(file=png.file.name, width = 600, height = 800, units = "px", pointsize = 16)
old.par <- par(mfcol=c(3,1))
k <- "Long"
idx <- trds$Name==i & trds$Asset==j & trds$Type==k
plot(y=cumsum(trds$Profit[idx]), x=trds$Close[idx],
pch=19, main=paste(i, j, k), ylab="Eq", xlab=""); abline(h=0)
k <- "Short"
idx <- trds$Name==i & trds$Asset==j & trds$Type==k
plot(y=cumsum(trds$Profit[idx]), x=trds$Close[idx],
pch=19, main=paste(i, j, k), ylab="Eq", xlab=""); abline(h=0)
idx <- trds$Name==i & trds$Asset==j
plot(y=cumsum(trds$Profit[idx]), x=trds$Close[idx],
pch=19, main=paste(i, j ), ylab="Eq", xlab=""); abline(h=0)
par(old.par)
dev.off()
}
}