Ejemplo n.º 1
0
def TrendFollowerEx(average                 = None, #mathutils.ewma(alpha = 0.15), 
                    threshold               = 0., 
                    orderFactory            = order.MarketFactory, 
                    creationIntervalDistr   = mathutils.rnd.expovariate(1.), 
                    volumeDistr             = mathutils.rnd.expovariate(1.)):
    
    if average is None:
        average = mathutils.ewma(alpha = 0.15)
    
    orderBook = orderbook.OfTrader()
    trend = observable.Fold(observable.Price(orderBook), 
                            observable.derivative(average))
    
    r = Generic(orderFactory= orderFactory, 
                volumeFunc  = volumeDistr,
                eventGen    = scheduler.Timer(creationIntervalDistr),
                sideFunc    = SignalSide(trend, threshold))
    
    return r
Ejemplo n.º 2
0
 def __init__(self):
     self._eventGen = scheduler.Timer(self.creationIntervalDistr) # TODO: dependency tracking
     self._signalFunc_ = observable.Fold(observable.Price(orderbook.OfTrader()), 
                                        observable.derivative(self.average))
     SignalBase.__init__(self)