We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Passing a Dates value to tradeStats() doesn't affect the output; the entire period is always returned.
Dates
tradeStats()
Reproducible example:
library(blotter) demo("longtrend") tradeStats("longtrend") tradeStats("longtrend", Dates = "2018")
Here's a patch that seems to work. But I didn't thoroughly check the output.
diff --git a/R/tradeStats.R b/R/tradeStats.R index 9456387..0370fa2 100644 --- a/R/tradeStats.R +++ b/R/tradeStats.R @@ -148,6 +148,9 @@ tradeStats <- function( Portfolios use <- use[1] #use the first(default) value only if user hasn't specified tradeDef <- tradeDef[1] + if (is.null(Dates)) { + Dates <- "/" + } for (Portfolio in Portfolios){ pname <- Portfolio Portfolio<-.getPortfolio(pname, envir=envir) @@ -157,8 +160,8 @@ tradeStats <- function( Portfolios ## Trade Statistics for (symbol in symbols){ - txn <- Portfolio$symbols[[symbol]]$txn - posPL <- Portfolio$symbols[[symbol]]$posPL + txn <- Portfolio$symbols[[symbol]]$txn[Dates] + posPL <- Portfolio$symbols[[symbol]]$posPL[Dates] posPL <- posPL[-1,] # Use gross transaction P&L to identify transactions that realized @@ -192,7 +195,7 @@ tradeStats <- function( Portfolios #moved above for daily stats for now }, trades = { - trades <- perTradeStats(pname,symbol,tradeDef=tradeDef, envir=envir) + trades <- perTradeStats(pname,symbol,tradeDef=tradeDef, envir=envir, Dates=Dates) PL.gt0 <- trades$Net.Trading.PL[trades$Net.Trading.PL > 0] PL.lt0 <- trades$Net.Trading.PL[trades$Net.Trading.PL < 0] PL.ne0 <- trades$Net.Trading.PL[trades$Net.Trading.PL != 0]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Passing a
Dates
value totradeStats()
doesn't affect the output; the entire period is always returned.Reproducible example:
Here's a patch that seems to work. But I didn't thoroughly check the output.
The text was updated successfully, but these errors were encountered: