回测模块支持对资产进行卖空
🌟 Feature Description
目前的回测实现中,Postion类是不支持卖空的。在不持有股票的时候,无法发起卖单。 虽然代码中添加了 InfPostion类,接触了这个限制。但是各种update逻辑基本没有实现。
但是,在实际上的股票/期权等金融资产交易中,卖空是最常见的实现中性策略的手段之一。不知道为什么团队在早期实现回测模块的时候,只考虑到了买多这种情况。
Motivation
希望团队增加对卖空的支持,大大增加Qlib的实用性。 很多成熟的回测框架都支持,这里不再一一列举。
当然可以让每个用户都进行改造,只用Qlib来做模型的预测部分,不使用Qlib的回测。 但是这就意味着,用户只用数据和模型这边部分,从策略的实现(因为一般都跟回测/实盘交易引擎绑定),回测,结果分析都使用其他框架。 如果这样的话,Qlib的价值会大打折扣。
🌟 Feature Description In the current backtesting implementation, the Postion class does not support short selling. When you do not hold a stock, you cannot place a sell order. Although the code added the InfPostion class to lift this restriction, various update logics have not been implemented. However, in actual stock/option and other financial asset trading, short selling is one of the most common means to achieve a neutral strategy. It is unknown why the team only considered the long position scenario when implementing the backtesting module in the early stage. Motivation We hope the team can add support for short selling and greatly enhance the实用性 of Qlib. Many mature backtesting frameworks support this, and we will not list them one by one here. Of course, we can ask each user to make transformations and only use Qlib for model prediction. But this means that users only use the data and model parts of Qlib, and use other frameworks for strategy implementation (as it is generally bound to the backtesting and real trading engine), backtesting and result analysis. If this is the case, the value of Qlib will be greatly reduced.
可能团队没时间改,自己尝试修改了下,也比较简单,把思路说下,让以后有同样需求的同学可以参考: 1、加个longshortPostion,支持股票的仓位为负。 2、加个LongshortWeightStrategy,按照信号生成带有负权重的目标权重字典。 3、加个LongshortOrderGenerator,把正负权重分开处理,这样就不需要改Exchange了。
试了一下,这样是可以支持持空仓的。
感谢MS的团队框架设计的好。
可能是 A股 不支持 做空
这整个项目 全都是 中国人 搞得