简体   繁体   English

在quantstrat中进行回测时如何更新最新权益

[英]how to update lastest equity when doing backtest in quantstrat

I am trying to use quantstrate to do backest.我正在尝试使用 quantstrate 来做 backest。 But could not update the lastest equity using "tradeSize=quote(last(getEndEq(acct,Date = timestamp)))" to get the latest total asset.但无法使用“tradeSize=quote(last(getEndEq(acct,Date = timestamp)))”更新最新的净值以获得最新的总资产。 Hope someone could help.希望有人能帮忙。 I'm search for this for a long time and tried many times but could not make it.我正在寻找这个很长一段时间并尝试了很多次但无法做到。 Many many thanks!非常感谢!

# long entry
add.rule(strat,name = "ruleSignal",
         arguments = list(sigcol='EntryLongSig',
                          sigval=TRUE,
                          orderside='long',
                          ordertype='market',
                          osFUN=osDollarATR,
                          pctATR=pctATR,
                          TxnFees=-300,
                          replace=F,
                          prefer='Close',
                          tradeSize=quote(last(getEndEq(acct,Date = timestamp))),
                          atrMod='X'),
         type = 'enter',enabled = TRUE,
         label = "enterLong")

getEndEq(account.st, timestamp) already gives your total equity at specified datetime POSIXct or numerical timestamp object. getEndEq(account.st, timestamp)已经给出了您在指定日期时间 POSIXct 或数字时间戳 object 的总资产。 Using "last" is unnecessary in this condition.在这种情况下,不需要使用“last”。

By the way, rules in quantstrat triggers the orders after the signal occurred(next bar).顺便说一句,quantstrat 中的规则会在信号发生后触发订单(下一个柱)。 If you wonder your total equity at signal time (previous bar) to calculate order quantity, please try - for instance minutely bar-:如果您想知道您在信号时间(前一根柱线)的总资产来计算订单数量,请尝试 - 例如每分钟柱线 -:

getEndEq(quote(getEndEq(account.st,timestamp-60)))

PS Try to give reproducible examples in your next questions. PS 试着在你的下一个问题中给出可重复的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM