当前位置: 首页>>代码示例>>Python>>正文


Python marketsim._函数代码示例

本文整理汇总了Python中marketsim._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 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)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:7,代码来源:_all.py

示例2: __init__

 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
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:7,代码来源:_account.py

示例3: __init__

 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
开发者ID:SemanticBeeng,项目名称:marketsimulator,代码行数:8,代码来源:account.py

示例4: __init__

    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)
开发者ID:SemanticBeeng,项目名称:marketsimulator,代码行数:8,代码来源:cumulative_price.py

示例5: bind_impl

 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
开发者ID:SemanticBeeng,项目名称:marketsimulator,代码行数:8,代码来源:props.py

示例6: __init__

 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)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:9,代码来源:_lp.py

示例7: __init__

 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)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:9,代码来源:_candlestick.py

示例8: __init__

    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)
开发者ID:SemanticBeeng,项目名称:marketsimulator,代码行数:9,代码来源:ladder.py

示例9: __init__

 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()
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:9,代码来源:_remote.py

示例10: __init__

    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)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:9,代码来源:cumulative_price.py

示例11: __init__

 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)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:10,代码来源:_choose_best.py

示例12: onOrderMatched

 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)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:11,代码来源:_stoploss.py

示例13: onOrderMatched

 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)
开发者ID:SemanticBeeng,项目名称:marketsimulator,代码行数:15,代码来源:stoploss.py

示例14: __init__

 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"]
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:7,代码来源:_average.py

示例15: __init__

    def __init__(self):
        self.attributes = {"smooth":True}

        self._timer = event.Every(self.intervalDistr)
        event.subscribe(self._timer, _(self)._wakeUp, self)
        
        self.reset()
开发者ID:SemanticBeeng,项目名称:marketsimulator,代码行数:7,代码来源:randomwalk.py


注:本文中的marketsim._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。