def getImpl(self):
     from marketsim.gen._out._const import const
     from marketsim.gen._out._const import const
     from marketsim.gen._out._const import const
     from marketsim.gen._out.observable.rsi._Raw import Raw
     from marketsim.gen._out.observable.orderbook._MidPrice import MidPrice
     return const(100.0)-const(100.0)/(const(1.0)+Raw(MidPrice(self.book),self.timeframe,self.alpha))
 def getImpl(self):
     from marketsim.gen._out.side._Buy import Buy
     from marketsim.gen._out.side._Sell import Sell
     from marketsim.gen._out.side._Nothing import Nothing
     from marketsim.gen._out._const import const
     from marketsim.gen._out._const import const
     return (self.signal>const(self.threshold))[Buy(), (self.signal<const(0.0-self.threshold))[Sell(), Nothing()]]
def constant(x = 1.):
    from marketsim.gen._out._const import const
    return const(x) if type(x) is float\
        else Constant[float](x) if type(x) is int\
        else Constant[Side](x) if x in [Side.Sell, Side.Buy]\
        else Constant[bool](x) if type(x) is bool\
        else None    
 def getImpl(self):
     from marketsim.gen._out.observable.volumefunc._DesiredPosition import DesiredPosition
     from marketsim.gen._out.observable._OnEveryDt import OnEveryDt
     from marketsim.gen._out._const import const
     from marketsim.gen._out.observable._RSI import RSI
     from marketsim.gen._out.observable.orderbook._OfTrader import OfTrader
     return DesiredPosition(OnEveryDt(1.0,const(50.0)-RSI(OfTrader(self.trader),self.timeframe,self.alpha))*self.k,self.trader)
 def __init__(self, desiredPosition = None, trader = None):
     from marketsim import float
     from marketsim.ops._all import Observable
     from marketsim.gen._out._const import const
     from marketsim.gen._out.observable.trader._SingleProxy import SingleProxy
     from marketsim import _
     from marketsim import event
     Observable[float].__init__(self)
     self.desiredPosition = desiredPosition if desiredPosition is not None else const()
     self.trader = trader if trader is not None else SingleProxy()
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
 def __init__(self, alpha = None, k = None, trader = None):
     from marketsim import float
     from marketsim.ops._all import Observable
     from marketsim.gen._out._const import const
     from marketsim.gen._out.observable.trader._SingleProxy import SingleProxy
     from marketsim import _
     from marketsim import event
     Observable[float].__init__(self)
     self.alpha = alpha if alpha is not None else 0.15
     self.k = k if k is not None else const(0.5)
     self.trader = trader if trader is not None else SingleProxy()
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
 def __init__(self, source = None, timeframe = None):
     from marketsim.gen._out._const import const
     from marketsim import event
     from marketsim import types
     from marketsim import event
     from marketsim import types
     self.source = source if source is not None else const()
     self.timeframe = timeframe if timeframe is not None else 10.0
     Lagged_Impl.__init__(self)
     if isinstance(source, types.IEvent):
         event.subscribe(self.source, self.fire, self)
     if isinstance(timeframe, types.IEvent):
         event.subscribe(self.timeframe, self.fire, self)
Exemple #8
0
def convert(other):
    from marketsim.gen._out._const import const
    if type(other) in [int, float]:
        other = const(other)
    return other
Exemple #9
0
 def const(self):
     from marketsim.gen._out._const import const
     return const(self)
Exemple #10
0
 def const(self):
     from marketsim.gen._out._const import const
     return const(self)
 def __init__(self, source = None, timeframe = None):
     from marketsim.gen._out._const import const
     self.source = source if source is not None else const()
     self.timeframe = timeframe if timeframe is not None else 100.0
     self.impl = self.getImpl()
 def __init__(self, source = None, alpha = None):
     from marketsim.gen._out._const import const
     self.source = source if source is not None else const()
     self.alpha = alpha if alpha is not None else 0.015
     self.impl = self.getImpl()
 def getImpl(self):
     from marketsim.gen._out.side._Sell import Sell
     from marketsim.gen._out.side._Buy import Buy
     from marketsim.gen._out._const import const
     return (self.side_distribution>const(0.5))[Sell(), Buy()]
 def getImpl(self):
     return const(self.x)
 def getImpl(self):
     from marketsim.gen._out.observable._Max import Max
     from marketsim.gen._out._const import const
     from marketsim.gen._out.observable._Lagged import Lagged
     return Max(const(0.0),Lagged(self.source,self.timeframe)-self.source)
Exemple #16
0
 def __init__(self, source = None):
     from marketsim.gen._out._const import const
     self.source = source if source is not None else const()
     CMA_Impl.__init__(self)
 def getImpl(self):
     from marketsim.gen._out.observable.orderbook._AskPrice import AskPrice
     from marketsim.gen._out.observable.orderbook._BidPrice import BidPrice
     from marketsim.gen._out._const import const
     return (AskPrice(self.book)+BidPrice(self.book))/const(2.0)