• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python event.subscribe函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

 def __init__(self):
     self._efficiency = Efficiency(self.trader)
     event.subscribe(
             OnEveryDt(self._efficiency, 1),
              _(self)._update, self)
     self._score = 1
     self._last = 0
开发者ID:SemanticBeeng,项目名称:marketsimulator,代码行数:7,代码来源:weight.py


示例2: __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


示例3: __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


示例4: __init__

 def __init__(self):
     self._balance = 0
     self._position = 0
     from marketsim.gen._out.event._event import Event
     self.on_traded = Event()
     self.orderBook = OfTrader()
     event.subscribe(self.inner.on_order_created, _(self).onOrderCreated, self)
开发者ID:SemanticBeeng,项目名称:marketsimulator,代码行数:7,代码来源:account.py


示例5: __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


示例6: __init__

 def __init__(self, trader = None):
     from marketsim.gen._out.observable.trader._SingleProxy import SingleProxy
     from marketsim import event
     from marketsim import types
     self.trader = trader if trader is not None else SingleProxy()
     PendingVolume_Impl.__init__(self)
     if isinstance(trader, types.IEvent):
         event.subscribe(self.trader, self.fire, self)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:8,代码来源:_PendingVolume.py


示例7: 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


示例8: __init__

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


示例9: __init__

 def __init__(self, x = None):
     from marketsim.gen._out._constant import constant
     from marketsim import event
     from marketsim import types
     Observable[float].__init__(self)
     self.x = x if x is not None else constant(1.0)
     if isinstance(x, types.IEvent):
         event.subscribe(self.x, self.fire, self)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:8,代码来源:_Log.py


示例10: __init__

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


示例11: __init__

 def __init__(self, queue = None):
     from marketsim.gen._out.observable.orderbook._Asks import Asks
     from marketsim import event
     from marketsim import types
     self.queue = queue if queue is not None else Asks()
     _LastTradePrice_Impl.__init__(self)
     if isinstance(queue, types.IEvent):
         event.subscribe(self.queue, self.fire, self)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:8,代码来源:_LastTradePrice.py


示例12: regSide

 def regSide(side):
     for book in self._books:
         queue = book.queue(side) 
         event.subscribe(queue.bestPrice, 
                         _(self, side)._schedule, 
                         self, {})
         if not queue.empty:
             self._bests[side.id][queue.best.signedPrice] = queue
             self._oldBests[queue] = queue.best.signedPrice
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:9,代码来源:_arbitrage.py


示例13: __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


示例14: __init__

    def __init__(self):
        Strategy.__init__(self)
        self._eventGen = event.Every(ops.constant(0.9))
        event.subscribe(self._eventGen, _(self)._wakeUp, self)

        self.book = orderbook.OfTrader()
        self.midprice = observable.MidPrice(self.book)
        self.log = TraderHistory(SingleProxy())
        self.prev_mid = None
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:9,代码来源:_market_maker.py


示例15: __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


示例16: __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


示例17: regSide

 def regSide(side):
     for book in self._books:
         queue = book.queue(side) 
         event.subscribe(queue.on_best_changed, 
                         bind.Method(self, '_schedule', side), 
                         self).bind(None)
         if not queue.empty:
             self._bests[side.id][queue.best.signedPrice] = queue
             self._oldBests[queue] = queue.best.signedPrice
开发者ID:aoboturov,项目名称:marketsimulator,代码行数:9,代码来源:_arbitrage.py


示例18: __init__

    def __init__(self):
        Strategy.__init__(self)
        self._eventGen = event.Every(ops.constant(1))
        event.subscribe(self._eventGen, _(self)._wakeUp, self)

        self.quotes = data.load(self.ticker, self.start, self.end)['Adj Close']

        self.log = TraderHistory(SingleProxy())
        self.waitingForCancel = False
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:9,代码来源:_market_data.py


示例19: __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


示例20: __init__

 def __init__(self):
     from marketsim.gen._out._observable import Observableint
     from marketsim import rtti
     from marketsim import _
     from marketsim import event
     Observableint.__init__(self)
     
     rtti.check_fields(self)
     self.impl = self.getImpl()
     event.subscribe(self.impl, _(self).fire, self)
开发者ID:abensrhir,项目名称:marketsimulator,代码行数:10,代码来源:_intobs.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python _const._const_Float函数代码示例发布时间:2022-05-27
下一篇:
Python context.bind函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap