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

Python context.bind函数代码示例

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

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



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

示例1: send

 def send(self, order):
     if order is not None:
         if isinstance(order, types.IOrder):
             order.owner = self
         context.bind(order, self._ctx)
         self._book.process(order)
     return order
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:7,代码来源:_meta.py


示例2: update

def update():
    w = current_user_workspace()
    
    parsed = request_parsed()

    metaToCreate = dict([(int(Id), (meta[0], meta[1], meta[2])) for (Id, meta) in parsed['created']])

    with w.world: 
        w.registry.createNewObjects(metaToCreate)
        
        # changing fields for existing ones    
        for (Id, field, value) in parsed['updates']:
            w.registry.setAttr(Id, field, value)
            
    context.bind(w.registry.get(w.root), { "world" : w.world })
    save_state_before_changes(w.registry) 

    save_current_workspace()
    
    if 'limitTime' in parsed:
        limitTime = parsed['limitTime']
        timeout = parsed["timeout"]
        run(w.world, timeout, limitTime)
        save_current_workspace()

    return changes(w)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:26,代码来源:flaskapp.py


示例3: run

def run(name, constructor):
    with scheduler.create() as world:
        
        ctx = Context(world, veusz.Graph)
        traders = constructor(ctx)
        
        books = orderBooksToRender(ctx, traders)
        
        for t in traders + books:
            for ts in t.timeseries:
                ts.graph.addTimeSerie(ts)
        
        r = registry.create()
        root = registry.Simulation(traders, list(ctx.books.itervalues()), ctx.graphs)
        r.insert(root)
        r.pushAllReferences()
        context.bind(root, {'world' : world })
        
        world.workTill(500)
        
        non_empty_graphs = [g for g in ctx.graphs if len(g._datas)]
        
        veusz.render(name, non_empty_graphs)
        
        world._reset()
        context.reset(root)

        if runTwoTimes:
            world.workTill(500)
            veusz.render(name, non_empty_graphs)
开发者ID:aoboturov,项目名称:marketsimulator,代码行数:30,代码来源:common.py


示例4: createSimulation

def createSimulation(name='All'):
    
    with scheduler.create() as world:
        
        myRegistry = registry.create()
    
        myRegistry.insert(Side.Sell)
        myRegistry.insert(Side.Buy)    
        ctx = Context(world, js.Graph)
        dependency = strategy.v0.Dependency(ctx.book_B)
        dependency_ex = strategy.Dependency(event.Every(mathutils.rnd.expovariate(1.)),
                                            order.factory.side.Market(), 
                                            ctx.book_B)
        
        def register(annotated_objects):
            for obj, alias in annotated_objects:
                if alias is not None:
                    obj._alias = alias
                myRegistry.insert(obj)
                
        register([
                  (dependency, ["Basic", "Dependency"]),
                  (dependency_ex, None),
        ])
        
        myRegistry.pushAllReferences()

        def process(name):
            constructor = predefined[name]
        
            traders = constructor(ctx)

            books = orderBooksToRender(ctx, traders)
        
            for t in traders + list(ctx.books.itervalues()) + ctx.graphs:
                myRegistry.insert(t)
                
        if name != 'All':
            process(name)
        else: 
            for n in predefined.iterkeys():
                process(n)
            
        myRegistry.insert(world)
        
        root = myRegistry.insert(registry.createSimulation(myRegistry))
        context.bind(myRegistry.get(root), { "world" : world })

        if name != 'All':
            current_dir = current_user_dir()
            ensure_dir_ex(current_dir)
            
            if os.path.exists(os.path.join(current_dir, name)):
                i = 0
                while os.path.exists(os.path.join(current_dir, name + "." + str(i))): 
                    i += 1
                name += '.' + str(i) 
        
        return name, root, myRegistry, world
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:59,代码来源:flaskapp.py


示例5: send

 def send(self, order):
     from marketsim.gen._out._iorder import IOrder
     if order is not None:
         if isinstance(order, IOrder):
             order.owner = self
         context.bind(order, self._ctx)
         self._book.process(order)
     return order
开发者ID:abensrhir,项目名称:marketsimulator,代码行数:8,代码来源:_meta.py


示例6: run

def run(name, constructor, only_veusz):
    with scheduler.create() as world:
        
        ctx = Context(world, veusz.Graph)
        traders = constructor(ctx)

        if config.useMinorTraders:
            traders.extend([
                ctx.makeMinorTrader(strategy.RSI_linear(k = const(0.07)), "RSI 0.07"),
                ctx.makeMinorTrader(strategy.RSI_linear(k = const(-0.07)), "RSI -0.07"),
                ctx.makeMinorTrader(strategy.Bollinger_linear(alpha=0.15, k = const(-0.5)), "Bollinger -0.5"),
                ctx.makeMinorTrader(strategy.Bollinger_linear(alpha=0.15, k = const(+0.5)), "Bollinger +0.5"),
            ])
        
        books = orderBooksToRender(ctx, traders)
        
        for t in traders + books:
            for ts in t.timeseries:
                ts.graph.addTimeSerie(ts)
        
        r = registry.create()
        root = registry.Simulation(traders, list(ctx.books.itervalues()), ctx.graphs)
        r.insert(root)
        r.pushAllReferences()
        context.bind(root, {'world' : world })
                    
        if False:
            req = request.EvalMarketOrder(Side.Sell, 500, _print)
            world.schedule(10, _(ctx.remote_A, req).process)
        
        def checks():
            if not only_veusz and config.checkConsistency:
                r.typecheck()
                try:
                    dumped = pickle.dumps(r)
                    pickle.loads(dumped)
                except Exception, err:
                    print err

        checks()        
        stat = world.workTill(500)
        checks()        

        if config.showTiming:
            print "\n", stat
        
        non_empty_graphs = [g for g in ctx.graphs if len(g._datas)]
        
        veusz.render(name, non_empty_graphs)
        
        world._reset()
        context.reset(root)

        if False and config.runTwoTimes:
            world.workTill(500)
            veusz.render(name, non_empty_graphs)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:56,代码来源:common.py


示例7: send

 def send(self, book, order):
     """ Sends 'order' to 'book'
     After having the order sent notifies listeners about it 
     """
     context.bind(order, self._ctx)
     if isinstance(order, types.IOrder):
         order = self._makeSubscribedTo(order)
     book.process(order)
     if isinstance(order, types.IOrder):
         self.on_order_sent.fire(order)        
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:10,代码来源:_base.py


示例8: send

 def send(self, book, order):
     """ Sends 'order' to 'book'
     After having the order sent notifies listeners about it
     """
     from marketsim.gen._out._iorder import IOrder
     context.bind(order, self._ctx)
     if isinstance(order, IOrder):
         order = self._makeSubscribedTo(order)
     book.process(order)
     if isinstance(order, IOrder):
         self.on_order_sent.fire(order)
开发者ID:abensrhir,项目名称:marketsimulator,代码行数:11,代码来源:classes.py


示例9: subscribe

def subscribe(event, listener, target = None, ctx = None):
    
    subscription = Subscription(event, listener)
    
    if target is not None:
        if '_subscriptions' not in dir(target):
            target._subscriptions = []
            
        target._subscriptions.append(subscription)
        
        if 'dispose' not in dir(target):
            target.dispose = bind.Callable(dispose, target)
            
    if ctx is not None:
        context.bind(subscription, ctx)
            
    return subscription
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:17,代码来源:event.py


示例10: reset

 def reset(self):
     self.impl = self.getImpl()
     ctx = getattr(self, '_ctx', None)
     if ctx: context.bind(self.impl, ctx)
开发者ID:Courvoisier13,项目名称:marketsimulator,代码行数:4,代码来源:_DesiredPosition.py


示例11: bind

 def bind(self, ctx):
     from marketsim import event, _, context
     event.subscribe(self.queue.bestPrice, _(self).fire, self)
     context.bind(self._subscriptions, ctx)
开发者ID:abensrhir,项目名称:marketsimulator,代码行数:4,代码来源:props.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python event.subscribe函数代码示例发布时间:2022-05-27
下一篇:
Python marketsim.deref_opt函数代码示例发布时间: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