Beispiel #1
0
def alpha8(df):
    """
    Alpha#8
    (-1 * rank(((sum(open, 5) * sum(returns, 5)) - delay((sum(open, 5) * 
    sum(returns, 5)), 10))))
    """
    temp1 = (u.ts_sum(df.open, 5) * u.ts_sum(df.returns, 5))
    temp2 = u.delay((u.ts_sum(df.open, 5) * u.ts_sum(df.returns, 5)), 10)
    return (-1 * u.rank(temp1 - temp2))
Beispiel #2
0
def alpha45(df):
    """
    Alpha#45
    (-1 * ((rank((sum(delay(close, 5), 20) / 20)) * correlation(close, volume, 2)) 
    * rank(correlation(sum(close, 5), sum(close, 20), 2)))) 
    """
    temp1 = u.rank((u.ts_sum(u.delay(df.close, 5), 20) / 20))
    temp2 = u.corr(df.close, df.volume, 2)
    temp3 = u.rank(u.corr(u.ts_sum(df.close, 5), u.ts_sum(df.close, 20), 2))
    return (-1 * ((temp1 * temp2) * temp3))
Beispiel #3
0
def alpha95(df):
    """
    Alpha#95
    (rank((open - ts_min(open, 12.4105))) < Ts_Rank((rank(correlation(sum(((high + low)
    / 2), 19.1351), sum(adv40, 19.1351), 12.8742))^5), 11.7584)) 
    """
    temp1 = u.rank((df.open - u.ts_min(df.open, 12)))
    temp2 = u.corr(u.ts_sum(((df.high + df.low) / 2), 19),
                   u.ts_sum(u.adv(df, 40), 19), 13)
    return (temp1 < u.ts_rank((u.rank(temp2)**5), 12))
Beispiel #4
0
def alpha52(df):
    """
    Alpha#52
    ((((-1 * ts_min(low, 5)) + delay(ts_min(low, 5), 5)) * rank(((sum(returns, 240) 
    - sum(returns, 20)) / 220))) * ts_rank(volume, 5)) 
    """
    temp1 = ((-1 * u.ts_min(df.low, 5)) + u.delay(u.ts_min(df.low, 5), 5))
    temp2 = u.rank(
        ((u.ts_sum(df.returns, 240) - u.ts_sum(df.returns, 20)) / 220))
    return ((temp1 * temp2) * u.ts_rank(df.volume, 5))
Beispiel #5
0
def alpha78(df):
    """
    Alpha#78
    (rank(correlation(sum(((low * 0.352233) + (vwap * (1 - 0.352233))), 19.7428),
    sum(adv40, 19.7428), 6.83313))^rank(correlation(rank(vwap), rank(volume), 5.77492)))
    """
    temp1 = u.ts_sum(((df.low * 0.352233) + (df.vwap * (1 - 0.352233))), 20)
    temp2 = u.rank(u.corr(u.rank(df.vwap), u.rank(df.volume), 6))
    temp3 = u.rank(u.corr(temp1, u.ts_sum(u.adv(df, 40), 20), 7))
    return (temp3**temp2)
Beispiel #6
0
def alpha30(df):
    """
    Alpha#30
     (((1.0 - rank(((sign((close - delay(close, 1))) + 
     sign((delay(close, 1) - delay(close, 2)))) +
     sign((delay(close, 2) - delay(close, 3)))))) * sum(volume, 5)) / sum(volume, 20)) 
    """
    return (((1.0 - u.rank(((np.sign((df.close - u.delay(df.close, 1))) \
            + np.sign((u.delay(df.close, 1) - u.delay(df.close, 2))))   \
            + np.sign((u.delay(df.close, 2) - u.delay(df.close, 3)))))) \
            * u.ts_sum(df.volume, 5)) / u.ts_sum(df.volume, 20))
Beispiel #7
0
def alpha99(df):
    """
    Alpha#99
    ((rank(correlation(sum(((high + low) / 2), 19.8975), sum(adv60, 19.8975), 8.8136)) 
    < rank(correlation(low, volume, 6.28259))) * -1) 
    """
    temp1 = u.rank(
        u.corr(u.ts_sum(((df.high + df.low) / 2), 20),
               u.ts_sum(u.adv(df, 60), 20), 9))
    temp2 = u.rank(u.corr(df.low, df.volume, 6))
    return pd.Series(np.where(temp1 < temp2, temp1 * -1, temp2 * -1),
                     index=df.index)
Beispiel #8
0
def alpha83(df):
    """
    Alpha#83
    ((rank(delay(((high - low) / (sum(close, 5) / 5)), 2)) * rank(rank(volume))) 
    / (((high - low) / (sum(close, 5) / 5)) / (vwap - close)))
    """
    temp1 = u.rank(
        u.delay(((df.high - df.low) /
                 (u.ts_sum(df.close, 5) / 5)), 2)) * u.rank(u.rank(df.volume))
    temp2 = (((df.high - df.low) / (u.ts_sum(df.close, 5) / 5)) /
             (df.vwap - df.close))
    return (temp1 / temp2)
Beispiel #9
0
def alpha64(df):
    """
    Alpha#64
    ((rank(correlation(sum(((open * 0.178404) + (low * (1 - 0.178404))), 12.7054),
    sum(adv120, 12.7054), 16.6208)) < rank(delta(((((high + low) / 2) * 0.178404) 
    + (vwap * (1 -0.178404))), 3.69741))) * -1) 
    """
    temp1 = u.ts_sum(((df.open * 0.178404) + (df.low * (1 - 0.178404))), 13)
    temp2 = u.rank(u.corr(temp1, u.ts_sum(u.adv(df, 120), 18), 17))
    temp3 = u.rank(
        u.delta(((((df.high + df.low) / 2) * 0.178404) + (df.vwap *
                                                          (1 - 0.178404))), 4))
    return ((temp2 < temp3) * -1)
Beispiel #10
0
def alpha21(df):
    """
    Alpha#21
    ((((sum(close, 8) / 8) + stddev(close, 8)) < (sum(close, 2) / 2)) ? (-1 * 1) : 
    (((sum(close,2) / 2) < ((sum(close, 8) / 8) - stddev(close, 8))) ? 
    1 : (((1 < (volume / adv20)) || ((volume /adv20) == 1)) ? 1 : (-1 * 1)))) 
    """
    decision1 = (u.ts_sum(df.close, 8) / 8 +
                 u.stddev(df.close, 8)) < (u.ts_sum(df.close, 2) / 2)
    decision2 = (u.ts_sum(df.close, 2) / 2 <
                 (u.ts_sum(df.close, 8) / 8) - u.stddev(df.close, 8))
    decision3 = ((1 < (df.volume / u.adv(df, 20))) |
                 ((df.volume / u.adv(df, 20)) == 1))
    return np.where(decision1, (-1 * 1),
                    np.where(decision2, 1, np.where(decision3, 1, (-1 * 1))))
Beispiel #11
0
def alpha5(df):
    """
    Alpha#5
    (rank((open - (sum(vwap, 10) / 10))) * (-1 * abs(rank((close - vwap))))) 
    """
    return (u.rank((df.open - (u.ts_sum(df.vwap, 10) / 10))) *
            (-1 * abs(u.rank((df.close - df.vwap)))))
Beispiel #12
0
def alpha23(df):
    """
    Alpha#23
    (((sum(high, 20) / 20) < high) ? (-1 * delta(high, 2)) : 0) 
    """
    return pd.Series(
        np.where((u.ts_sum(df.high, 20) / 20) < df.high,
                 (-1 * u.delta(df.high, 2)), 0), df.index)
Beispiel #13
0
def alpha39(df):
    """
    Alpha#39

    """
    temp = (-1 * u.rank(
        (u.delta(df.close, 7) *
         (1 - u.rank(u.decay_linear((df.volume / u.adv(df, 20)), 9))))))
    return (temp * (1 + u.rank(u.ts_sum(df.returns, 250))))
Beispiel #14
0
def alpha32(df):
    """
    Alpha#32
    (scale(((sum(close, 7) / 7) - close)) + 
    (20 * scale(correlation(vwap, delay(close, 5), 230)))) 
    """
    temp1 = u.scale(((u.ts_sum(df.close, 7) / 7) - df.close))
    temp2 = (20 * u.scale(u.corr(df.vwap, u.delay(df.close, 5), 230)))
    return temp1 + temp2
Beispiel #15
0
def alpha27(df):
    """
    Alpha#27
    ((0.5 < rank((sum(correlation(rank(volume), rank(vwap), 6), 2) / 2.0))) ? (-1 * 1) : 1) 
    """
    temp = np.where((0.5 < u.rank(
        (u.ts_sum(u.corr(u.rank(df.volume), u.rank(df.vwap), 6), 2) / 2.0))),
                    (-1 * 1), 1)
    return pd.Series(temp, index=df.index)
Beispiel #16
0
def alpha86(df):
    """
    Alpha#86
    ((Ts_Rank(correlation(close, sum(adv20, 14.7444), 6.00049), 20.4195) 
    < rank(((open + close) - (vwap + open)))) * -1)
    """
    temp1 = u.ts_rank(u.corr(df.close, u.ts_sum(u.adv(df, 20), 15), 6), 20)
    temp2 = u.rank(((df.open + df.close) - (df.vwap + df.open)))
    return ((temp1 < temp2) * -1)
Beispiel #17
0
def alpha62(df):
    """
    Alpha#62
    ((rank(correlation(vwap, sum(adv20, 22.4101), 9.91009)) < rank(((rank(open) 
    + rank(open)) < (rank(((high + low) / 2)) + rank(high))))) * -1) 
    """
    temp1 = u.rank(u.corr(df.vwap, u.ts_sum(u.adv(df, 20), 22), 10))
    temp2 = u.rank(((u.rank(df.open) + u.rank(df.open)) < (u.rank(
        ((df.high + df.low) / 2)) + u.rank(df.high))))
    return ((temp1 < temp2) * -1)
Beispiel #18
0
def alpha19(df):
    """
    Alpha#19
    ((-1 * sign(((close - delay(close, 7)) + delta(close, 7)))) * 
    (1 + rank((1 + sum(returns, 250)))))
    """
    temp1 = (-1 * np.sign(
        ((df.close - u.delay(df.close, 7)) + u.delta(df.close, 7))))
    temp2 = (1 + u.rank((1 + u.ts_sum(df.returns, 250))))
    return (temp1 * temp2)
Beispiel #19
0
def alpha65(df):
    """
    Alpha#65
    ((rank(correlation(((open * 0.00817205) + 
    (vwap * (1 - 0.00817205))), sum(adv60, 8.6911), 6.40374)) < rank((open - ts_min(open, 13.635)))) * -1) 
    """
    temp1 = (df.open * 0.00817205) + (df.vwap * (1 - 0.00817205))
    temp2 = u.rank((df.open - u.ts_min(df.open, 14)))
    return ((u.rank(u.corr(temp1, u.ts_sum(u.adv(df, 60), 9), 6)) < temp2) *
            -1)
Beispiel #20
0
def alpha47(df):
    """
    Alpha#47
    ((((rank((1 / close)) * volume) / adv20) * 
    ((high * rank((high - close))) / (sum(high, 5) / 5))) - rank((vwap - delay(vwap, 5)))) 
    """
    temp1 = ((u.rank((1 / df.close)) * df.volume) / u.adv(df, 20))
    temp2 = ((df.high * u.rank(
        (df.high - df.close))) / (u.ts_sum(df.high, 5) / 5))
    return ((temp1 * temp2) - u.rank((df.vwap - u.delay(df.vwap, 5))))
Beispiel #21
0
def alpha74(df):
    """
    Alpha#74
    ((rank(correlation(close, sum(adv30, 37.4843), 15.1365)) 
    < rank(correlation(rank(((high * 0.0261661) 
    + (vwap * (1 - 0.0261661)))), rank(volume), 11.4791))) * -1)
    """
    temp1 = u.rank(u.corr(df.close, u.ts_sum(u.adv(df, 30), 37), 15))
    temp2 = u.rank(
        u.corr(u.rank(((df.high * 0.0261661) + (df.vwap * (1 - 0.0261661)))),
               u.rank(df.volume), 11))
    return ((temp1 < temp2) * -1)
Beispiel #22
0
def alpha24(df):
    """
    Alpha#24
    Can be shortened without the || (or operator) and just use the <= statement.
    ((((delta((sum(close, 100) / 100), 100) / delay(close, 100)) < 0.05) ||
    ((delta((sum(close, 100) / 100), 100) / delay(close, 100)) == 0.05)) ? 
    (-1 * (close - ts_min(close, 100))) : (-1 * delta(close, 3))) 
    """
    decision = u.delta(
        (u.ts_sum(df.close, 100) / 100), 100) / u.delay(df.close, 100) <= 0.05
    if_true = (-1 * (df.close - u.ts_min(df.close, 100)))
    if_false = (-1 * u.delta(df.close, 3))
    return pd.Series(np.where(decision, if_true, if_false), df.index)
Beispiel #23
0
def alpha98(df):
    """
    Alpha#98
    (rank(decay_linear(correlation(vwap, sum(adv5, 26.4719), 4.58418), 7.18088)) -
    rank(decay_linear(Ts_Rank(Ts_ArgMin(correlation(rank(open), rank(adv15), 20.8187), 8.62571),
    6.95668), 8.07206))) 
    """
    temp1 = u.ts_rank(
        u.ts_argmin(u.corr(u.rank(df.open), u.rank(u.adv(df, 15)), 21), 9), 7)
    temp2 = u.rank(u.decay_linear(temp1, 8.07206))
    temp3 = u.rank(
        u.decay_linear(u.corr(df.vwap, u.ts_sum(u.adv(df, 5), 26), 5), 7))
    return (temp3 - temp2)
Beispiel #24
0
def alpha81(df):
    """
    Alpha#81
    ((rank(Log(product(rank((rank(correlation(vwap, sum(adv10, 49.6054),
    8.47743))^4)), 14.9655))) < rank(correlation(rank(vwap), rank(volume), 5.07914))) * -1)
    """
    temp = u.rank(
        np.log(
            u.product(
                u.rank(
                    u.rank(u.corr(df.vwap, u.ts_sum(u.adv(df, 10), 50),
                                  8))**4), 15)))
    return ((temp < u.rank(u.corr(u.rank(df.vwap), u.rank(df.volume), 5))) *
            -1)
Beispiel #25
0
def alpha29(df):
    """
    Alpha#29
    (min(product(rank(rank(scale(log(sum(ts_min(rank(rank((-1 * rank(delta((close - 1),
    5))))), 2), 1))))), 1), 5) + ts_rank(delay((-1 * returns), 6), 5)) 
    """
    temp1 = u.scale(
        np.log(
            u.ts_sum(
                u.ts_min(
                    u.rank(u.rank((-1 * u.rank(u.delta((df.close - 1), 5))))),
                    2), 1)))
    temp2 = u.product(u.rank(u.rank(temp1)), 1)
    temp3 = u.ts_rank(u.delay((-1 * df.returns), 6), 5)
    return (np.where(temp1 < temp2, temp1, temp2) + temp3)
Beispiel #26
0
def alpha15(df):
    """
    Alpha#15
    (-1 * sum(rank(correlation(rank(high), rank(volume), 3)), 3)) 
    """
    return (-1 * u.ts_sum(u.corr(u.rank(df.high), u.rank(df.volume), 3), 3))