Пример #1
0
 def run_sim(self,
             stm=3,
             ns=15,
             min_fast=0.,
             min_slow=0.,
             max_z=1.,
             fast=True,
             fundamental=False):
     s1 = -1. * cross.get_stock_mom(self.rm, stm)
     s2 = cross.get_stock_mom(self.rm, 52).shift(stm)
     s3 = cross.get_stock_mom(self.rm, 52)
     holding = 0
     input1 = s1 if fast else s2
     if fundamental:
         input2 = self.score
     else:
         input2 = s2 if fast else s1
     f = 1. * (s1 >= min_fast) * (s3 >= min_slow) * (self.z <=
                                                     max_z) * (self.z >= 0)
     ans = cross.get_step_positions(input1,
                                    input2,
                                    self.vol,
                                    ns,
                                    f,
                                    None,
                                    holding=holding)
     ra = cross.get_portfolio_returns(ans, self.rtn)
     return ans, ra
Пример #2
0
def get_fast_fundamental_signal(rtn, rm, vol, score, stm=3, ns=8, min_fast=1.5, min_slow=.4):
    '''
    1st Gen fast fundamental signal
    '''
    s1 = -1. * cross.get_stock_mom(rm, stm)
    s3 = cross.get_stock_mom(rm, 52)
    base = 1. * (s1 >= min_fast) * (s3 >= min_slow)
    ans = cross.get_step_positions(s1, score, vol, ns, base, None, holding=0)
    return ans
Пример #3
0
def get_slow_signal(rtn, rm, vol, stm=3, ns=7, min_fast=1.5, min_slow=.4):
    '''
    1st Gen slow signal
    '''
    s1 = -1. * cross.get_stock_mom(rm, stm)
    s2 = cross.get_stock_mom(rm, 52).shift(stm)
    s3 = cross.get_stock_mom(rm, 52)   
    base = 1. * (s1 >= min_fast) * (s3 >= min_slow)
    ans = cross.get_step_positions(s2, s1, vol, ns, base, None, holding=0)
    return ans
Пример #4
0
def get_good_signal(rtn, rm, vol, stm=3, ns=10, min_fast=1.5, min_slow=.4):
    '''
    1st Gen good signal
    '''
    s1 = -1. * cross.get_stock_mom(rm, stm)
    s2 = cross.get_stock_mom(rm, 52).shift(stm)
    s3 = cross.get_stock_mom(rm, 52)
    good = s3.subtract(s3.median(axis=1), axis=0)
    base = 1. * (s1 >= min_fast) * (s3 >= min_slow) * (good >= 0.) 
    ans = cross.get_step_positions(s1, s2, vol, ns, base, None, holding=0)
    return ans