test_perf_tracking.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:zipline-chinese 作者: zhanghan1990 项目源码 文件源码
def test_empty_positions(self):
        """
        make sure all the empty position stats return a numeric 0

        Originally this bug was due to np.dot([], []) returning
        np.bool_(False)
        """
        pt = perf.PositionTracker(self.env.asset_finder)
        pos_stats = pt.stats()

        stats = [
            'net_value',
            'net_exposure',
            'gross_value',
            'gross_exposure',
            'short_value',
            'short_exposure',
            'shorts_count',
            'long_value',
            'long_exposure',
            'longs_count',
        ]
        for name in stats:
            val = getattr(pos_stats, name)
            self.assertEquals(val, 0)
            self.assertNotIsInstance(val, (bool, np.bool_))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号