md.L1.agr_ask_size error

qumentaqumenta Posts: 10
edited April 2018 in Quick Question

Where can I find the updated reference for md.L1?

 self.__class__.bar_trigger_agr_ask_size[self.symbol] = md.L1.agr_ask_size
...
KeyError: 'agr_ask_size'
Tagged:

Comments

  • ptunneyptunney Posts: 246

    As this is an aggregated ASK function it would not be very useful to be called on a minute bar, therefore it would only work in on_trade and on_nbbo. The front page of documentation has been updated to make this clear.

    If you have ELITE status then here is some code that will print out those values between 9:31:00 and 9:31:10 for SPY...

    from cloudquant.interfaces import Strategy
    class Forum_Agr_Ask(Strategy):
        @classmethod
        def on_strategy_start(cls, md, service, account):
            print service.time_to_string(service.system_time, '%Y-%m-%d')
    
        @classmethod
        def is_symbol_qualified(cls, symbol, md, service, account):
            return symbol == 'SPY'
    
        def on_start(self, md, order, service, account):
            print self.symbol
    
        def on_trade(self, event, md, order, service, account):
            if service.system_time>service.time(9,31,0,0) and service.system_time<service.time(9,31,10,0) :
                print service.time_to_string(service.system_time, '%H:%M:%S.%f'),md.L1.ask_size,md.L1.bid_size,md.L1.agr_ask_size, md.L1.agr_bid_size
            if service.system_time>service.time(9,31,10,0):\
                service.terminate()
    
  • ptunneyptunney Posts: 246

    Note, as of March 2018, this variable is not currently available in Live/Forward-Testing.

Sign In or Register to comment.