Ejemplo n.º 1
0
 def __init__(self):
     event.subscribe(self.inner.on_order_created, _(self).onOrderCreated, self)
     event.subscribe(observable.OnOrderMatched(), _(self)._onOrderMatched, self)
     self.on_traded = event.Event()
     self.orderBook = orderbook.OfTrader()
     self._balance = 0
     self._position = 0
Ejemplo n.º 2
0
 def __init__(self, lhs, rhs):
     self.lhs = lhs
     self.rhs = rhs 
     if types.IEvent in inspect.getmro(type(lhs)):
         event.subscribe(lhs, _(self).fire, self)
     if types.IEvent in inspect.getmro(type(rhs)):
         event.subscribe(rhs, _(self).fire, self)
    def __init__(self):
        self.ask = self.book.Asks.BestPrice
        self.bid = self.book.Bids.BestPrice

        self.reset()
        event.subscribe(self.ask, _(self)._update, self)
        event.subscribe(self.bid, _(self)._update, self)
        event.subscribe(self.depth, _(self)._update, self)
Ejemplo n.º 4
0
 def bind_impl(self, ctx):
     if not hasattr(self, '_subscriptions'):
         self.trader.bind_ex(ctx)
         event.subscribe(self.trader.on_order_matched, _(self).onOrderMatched, self)
         event.subscribe(self.trader.on_order_disposed, _(self).onOrderDisposed, self)
         for x in self._subscriptions:
             x.bind_ex(ctx)
         self._bound_ex = True
Ejemplo n.º 5
0
 def __init__(self):
     event.subscribe(self.inner.on_order_created, _(self).onOrderCreated, self)
     event.subscribe(OnOrderMatched(), _(self)._onOrderMatched, self)
     from marketsim.gen._out.event._event import Event
     self.on_traded = Event()
     self.orderBook = OfTrader()
     self._balance = 0
     self._position = 0
    def __init__(self):

        ops.Observable[float].__init__(self)

        self.price = LastTradePrice(self.book)

        self.reset()
        event.subscribe(self.price, _(self)._update, self)
        event.subscribe(self.depth, _(self)._update, self)
Ejemplo n.º 7
0
 def __init__(self):
     Strategy.__init__(self)
     props = dict([(k, getattr(self, k)) for k in self._properties.iterkeys() ])
     sp = merge_dict(props, side=Side.Sell)
     bp = merge_dict(props, side=Side.Buy) 
     self._sell = LiquidityProviderSide(**sp)
     self._buy = LiquidityProviderSide(**bp)
     event.subscribe(self._sell.on_order_created, _(self)._send, self)
     event.subscribe(self._buy.on_order_created, _(self)._send, self)
Ejemplo n.º 8
0
 def __init__(self, source, timeframe = 1.):
     ops.Observable[types.ICandleStick].__init__(self)
     self._source = source
     self._event = event.subscribe(source, _(self)._update, self)
     event.subscribe(event.Every(ops.constant(timeframe)), _(self)._flush, self)
     self.timeframe = timeframe
     self.reset()
     self._mean = CMA(source)
     self._stddev = StdDev(source)
Ejemplo n.º 9
0
 def __init__(self, queue, book, link):
     self._queue = queue
     self.book = book
     self._link = link
     queue.bestPrice += _(self)._onBestChanged
     self.bestPrice = BestPrice(self)
     self.lastTrade = LastTrade()
     queue.lastTrade += _(self)._onTraded
     self.reset()
Ejemplo n.º 10
0
    def __init__(self):
        Strategy.__init__(self)
        from marketsim._pub import strategy, side

        self._seller = strategy.price.Ladder(self.orderFactory, self.initialSize, side.Sell())
        self._buyer = strategy.price.Ladder(self.orderFactory, self.initialSize, side.Buy())

        event.subscribe(self._seller.on_order_created, _(self)._send, self)
        event.subscribe(self._buyer.on_order_created, _(self)._send, self)
Ejemplo n.º 11
0
 def __init__(self, cond, ifpart, elsepart):
     self.cond = cond
     self.ifpart = ifpart
     self.elsepart = elsepart
     if types.IEvent in inspect.getmro(type(cond)):
         event.subscribe(cond, _(self).fire, self)
     if types.IEvent in inspect.getmro(type(ifpart)):
         event.subscribe(ifpart, _(self).fire, self)
     if types.IEvent in inspect.getmro(type(elsepart)):
         event.subscribe(elsepart, _(self).fire, self)
Ejemplo n.º 12
0
    def __init__(self):
        Strategy.__init__(self)
        from marketsim._pub import trader, orderbook
        self._balance = trader.Balance()
        self._position = trader.Position()
        self._pendingVolume = trader.PendingVolume()
        self._internalSuspended = False

        event.subscribe(self.inner.on_order_created, _(self)._send, self)
        event.subscribe(self.predicate, _(self)._wakeUp, self)
Ejemplo n.º 13
0
 def __init__(self):
     Strategy.__init__(self)
     self._current = None
     self._estimators = []
     for s in self.strategies:
         event.subscribe(s.on_order_created, _(self).send, self)
         e = self.performance(self.account(s))
         e._origin = s
         self._estimators.append(e)
     event.subscribe(event.Every(ops.constant(1.)), _(self)._wakeUp, self)
Ejemplo n.º 14
0
 def onOrderMatched(self, order, price, volume):
     if order is not self._stopLossOrder:
         if volume > 0:
             handler = event.GreaterThan((1+self._maxloss) * price, _(self)._onPriceChanged)\
                         if self.side == Side.Sell else\
                       event.LessThan((1-self._maxloss) * price, _(self)._onPriceChanged)
                         
             self._stopSubscription = event.subscribe(self._obsPrice, handler, self, self._ctx)
             self.onMatchedWith(price, +volume)
     else:
         self.onMatchedWith(price, -volume)
Ejemplo n.º 15
0
 def onOrderMatched(self, order, price, volume):
     from marketsim.gen._out._side import Side
     from marketsim.gen._out.event._greaterthan import GreaterThan
     from marketsim.gen._out.event._lessthan import LessThan
     if order is not self._stopLossOrder:
         if volume > 0:
             handler = GreaterThan((1+self._maxloss) * price, _(self)._onPriceChanged)\
                         if self.side == Side.Sell else\
                       LessThan((1-self._maxloss) * price, _(self)._onPriceChanged)
                         
             self._stopSubscription = event.subscribe(self._obsPrice, handler, self)
             self._stopSubscription.bind_ex(self._ctx_ex)
             self.onMatchedWith(price, +volume)
     else:
         self.onMatchedWith(price, -volume)
 def _update(self, dummy = None):
     depth = self.depth()
     side = Side.Buy if depth < 0 else Side.Sell
     self.book.process(
                     request.EvalMarketOrder(side,
                                             abs(depth),
                                             _(self, -sign(depth))._callback))
Ejemplo n.º 17
0
 def __init__(self):
     self._efficiency = Efficiency(self.trader)
     event.subscribe(
             OnEveryDt(self._efficiency, 1),
              _(self)._update, self)
     self._score = 1
     self._last = 0
Ejemplo n.º 18
0
    def __init__(self):
        self.attributes = {"smooth":True}

        self._timer = event.Every(self.intervalDistr)
        event.subscribe(self._timer, _(self)._wakeUp, self)
        
        self.reset()
Ejemplo n.º 19
0
 def __init__(self, source = ops.constant(1.)):
     ops.Observable[float].__init__(self)
     
     self._source = source
     self._event = event.subscribe(source, _(self)._wakeup, self)
     self._previous = None
     self._value = None
Ejemplo n.º 20
0
 def __init__(self, source, folder):
     """ Initializes folder with source of values and accumulator object        
     """
     self._acc = folder
     self._source = source
     self._event = event.subscribe(self._source, _(self)._update, self)
     self._alias = ["_details", "fold", "old"]
Ejemplo n.º 21
0
 def process(self, order):
     if isinstance(order, types.IOrder):
         BookBase.process(self, order)
     else:
         # if 'callback' in dir(order):
         #    order.callback = _(self, order.callback)._sendToDownLink
         self._upLink.send(_(self._book, order).process)
Ejemplo n.º 22
0
 def __init__(self, source, graph, _digits = 4, _smooth = False):
     self._source = source
     self.graph = graph
     self.attributes = getattr(source, 'attributes', {})
     self._smooth =  1 if 'smooth' in self.attributes and self.attributes['smooth'] else 0
     self._lastPoint = None
     self._event = event.subscribe(source, _(self)._wakeUp, self)
     self.reset()
Ejemplo n.º 23
0
 def __init__(self, ticker = "^GSPC", start = "2001-1-1", end = "2010-1-1"):
     ops.Observable[float].__init__(self)
     self.ticker = ticker
     self.start = start
     self.end = end
     self._quotes = None
     self._current = None
     event.subscribe(event.Every(ops.constant(1)), _(self)._wakeUp, self)
Ejemplo n.º 24
0
 def process(self, order):
     from marketsim.gen._out._iorder import IOrder
     if isinstance(order, IOrder):
         BookBase.process(self, order)
     else:
         #if 'callback' in dir(order):
         #    order.callback = _(self, order.callback)._sendToDownLink
         self._upLink.send(_(self.orderbook, order).process)
Ejemplo n.º 25
0
 def __init__(self, trader):
     self.trader = trader
     self._efficiency = observable.Efficiency(trader)
     event.subscribe(
             observable.OnEveryDt(1, self._efficiency),
              _(self)._update, self)
     self._score = 1
     self._last = 0
Ejemplo n.º 26
0
    def __init__(self):
        """ Initializes EWMA with \alpha = alpha
        """
        from marketsim.gen._out._ievent import IEvent

        self._event = event.subscribe(self.x.source, _(self)._update, self)

        self.reset()
Ejemplo n.º 27
0
 def update(self, t, x):
     if x is not None and (self._x is None or x > self._x):
         if -x not in self._levels:
             self._levels[-x] = 0
         self._levels[-x] += 1 
         self._scheduler.scheduleAfter(self.timeframe, _(self, x)._remove)
     self._x = x
     self.fire(self)
Ejemplo n.º 28
0
 def onOrderCreated(self, order, source):
     self.orderBook.process(
                 request.EvalMarketOrder(
                             order.side,
                             order.volumeUnmatched,
                             _(self,
                               order.side,
                               order.volumeUnmatched)._update))
Ejemplo n.º 29
0
    def __init__(self, bids, asks):
        """ Initializes empty order book with given tick size
        """
        Holder_Impl.__init__(self)
        self._bids = bids
        self._asks = asks
        # queues indexed by their side
        self._queues = [0, 0]
        self._queues[self._bids.side.id] = self._bids
        self._queues[self._asks.side.id] = self._asks
        if self.name != "":
            self._alias = [self.name]

        self.lastTrade = LastTradeImpl()
        event.subscribe(self._asks.lastTrade, _(self.lastTrade)._retranslate, self)
        event.subscribe(self._bids.lastTrade, _(self.lastTrade)._retranslate, self)
        
        self.reset()
Ejemplo n.º 30
0
    def __init__(self):
        """ Initializes EWMA with \alpha = alpha
        """
        if not isinstance(self.source, types.IEvent):
            self.source = OnEveryDt(1, self.source)

        self._event = event.subscribe(self.source, _(self)._update, self)

        self.reset()
Ejemplo n.º 31
0
 def __init__(self, source=None, timeframe=None):
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import _
     from marketsim import event
     from marketsim.gen._out._observable._observablefloat import Observablefloat
     from marketsim import deref_opt
     Observablefloat.__init__(self)
     self.source = source if source is not None else deref_opt(
         _const_Float(1.0))
     self.timeframe = timeframe if timeframe is not None else 10.0
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 32
0
 def __init__(self, book=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.orderbook._oftrader import OfTrader_IAccount as _orderbook_OfTrader_IAccount
     from marketsim import event
     from marketsim.gen._out._observable import Observablefloat
     Observablefloat.__init__(self)
     self.book = book if book is not None else _orderbook_OfTrader_IAccount(
     )
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 33
0
 def __init__(self, source=None, timeframe=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import event
     from marketsim.gen._out._observable import Observablefloat
     Observablefloat.__init__(self)
     self.source = source if source is not None else _const_Float(1.0)
     self.timeframe = timeframe if timeframe is not None else 10.0
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 34
0
 def __init__(self, signal=None, threshold=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out._constant import constant_Float as _constant_Float
     from marketsim.gen._out._side import Side
     from marketsim import event
     from marketsim.gen._out._observable import ObservableSide
     ObservableSide.__init__(self)
     self.signal = signal if signal is not None else _constant_Float(0.0)
     self.threshold = threshold if threshold is not None else 0.7
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 35
0
 def __init__(self, inner = None, lossFactor = None):
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim.gen._out.strategy.price._laddermm import LadderMM_SideFloatIObservableIOrderInt as _strategy_price_LadderMM_SideFloatIObservableIOrderInt
     from marketsim.gen._out.event._event import Event
     from marketsim import _
     from marketsim import event
     from marketsim import deref_opt
     self.inner = inner if inner is not None else deref_opt(_strategy_price_LadderMM_SideFloatIObservableIOrderInt())
     self.lossFactor = lossFactor if lossFactor is not None else deref_opt(_const_Float(0.2))
     self.impl = self.getImpl()
     
     self.on_order_created = Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 36
0
 def __init__(self, desiredPosition = None, trader = None):
     from marketsim.gen._out.trader._singleproxy import SingleProxy_ as _trader_SingleProxy_
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import event
     from marketsim.gen._out._observable import Observablefloat
     Observablefloat.__init__(self)
     self.desiredPosition = desiredPosition if desiredPosition is not None else _const_Float(1.0)
     self.trader = trader if trader is not None else _trader_SingleProxy_()
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 37
0
 def __init__(self, x=None, elsePart=None):
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import _
     from marketsim import event
     from marketsim.gen._out._observable._observablefloat import Observablefloat
     from marketsim.gen._out._constant import constant_Float as _constant_Float
     from marketsim import deref_opt
     Observablefloat.__init__(self)
     self.x = x if x is not None else deref_opt(_const_Float(1.0))
     self.elsePart = elsePart if elsePart is not None else deref_opt(
         _constant_Float(1.0))
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 38
0
 def __init__(self, orderFactory = None, alpha = None, k = None):
     from marketsim.gen._out.order._curried._signedvolume_marketsigned import signedVolume_MarketSigned_ as _order__curried_signedVolume_MarketSigned_
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import event
     self.orderFactory = orderFactory if orderFactory is not None else _order__curried_signedVolume_MarketSigned_()
     self.alpha = alpha if alpha is not None else 0.15
     self.k = k if k is not None else _const_Float(0.5)
     rtti.check_fields(self)
     self.impl = self.getImpl()
     self.on_order_created = event.Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 39
0
 def __init__(self, x=None, y=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out._constant import constant_Float as _constant_Float
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import event
     from marketsim.gen._out._observable import Observablefloat
     Observablefloat.__init__(self)
     self.x = x if x is not None else _constant_Float(1.0)
     self.y = y if y is not None else _const_Float(1.0)
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 40
0
 def __init__(self, x=None, side=None):
     from marketsim.gen._out.side._sell import Sell_ as _side_Sell_
     from marketsim import _
     from marketsim import event
     from marketsim.gen._out._observable._observablefloat import Observablefloat
     from marketsim.gen._out.strategy.price._liquidityprovider import LiquidityProvider_FloatFloatIOrderBook as _strategy_price_LiquidityProvider_FloatFloatIOrderBook
     from marketsim import deref_opt
     Observablefloat.__init__(self)
     self.x = x if x is not None else deref_opt(
         _strategy_price_LiquidityProvider_FloatFloatIOrderBook())
     self.side = side if side is not None else deref_opt(_side_Sell_())
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 41
0
 def __init__(self, alpha=None, k=None, trader=None):
     from marketsim.gen._out.trader._singleproxy import SingleProxy_ as _trader_SingleProxy_
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import event
     from marketsim.gen._out._observable import Observablefloat
     Observablefloat.__init__(self)
     self.alpha = alpha if alpha is not None else 0.15
     self.k = k if k is not None else _const_Float(0.5)
     self.trader = trader if trader is not None else _trader_SingleProxy_()
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 42
0
 def __init__(self, eventGen = None, orderFactory = None, ewma_alpha = None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.order._curried._side_market import side_Market_Float as _order__curried_side_Market_Float
     from marketsim.gen._out.event._every import Every_Float as _event_Every_Float
     from marketsim.gen._out.math.random._expovariate import expovariate_Float as _math_random_expovariate_Float
     from marketsim import event
     self.eventGen = eventGen if eventGen is not None else _event_Every_Float(_math_random_expovariate_Float(1.0))
     self.orderFactory = orderFactory if orderFactory is not None else _order__curried_side_Market_Float()
     self.ewma_alpha = ewma_alpha if ewma_alpha is not None else 0.15
     rtti.check_fields(self)
     self.impl = self.getImpl()
     self.on_order_created = event.Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 43
0
 def __init__(self, queue=None, defaultValue=None):
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import _
     from marketsim import event
     from marketsim.gen._out._observable._observablefloat import Observablefloat
     from marketsim.gen._out.orderbook._asks import Asks_IOrderBook as _orderbook_Asks_IOrderBook
     from marketsim import deref_opt
     Observablefloat.__init__(self)
     self.queue = queue if queue is not None else deref_opt(
         _orderbook_Asks_IOrderBook())
     self.defaultValue = defaultValue if defaultValue is not None else deref_opt(
         _const_Float(100.0))
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 44
0
 def __init__(self, book=None, depth=None):
     from marketsim.gen._out._const import const_Float as _const_Float
     from marketsim import _
     from marketsim import event
     from marketsim.gen._out._observable._observablefloat import Observablefloat
     from marketsim import deref_opt
     from marketsim.gen._out.orderbook._oftrader import OfTrader_IAccount as _orderbook_OfTrader_IAccount
     Observablefloat.__init__(self)
     self.book = book if book is not None else deref_opt(
         _orderbook_OfTrader_IAccount())
     self.depth = depth if depth is not None else deref_opt(
         _const_Float(1.0))
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 45
0
 def __init__(self, queue=None, defaultValue=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out._constant import constant_Float as _constant_Float
     from marketsim import event
     from marketsim.gen._out._observable import Observablefloat
     from marketsim.gen._out.orderbook._asks import Asks_IOrderBook as _orderbook_Asks_IOrderBook
     Observablefloat.__init__(self)
     self.queue = queue if queue is not None else _orderbook_Asks_IOrderBook(
     )
     self.defaultValue = defaultValue if defaultValue is not None else _constant_Float(
         100.0)
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 46
0
    def __init__(self):
        Strategy.__init__(self)

        # our order book
        self._book = OfTrader()
        # our order queue
        self._orderQueue = Queue(self._book, side = self.side)
        # we are going to track best price changes
        self._source = self._orderQueue.BestPrice
        event.subscribe(self._source, _(self)._wakeUp, self)
        # deque containing issued orders
        self._orders = None
        # how many orders can be issued
        self._size = self.initialSize
        self._suspended = False
Ejemplo n.º 47
0
    def __init__(self, x=None, side=None, sign=None):
        from marketsim.gen._out.strategy.price._marketdata import MarketData_StringStringStringFloatFloat as _strategy_price_MarketData_StringStringStringFloatFloat
        from marketsim.gen._out.side._sell import Sell_ as _side_Sell_
        from marketsim.gen._out.event._event import Event
        from marketsim import _
        from marketsim import event
        from marketsim import deref_opt
        self.x = x if x is not None else deref_opt(
            _strategy_price_MarketData_StringStringStringFloatFloat())
        self.side = side if side is not None else deref_opt(_side_Sell_())
        self.sign = sign if sign is not None else 1.0
        self.impl = self.getImpl()

        self.on_order_created = Event()
        event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 48
0
 def __init__(self, fv=None, book=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.orderbook._oftrader import OfTrader_IAccount as _orderbook_OfTrader_IAccount
     from marketsim.gen._out._constant import constant_Float as _constant_Float
     from marketsim.gen._out._side import Side
     from marketsim import event
     from marketsim.gen._out._observable import ObservableSide
     ObservableSide.__init__(self)
     self.fv = fv if fv is not None else _constant_Float(200.0)
     self.book = book if book is not None else _orderbook_OfTrader_IAccount(
     )
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 49
0
 def __init__(self, bookToDependOn=None, factor=None, book=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.orderbook._oftrader import OfTrader_IAccount as _orderbook_OfTrader_IAccount
     from marketsim.gen._out._side import Side
     from marketsim import event
     from marketsim.gen._out._observable import ObservableSide
     ObservableSide.__init__(self)
     self.bookToDependOn = bookToDependOn if bookToDependOn is not None else _orderbook_OfTrader_IAccount(
     )
     self.factor = factor if factor is not None else 1.0
     self.book = book if book is not None else _orderbook_OfTrader_IAccount(
     )
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 50
0
 def __init__(self, eventGen = None, orderFactory = None, bookToDependOn = None, factor = None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.order._curried._side_market import side_Market_Float as _order__curried_side_Market_Float
     from marketsim.gen._out.orderbook._oftrader import OfTrader_IAccount as _orderbook_OfTrader_IAccount
     from marketsim.gen._out.event._every import Every_Float as _event_Every_Float
     from marketsim.gen._out.math.random._expovariate import expovariate_Float as _math_random_expovariate_Float
     from marketsim import event
     self.eventGen = eventGen if eventGen is not None else _event_Every_Float(_math_random_expovariate_Float(1.0))
     self.orderFactory = orderFactory if orderFactory is not None else _order__curried_side_Market_Float()
     self.bookToDependOn = bookToDependOn if bookToDependOn is not None else _orderbook_OfTrader_IAccount()
     self.factor = factor if factor is not None else 1.0
     rtti.check_fields(self)
     self.impl = self.getImpl()
     self.on_order_created = event.Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 51
0
    def __init__(self, x=None, orderFactory=None):
        from marketsim.gen._out.event._event import Event
        from marketsim import _
        from marketsim.gen._out.strategy.position._bollinger_linear import Bollinger_linear_FloatIObservableFloatISingleAssetTrader as _strategy_position_Bollinger_linear_FloatIObservableFloatISingleAssetTrader
        from marketsim import event
        from marketsim.gen._out.order._curried._signedvolume_marketsigned import signedVolume_MarketSigned_ as _order__curried_signedVolume_MarketSigned_
        from marketsim import deref_opt
        self.x = x if x is not None else deref_opt(
            _strategy_position_Bollinger_linear_FloatIObservableFloatISingleAssetTrader(
            ))
        self.orderFactory = orderFactory if orderFactory is not None else deref_opt(
            _order__curried_signedVolume_MarketSigned_())
        self.impl = self.getImpl()

        self.on_order_created = Event()
        event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 52
0
 def __init__(self, inner=None, account=None, performance=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.strategy.weight.trader._trader_traderefficiencytrend import trader_TraderEfficiencyTrend_Float as _strategy_weight_trader_trader_TraderEfficiencyTrend_Float
     from marketsim.gen._out.strategy._noise import Noise_IEventSideIObservableIOrder as _strategy_Noise_IEventSideIObservableIOrder
     from marketsim.gen._out.strategy.account.inner._inner_virtualmarket import inner_VirtualMarket_ as _strategy_account_inner_inner_VirtualMarket_
     from marketsim import event
     self.inner = inner if inner is not None else _strategy_Noise_IEventSideIObservableIOrder(
     )
     self.account = account if account is not None else _strategy_account_inner_inner_VirtualMarket_(
     )
     self.performance = performance if performance is not None else _strategy_weight_trader_trader_TraderEfficiencyTrend_Float(
     )
     rtti.check_fields(self)
     self.impl = self.getImpl()
     self.on_order_created = event.Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 53
0
    def __init__(self, inner=None, account=None, performance=None):
        from marketsim.gen._out.strategy.account.inner._inner_virtualmarket import inner_VirtualMarket_ as _strategy_account_inner_inner_VirtualMarket_
        from marketsim.gen._out.event._event import Event
        from marketsim import _
        from marketsim import event
        from marketsim.gen._out.strategy._empty import Empty_ as _strategy_Empty_
        from marketsim.gen._out.strategy.weight.trader._trader_traderefficiencytrend import trader_TraderEfficiencyTrend_Float as _strategy_weight_trader_trader_TraderEfficiencyTrend_Float
        from marketsim import deref_opt
        self.inner = inner if inner is not None else deref_opt(
            _strategy_Empty_())
        self.account = account if account is not None else deref_opt(
            _strategy_account_inner_inner_VirtualMarket_())
        self.performance = performance if performance is not None else deref_opt(
            _strategy_weight_trader_trader_TraderEfficiencyTrend_Float())
        self.impl = self.getImpl()

        self.on_order_created = Event()
        event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 54
0
 def __init__(self,
              ticker=None,
              start=None,
              end=None,
              delta=None,
              volume=None):
     from marketsim import rtti
     from marketsim import event
     from marketsim import _
     self.ticker = ticker if ticker is not None else "^GSPC"
     self.start = start if start is not None else "2001-1-1"
     self.end = end if end is not None else "2010-1-1"
     self.delta = delta if delta is not None else 1.0
     self.volume = volume if volume is not None else 1000.0
     rtti.check_fields(self)
     self.impl = self.getImpl()
     self.on_order_created = event.Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 55
0
 def __init__(self, initialValue = None, priceDistr = None, eventGen = None, orderFactory = None, side = None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.math.random._lognormvariate import lognormvariate_FloatFloat as _math_random_lognormvariate_FloatFloat
     from marketsim.gen._out.side._sell import Sell_ as _side_Sell_
     from marketsim.gen._out.event._every import Every_Float as _event_Every_Float
     from marketsim.gen._out.math.random._expovariate import expovariate_Float as _math_random_expovariate_Float
     from marketsim.gen._out.order._curried._sideprice_limit import sideprice_Limit_Float as _order__curried_sideprice_Limit_Float
     from marketsim import event
     self.initialValue = initialValue if initialValue is not None else 100.0
     self.priceDistr = priceDistr if priceDistr is not None else _math_random_lognormvariate_FloatFloat(0.0,0.1)
     self.eventGen = eventGen if eventGen is not None else _event_Every_Float(_math_random_expovariate_Float(1.0))
     self.orderFactory = orderFactory if orderFactory is not None else _order__curried_sideprice_Limit_Float()
     self.side = side if side is not None else _side_Sell_()
     rtti.check_fields(self)
     self.impl = self.getImpl()
     self.on_order_created = event.Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 56
0
    def __init__(self, x=None, eventGen=None, orderFactory=None):
        from marketsim.gen._out.event._every import Every_Float as _event_Every_Float
        from marketsim.gen._out.math.random._expovariate import expovariate_Float as _math_random_expovariate_Float
        from marketsim.gen._out.event._event import Event
        from marketsim import _
        from marketsim import event
        from marketsim.gen._out.strategy.price._liquidityprovider import LiquidityProvider_FloatFloatIOrderBook as _strategy_price_LiquidityProvider_FloatFloatIOrderBook
        from marketsim.gen._out.order._curried._sideprice_limit import sideprice_Limit_Float as _order__curried_sideprice_Limit_Float
        from marketsim import deref_opt
        self.x = x if x is not None else deref_opt(
            _strategy_price_LiquidityProvider_FloatFloatIOrderBook())
        self.eventGen = eventGen if eventGen is not None else deref_opt(
            _event_Every_Float(deref_opt(_math_random_expovariate_Float(1.0))))
        self.orderFactory = orderFactory if orderFactory is not None else deref_opt(
            _order__curried_sideprice_Limit_Float())
        self.impl = self.getImpl()

        self.on_order_created = Event()
        event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 57
0
 def __init__(self,
              eventGen=None,
              orderFactory=None,
              signal=None,
              threshold=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.order._curried._side_market import side_Market_Float as _order__curried_side_Market_Float
     from marketsim.gen._out.event._every import Every_Float as _event_Every_Float
     from marketsim.gen._out._constant import constant_Float as _constant_Float
     from marketsim.gen._out.math.random._expovariate import expovariate_Float as _math_random_expovariate_Float
     from marketsim import event
     self.eventGen = eventGen if eventGen is not None else _event_Every_Float(
         _math_random_expovariate_Float(1.0))
     self.orderFactory = orderFactory if orderFactory is not None else _order__curried_side_Market_Float(
     )
     self.signal = signal if signal is not None else _constant_Float(0.0)
     self.threshold = threshold if threshold is not None else 0.7
     rtti.check_fields(self)
     self.impl = self.getImpl()
     self.on_order_created = event.Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 58
0
 def __init__(self,
              side=None,
              initialValue=None,
              priceDistr=None,
              book=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.math.random._lognormvariate import lognormvariate_FloatFloat as _math_random_lognormvariate_FloatFloat
     from marketsim.gen._out.side._sell import Sell_ as _side_Sell_
     from marketsim.gen._out.orderbook._oftrader import OfTrader_IAccount as _orderbook_OfTrader_IAccount
     from marketsim import event
     from marketsim.gen._out._observable import Observablefloat
     Observablefloat.__init__(self)
     self.side = side if side is not None else _side_Sell_()
     self.initialValue = initialValue if initialValue is not None else 100.0
     self.priceDistr = priceDistr if priceDistr is not None else _math_random_lognormvariate_FloatFloat(
         0.0, 0.1)
     self.book = book if book is not None else _orderbook_OfTrader_IAccount(
     )
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
Ejemplo n.º 59
0
 def __init__(self,
              eventGen=None,
              orderFactory=None,
              alpha=None,
              timeframe=None,
              threshold=None):
     from marketsim import _
     from marketsim import rtti
     from marketsim.gen._out.order._curried._side_market import side_Market_Float as _order__curried_side_Market_Float
     from marketsim.gen._out.event._every import Every_Float as _event_Every_Float
     from marketsim.gen._out.math.random._expovariate import expovariate_Float as _math_random_expovariate_Float
     from marketsim import event
     self.eventGen = eventGen if eventGen is not None else _event_Every_Float(
         _math_random_expovariate_Float(1.0))
     self.orderFactory = orderFactory if orderFactory is not None else _order__curried_side_Market_Float(
     )
     self.alpha = alpha if alpha is not None else (1.0 / 14)
     self.timeframe = timeframe if timeframe is not None else 1.0
     self.threshold = threshold if threshold is not None else 30.0
     rtti.check_fields(self)
     self.impl = self.getImpl()
     self.on_order_created = event.Event()
     event.subscribe(self.impl.on_order_created, _(self)._send, self)
Ejemplo n.º 60
0
 def bind_impl(self, ctx):
     from marketsim import event, _, context
     if not hasattr(self, '_subscriptions'):
         event.subscribe(self.queue.lastTrade, _(self).fire, self)