简体   繁体   English

资产组合中的期末权益(和其他交易统计数据)更新问题-吸墨纸

[英]End equity (and other trading stats) update issue in portfolio - blotter

I have multiple symbols in a portfolio but when running a blotter trading strategy the end equity only updates for the last symbol that has been run. 我的投资组合中有多个交易品种,但是在执行吸盘交易策略时,最终权益仅针对已运行的最后一个交易品种进行更新。 When looking into how the equity updates each transaction it seems that when a new symbol is introduced the equity goes back to its original value set at the beginning (1mil). 当调查股本如何更新每笔交易时,似乎引入了新的符号后,股本会恢复到开始时的原始值(100万)。

This is how the portfolio is getting updated for a symbol month by month: 这是一个投资组合每月更新符号的方式:

updatePortf(portfolioName,Symbols=symbolName, Dates=currentDate)
updateAcct(accountName,Dates=currentDate)
updateEndEq(accountName, currentDate)

Why is this happening? 为什么会这样呢?

Hope my question makes sense and thank you in advance 希望我的问题有道理并预先感谢您

This is a good question. 这是一个很好的问题。 if you look at applyStrategy you'll see that each symbol in the loop is run in isolation -- independently. 如果您查看applyStrategy您会发现循环中的每个符号都是独立运行的。 You may want to check out applyStrategy.rebalancing which does a nested loop of the form: 您可能想查看一下applyStrategy.rebalancing ,它执行以下形式的嵌套循环:

for(i in 2:length(pindex)){

            #the proper endpoints for each symbol will vary, so we need to get
            #them separately, and subset each one
            for (symbol in symbols){
                #sret<-ret[[portfolio]]

This means it loops over a section of timestamps, and then for each symbol, which is what you want when you want some interactions between symbols ( applyStrategy simply does a for symbols, then an inner by timestamp loop, so you'll never get interactions going on) in terms of equity. 这意味着它会遍历一部分时间戳,然后遍历每个符号,这就是您希望在符号之间进行某些交互时想要的( applyStrategy只是对符号进行一个for,然后是一个内部的timestamp循环,所以您永远都不会得到交互进行)。

When I first starting using quantstrat I initially had the same frustration. 当我第一次开始使用Quantstrat时,我最初有同样的挫败感。 My solution was to modify applyStrategy.rebalancing do become a (slower) double loop, for each time stamp, then an inner loop across each symbol. 我的解决方案是将applyStrategy.rebalancing修改为每个时间戳一个(较慢的)双循环,然后跨每个符号进行一个内部循环。

Yes, this means you can't directly compute portfolio PL accurately in quantstrat. 是的,这意味着您不能直接在quantstrat中准确计算投资组合的PL。 So things like opening positions that are position of current portfolio equity can't be done directly. 因此,诸如开仓头寸即当前投资组合权益头寸之类的事情无法直接完成。 (But you can modify the code to do it if you want). (但是您可以根据需要修改代码)。

Why does quantstrat behave this way by default? 为什么默认情况下Quantstrat会表现这种方式? The authors will give you good reasons. 作者将给您充分的理由。 In short, my view is that (after some brief discussions with the authors), if a signal has predictive power, and gives you an edge in a strategy, it'll work regardless of how you combine it with other symbols later. 简而言之,我的观点是(在与作者进行简短讨论之后),如果信号具有预测力,并且可以为您提供策略上的优势,则无论以后如何将其与其他符号组合使用,信号都将起作用。 quantstrat is about identifying whether signals are good or not in relation to mktdata you pass to it. quantstrat是确定与传递给它的mktdata相关的信号是否良好。

Logically, if a signal is good on a per symbol level, then it will likely do ok on a portfolio level too (if not better, with smoother portfolio PL). 从逻辑上讲,如果信号在每个符号级别上都不错,那么它也可能在投资组合级别上正常(如果不是更好,则使用更平滑的投资组合PL)。 quantstrat's current approach will give you a reasonable approximation to what portfolio PL will look like, but not in a true "compounding return" sense. Quantumstrat当前的方法将使您对投资组合PL的外观有一个合理的近似,但并不是真正的“复合回报”。 To do that, you'd want to scale your positions according to the current portfolio PL (which isn't possible in applyStrategy as noted above). 为此,您需要根据当前的投资组合PL来applyStrategy (如上所述,这在applyStrategy是不可能的)。 This simplification of running a strategy per symbol only also makes simulations much, much faster. 每个符号运行策略的这种简化也仅使仿真快得多。 Note that you can introduce still interactions with other symbols in applyStrategy by adding additional columns to the symbol data that relate to other symbols though (eg in pairs trading, etc). 请注意,您可以通过在与其他符号相关的符号数据中添加其他列(例如,成对交易等)来在applyStrategy引入与其他符号的静态交互。

At the end of the day backtest results are always simplifications of trading in reality, so there isn't a big motivation to get "super" accurate backtest results that project profit/trading revenue very accurately. 归根结底,回测结果始终是实际交易的简化,因此,没有很大的动力来获得“超级”准确的回测结果,从而非常准确地预测利润/交易收入。

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

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