Exemplo n.º 1
0
@meta.sig(args=(types.IFunction[float],), rv=types.IFunction[float])
def atanpow(f, base = 1.002):
    return ops.Atan(ops.Pow(ops.constant(base), f))

@registry.expose(alias=['Clamp0'])
@meta.sig(args=(types.IFunction[float],), rv=types.IFunction[float])
def clamp0(f):
    return ops.Max(f, ops.constant(0)) + 1

def identity(x):
    return x

Ts = [float, meta.listOf(float), types.IFunction[float]]
identity._types = [meta.function((t,), t) for t in Ts]

registry.expose(alias=['identity'])(identity)

def cachedattr(obj, name, setter):
    if not hasattr(obj, name):
        setattr(obj, name, setter())
        
    return getattr(obj, name)

@registry.expose(alias=['Efficiency'])
@meta.sig(args=(types.IAccount,), rv=types.IFunction[float])
def efficiency(trader):
    return cachedattr(trader, '_efficiency', 
                      lambda: observable.Efficiency(trader))

from marketsim.gen._out.observable.trader._EfficiencyTrend import EfficiencyTrend
Exemplo n.º 2
0
            return price
        return None
    
    @property
    def digits(self):
        return self.orderbook._digitsToShow
    
    @property
    def label(self):
        return "PriceAtVolume_{"+str(self.volumeAt)+"}("+self.orderbook.queue(self.side).label+")" 
    
    _properties = { 'orderbook' : types.IOrderBook, 
                    'side'      : types.Side, 
                    'volumeAt'  : float }

registry.expose(alias = ["Asset's", "Ask", "Price at volume"], args = (None, Side.Sell))(price_at_volume)
registry.expose(alias = ["Asset's", "Bid", "Price at volume"], args = (None, Side.Buy))(price_at_volume)

class volume_levels(ops.Function[types.IVolumeLevels]): 
    
    def __init__(self, 
                 orderbook = None, 
                 side = Side.Sell, 
                 volumeDelta = 30, 
                 volumeCount = 10):
        
        self.orderbook = orderbook if orderbook else marketsim.orderbook.Proxy()
        self.side = side
        self.volumeDelta = volumeDelta
        self.volumeCount = volumeCount