探讨胜率、盈亏比、收益率、杠杆四者的关系

2020-03-05  本文已影响0人  东东威武

文章介绍

胜率重要还是盈亏比重要?
是高胜率小赚好还是低胜率大赚好?
是刺激火爆的标的好,还是温和的标的好?
杠杆用多大?杠杆用大了是能发财致富还是加速破产?
胜率、盈亏比、收益率、波动率、杠杆这些这些概念对交易的结果至关重要,所以本文对这些作些探讨。个人整理,如有不对,烦请指正。

整体思路上,会对涉及到的概念做些约定,推导下公式,然后基于公式分析各因子的作用与关系,并做几个程序实验。后面基于探究的结果谈谈如何改善交易结果。

概念约定

胜率,用W表示。
单笔收益率,用Y表示,实际反映的交易结果的振幅,你是大赚大亏还是小赚小亏。
亏盈比,用于和收益率相乘得到亏损率,用R表示,即亏损时的收益率为-RY。因为实际上波动大的市场,一定是赚的多亏的也多,所以盈利和亏损之间更接近于是一个比例关系。
杠杆数,用L表示。
总交易次数为N。

盈亏分布上,假定总是一赚一亏。

盈亏顺序无关:这不是一个约定,是一个基础认知。最终交易结果只取决于每次交易的收益率,和这些交易什么顺序无关。

杠杆与真实收益率:杠杆其实只影响真实的收益率,2倍5%的收益率和1倍10%的收益率其实是一样的。所以在实际上我们并不需要单独去考虑杠杆这个因子,它的作用可以体现在收益率里

各因子分析

\begin{aligned} &盈利单数为WN\\ &盈利单的总收益为(1+Y)^{WN}\\ &亏损单数为(1-W)N\\ &亏损单的总收益为(1-RY)^{(1-W)N}\\ &故,最终总收益E=(1+Y)^{WN}*(1-RY)^{(1-W)N}\\ &若要交易获胜,首先要不亏,即E>1\\ &即(1+Y)^{WN}*(1-RY)^{(1-W)N}>1\\ &即[(1+Y)^{W}*(1-RY)^{(1-W)}]^{N}>1\\ &因为N为正整数,故等价于(1+Y)^{W}*(1-RY)^{1-W}>1\\ &因为Y>0,所以(1+Y) > 1,(1+Y)^{W}也必定大于1,是总收益率里的盈利部分\\ &R>0,Y>0,所以(1-RY)小于1,而指数1-W大于0\\ &所以(1-RY)^{1-W}也必定小于1,是总收益率里的亏损部分\\ \end{aligned}

提一下要点---总收益E是盈利部分(1+Y)WN和亏损部分(1-RY)(1-W)N的乘积

综上,胜率和盈亏比都是越大越好。胜率越大、盈亏比越大,可以使用的真实收益率也即杠杆越大;反之越小。都是废话。

程序测试

用方便好用的python测试。

一个遍历所有因子计算最终收益的接口:

def calculate_rate_of_return(wr_list=None, lr_list=None, yr_list=None, lever_list=None, trade_cnt=TRADE_CNT):
    """
    :param wr_list: 胜率
    :param lr_list: 亏盈比
    :param yr_list: 收益率
    :param lever_list:杠杆
    :param trade_cnt:交易次数
    :return:
    """
    # 遍历胜率
    if lever_list is None:
        lever_list = [1]
    if yr_list is None:
        yr_list = [0.1]
    if lr_list is None:
        lr_list = [0.5]
    if wr_list is None:
        wr_list = [0.6]
    for wr in wr_list:
        win_cnt = int(trade_cnt * wr)
        lose_cnt = trade_cnt - win_cnt
        # 遍历基础收益率
        for yr in yr_list:
            print('\n')
            # 遍历盈亏比
            for lr in lr_list:
                true_yield_rate_list = []
                for _ in range(win_cnt):
                    true_yield_rate_list.append(yr)
                for _ in range(lose_cnt):
                    true_yield_rate_list.append(-yr * lr)
                random.shuffle(true_yield_rate_list)  # 洗个牌,不影响最终收益
                # 遍历杠杆
                for lever in lever_list:
                    result = 1
                    for bs in true_yield_rate_list:
                        result = result * (1 + lever * bs)
                        if result < 0:
                            result = 0
                            break
                    print('wr = {:.2%}, yr = {:.2%},lr = {:.2%}, lever = {},result = {:.2f}'.format(
                        wr, yr, lr, lever, result))

实验:不同盈亏比对最终收益率的影响

懒得上代码和文字结果了,直接看图吧。

60%胜率,10%单次收益率:


60%胜率10%单次收益率不同盈亏比100次交易后的收益曲线

刚开始陡峭上升,后面依旧稳定提升,但是没那么明显了,不过基本也没人能做到后面的部分。盈亏比做好3到4样子就很好了。

实验:不同杠杆对最终收益率的影响

因为真实收益率=杠杆*单倍收益率,所以这里采用固定的收益率1%配合1到200倍的杠杆测试,交易次数为100。

60%胜率,2:1的盈亏比:


可以看到收益率刚开始随着杠杆的增大而增大,大概在85%真实单次收益率时达到最高,120%后开始归零。

60%胜率,10:1超高盈亏比,1~200倍杠杆:


纳尼?看上去似乎杠杆越大越好。我继续增加杠杆到1000。


可以看到在接近600倍杠杆是利润最大,之后开始下降,700左右开始归零。

90%超高胜率,2:1盈亏比:



也是一样的先上升后降低。

貌似效果没有盈亏比的明显,于是把胜率提高99%看看。
然而好像并没有什么卵用,因为没有盈亏比的支撑,超大杠杆之后爆仓了,囧~


实验:不同胜率的影响

4:1盈亏比,单次收益率为5%:



可以看到,胜率对最终收益率的影响基本是指数级的。其实这个好理解,胜率提高之后,赚的多,亏的少,盈余多了很多,加上复利的影响,自然会提升很大。

实验:50%胜率,1:1盈亏比,不同基础收益率下归零需要的次数

我们知道,如果胜率50%,赢1输1,盈亏比例都一样,你其实是会慢慢归零的。比如你有100,赚50%之后是150,再亏50%,就变成了75。看上去赢一次输一次,比例还都一样,但是实际上你的钱会变少。

现在用程序测试,不同基础收益率下归零需要的次数。

测试代码:

def test_trade_cnt_fixed_50wr_50rr(lever=1):
    """
    因为杠杆就是直接增加收益率,所以这里可以只考虑没有杠杆的情况
    """
    for yr in [x * 0.05 for x in range(1,21,1)]:
        result = 1
        trade_cnt = 0
        while True:
            result = result * (1 + lever * yr)
            trade_cnt += 1
            result = result * (1 - lever * yr)
            trade_cnt += 1
            if result < 0.01:
                print(
                    'yr is {:.2f}, be 0 after {} trade'.format(yr, trade_cnt))
                break


test_trade_cnt_fixed_50wr_50rr()

测试结果:

yr is 0.05, be 0 after 3680 trade
yr is 0.10, be 0 after 918 trade
yr is 0.15, be 0 after 406 trade
yr is 0.20, be 0 after 226 trade
yr is 0.25, be 0 after 144 trade
yr is 0.30, be 0 after 98 trade
yr is 0.35, be 0 after 72 trade
yr is 0.40, be 0 after 54 trade
yr is 0.45, be 0 after 42 trade
yr is 0.50, be 0 after 34 trade
yr is 0.55, be 0 after 26 trade
yr is 0.60, be 0 after 22 trade
yr is 0.65, be 0 after 18 trade
yr is 0.70, be 0 after 14 trade
yr is 0.75, be 0 after 12 trade
yr is 0.80, be 0 after 10 trade
yr is 0.85, be 0 after 8 trade
yr is 0.90, be 0 after 6 trade
yr is 0.95, be 0 after 4 trade
yr is 1.00, be 0 after 2 trade

虽然都是亏钱,但是波动小一点能活得久很多。所以如果还没有在市场里验证过的稳定盈利的能力,就尽量低杠杆,这样才能在这个市场活的足够久到你慢慢成长到能稳定盈利。

实验:分批下单对交易结果的影响

现在我们知道盈亏比的重要性。那么怎么提高盈亏比?其中一个方法就是分批下单,使用小仓位测试行情后再跟进,先锋不盈,后续不进。这样损失了部分利润,但是降低了更多的亏损。

假设分成等额的两批,第一批入场后发现不能盈利,亏损出局,那么这样就减少了一半的亏损,可以认为亏损比例降低了50%。同理,如果第一批入场后发现能赢利,补后面的单子,这样第一批是能拿到全部利润的,第二批只能拿到后面的利润。假设在全额利润50%处第二批进场,那么实际总利润只是少了第二批仓位本来该在前面拿到的利润,一半仓位的一半行情,即25%。所以通过分批进场,利润为原来的75%。亏损降低到1/2,利润降低到3/4,R变为(1/2)/(3/4) =2/3,即R变为原来的2/3,盈亏比1/R变为原来的3/2。

这对实际的交易结果有多大的影响呢?用程序测试下。
使用60%的胜率,收益率为10%,没分批前的亏盈比是0.6,分批后是0.4。比较两次的收益情况。

测试代码:

def test_in_batches():
    """
    :return:
    """
    calculate_rate_of_return(lr_list=[0.6], yr_list=[0.1], lever_list=[
        x for x in range(1, 21)], trade_cnt=20)
    calculate_rate_of_return(lr_list=[0.4], yr_list=[0.1], lever_list=[
        x for x in range(1, 21)], trade_cnt=20)


test_in_batches()

测试结果:

#没分批进场前
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 1,result = 1.91
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 2,result = 3.21
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 3,result = 4.76
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 4,result = 6.31
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 5,result = 7.48
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 6,result = 7.92
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 7,result = 7.46
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 8,result = 6.18
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 9,result = 4.44
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 10,result = 2.68
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 11,result = 1.31
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 12,result = 0.49
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 13,result = 0.12
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 14,result = 0.02
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 15,result = 0.00
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 16,result = 0.00
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 17,result = 0.00
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 18,result = 0.00
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 19,result = 0.00
wr = 60.00%, yr = 10.00%,lr = 60.00%, lever = 20,result = 0.00

#分批进场后
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 1,result = 2.26
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 2,result = 4.58
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 3,result = 8.38
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 4,result = 14.05
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 5,result = 21.77
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 6,result = 31.33
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 7,result = 42.08
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 8,result = 52.89
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 9,result = 62.30
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 10,result = 68.80
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 11,result = 71.14
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 12,result = 68.72
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 13,result = 61.75
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 14,result = 51.30
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 15,result = 39.06
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 16,result = 26.92
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 17,result = 16.50
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 18,result = 8.77
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 19,result = 3.89
wr = 60.00%, yr = 10.00%,lr = 40.00%, lever = 20,result = 1.36

可以看到,效果非常明显。没有分批前,在6倍杠杆时出现最大收益7.92,11倍之后开始亏损,14倍之后开始归零。分批后,在11倍杠杆出现最大收益71.14,20倍还没有看到亏损和归零。看到这里,怎么做,不用说了吧?

总结

上一篇下一篇

猜你喜欢

热点阅读