account.py 文件源码

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

项目:AutoTrading 作者: curme 项目源码 文件源码
def calQnt(self, price, volume, method, fixedFraction):

            Equity = self.queryCapital()
            proportion = 0.15
            maxDrawDown = 3800

            if method is 'FixedFraction':
                # TradeRisk = maxDrawDown(data)
                TradeRisk = maxDrawDown
                N = fixedFraction * Equity / abs(TradeRisk)
                if N >= volume * proportion : return math.trunc(volume * proportion)
                else                        : return int(np.nan_to_num(N))
                # return int(N)

            if method is 'MaxDrawDown':
                margin = 0.65
                # allocation = maxDrawDown(data) * 1.5 + margin * price
                allocation = maxDrawDown * 1.5 + margin * price
                N = Equity / allocation
                if N >= volume * proportion : return math.trunc(volume * proportion)
                else                        : return int(np.nan_to_num(N))
                # return int(N)

        # query capital of self strategy
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号