require(FinancialInstrument)
## Loading required package: FinancialInstrument
## Loading required package: quantmod
## Loading required package: Defaults
## Loading required package: xts
## Loading required package: zoo
## Attaching package: 'zoo'
## The following object is masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
require(blotter)
## Loading required package: blotter
## Loading required package: PerformanceAnalytics
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
currency("USD")
## [1] "USD"
source("getSymbols.mycsv.R")
loadInstruments("Futures_instruments_with_paths.RData")
loadSymbolLookup("Futures_instruments_SymbolLookup.RData")
getSymbols("ES_201303")
## As of 0.4-0, 'getSymbols' uses env=parent.frame() and auto.assign=TRUE by
## default.
##
## This behavior will be phased out in 0.5-0 when the call will default to
## use auto.assign=FALSE. getOption("getSymbols.env") and
## getOptions("getSymbols.auto.assign") are now checked for alternate
## defaults
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.warning4.0"=FALSE). See ?getSymbol for more details
## [1] "ES_201303"
head(ES_201303)
## ES_201303.Open ES_201303.High ES_201303.Low ES_201303.Close
## 2011-12-16 1188 1188 1188 1188
## 2011-12-19 1177 1177 1177 1177
## 2011-12-20 1214 1214 1214 1214
## 2011-12-21 1214 1214 1214 1214
## 2011-12-22 1227 1227 1227 1227
## 2011-12-23 1238 1238 1238 1238
## ES_201303.Volume ES_201303.Adjusted
## 2011-12-16 2267073 3402680
## 2011-12-19 1684649 2538315
## 2011-12-20 1827326 2561308
## 2011-12-21 1987322 2575097
## 2011-12-22 1336956 2597419
## 2011-12-23 695759 2605398
tail(ES_201303)
## ES_201303.Open ES_201303.High ES_201303.Low ES_201303.Close
## 2013-03-08 1543 1554 1540 1550
## 2013-03-11 1547 1557 1546 1556
## 2013-03-12 1557 1557 1548 1552
## 2013-03-13 1553 1557 1548 1556
## 2013-03-14 1556 1564 1555 1562
## 2013-03-15 1561 1565 1557 1557
## ES_201303.Volume ES_201303.Adjusted
## 2013-03-08 3053473 3555036
## 2013-03-11 2361481 3705061
## 2013-03-12 2885864 3796609
## 2013-03-13 2160933 3801969
## 2013-03-14 1901939 3757487
## 2013-03-15 1767829 3778891
initPortf("p", symbols = "ES_201303", currency = "USD")
## [1] "p"
addTxn(Portfolio = "p", Symbol = "ES_201303", TxnDate = "2013-01-02", TxnQty = 1,
TxnPrice = 1440, TxnFees = -2)
## [1] "2013-01-02 00:00:00 ES_201303 1 @ 1440"
addTxn(Portfolio = "p", Symbol = "ES_201303", TxnDate = "2013-03-13", TxnQty = -1,
TxnPrice = 1450, TxnFees = -2)
## [1] "2013-03-13 00:00:00 ES_201303 -1 @ 1450"
updatePortf(Portfolio = "p")
## [1] "p"
initAcct(name = "a", portfolios = "p", initEq = 10000, currency = "USD")
## [1] "a"
updateAcct("a")
## [1] "a"
updateEndEq("a")
## [1] "a"
tradeStats("p")
## Portfolio Symbol Num.Txns Num.Trades Net.Trading.PL
## ES_201303 p ES_201303 2 2 496
## Avg.Trade.PL Med.Trade.PL Largest.Winner Largest.Loser
## ES_201303 248 248 498 -2
## Gross.Profits Gross.Losses Std.Dev.Trade.PL Percent.Positive
## ES_201303 498 -2 353.6 50
## Percent.Negative Profit.Factor Avg.Win.Trade Med.Win.Trade
## ES_201303 50 249 498 498
## Avg.Losing.Trade Med.Losing.Trade Avg.Daily.PL Med.Daily.PL
## ES_201303 -2 -2 248 248
## Std.Dev.Daily.PL Max.Drawdown Profit.To.Max.Draw
## ES_201303 353.6 -5302 0.09355
## Avg.WinLoss.Ratio Med.WinLoss.Ratio Max.Equity Min.Equity
## ES_201303 249 249 5798 -1002
## End.Equity
## ES_201303 496
getTxns(Portfolio = "p", Symbol = "ES_201303")
## Txn.Qty Txn.Price Txn.Fees Txn.Value Txn.Avg.Cost
## 1950-01-01 0 0 0 0 0
## 2013-01-02 1 1440 -2 72000 1440
## 2013-03-13 -1 1450 -2 -72500 1450
## Net.Txn.Realized.PL
## 1950-01-01 0
## 2013-01-02 -2
## 2013-03-13 498