Mariner Backtesting - Strategy.on_amer_imbalance()

AMEX imbalances Event

This method will be called whenever a NYSE Mkt (aka AMEX) imbalance event occurs (from the openbook feed).

Interface:
 def on_amer_imbalance(self,
                      event,
                      md,
                      order,
                      service,
                      account):
    pass
Data Attributes for event:
Name Type Information
SSR_filling_price float This field contains the SSR Filing Price. This price is the price at which Sell Short interest will be filed in the matching in the event a Sell Short Restriction is in effect for the security. The SSR Filing price is based on the National Best Bid at 9:28am . This price remains static after the SSR Filing price has been determined.
clearing_price float The indicative matching price, the price closest to Reference Price where imbalance is zero. If a continuous book clearing price is not reached, it is defaulted to 0. The Opening Clearing Price will begin publication at approximately 2 minutes (9.28am) and will continue to be published on with the next Opening Imbalance publication interval
closing_only_clearing_price float The Closing Only Clearing Price is defined as the closing only interest where price closest to last sale where imbalance is zero.
condition_indicator string "I" - Informational "R" - Regulatory
exchange string "A" - NYSE Mkt (AMEX) exchange details
imbalance_quantity integer The total imbalance quantity at the reference price point. '+' shares indicates buy imbalance '-' shares indicates a sell imbalance.
indicative_match_price float The indicative matching price, the price closest to Reference Price where imbalance is zero. If a continuous book clearing price is not reached, it is defaulted to 0.
paired_quantity integer This field contains the paired off quantity at the reference price point. Similar to Matched Shares from ARCA and NASDAQ.
reference_price float The Imbalance reference price point.
symbol string Event Symbol. In most cases symbol is obvious (self.symbol, md.symbol). If the script has subscribed to multiple symbols events, then event.symbol should be used to identify the symbol.
timestamp muts Timestamp of the event
type string "O" - Open "H" - Halt/IPO "C" - Close
Remarks:
  • Event Symbol. In most cases symbol is obvious (self.symbol, md.symbol). If the script has subscribed to multiple symbols events, then event.symbol should be used to identify the symbol.
Working Example:

Print the attributes of event when on_amer_imbalance() is called.

 from cloudquant.interfaces import Strategy


class OnAmerImbalanceExample(Strategy):
    do_once = True

    @classmethod
    def is_symbol_qualified(cls, symbol, md, service, account):
        return symbol == "CRF"

    def on_start(self, md, order, service, account):
        if self.__class__.do_once:
            print service.time_to_string(service.system_time, '%Y-%m-%d')
            self.__class__.do_once = False
        print self.symbol


    def on_amer_imbalance( self, event, md, order, service, account ):


        print '\nin on_amer_imbalance()\n\t%s\n' % service.time_to_string(service.system_time, '%H:%M:%S.%f')
        print 'event - AmerImbalanceEvent\n'


        print '  event.clearing_price  -  ', event.clearing_price
        print '  event.closing_only_clearing_price  -  ', event.closing_only_clearing_price
        print '  event.condition_indicator  -  ', event.condition_indicator
        print '  event.exchange  -  ', event.exchange
        print '  event.imbalance_quantity  -  ', event.imbalance_quantity
        print '  event.kind  -  ', event.kind
        print '  event.paired_quantity  -  ', event.paired_quantity
        print '  event.reference_price  -  ', event.reference_price
        print '  event.symbol  -  ', event.symbol
        print '  event.timestamp  -  ', event.timestamp
        print '  event.type  -  ', event.type

        service.terminate()

Console

in on_amer_imbalance()
    09:25:00.239000

event - AmerImbalanceEvent

  event.clearing_price  -   15.4499998093
  event.closing_only_clearing_price  -   15.3299999237
  event.condition_indicator  -   0
  event.exchange  -   A
  event.imbalance_quantity  -   -4606
  event.kind  -   25
  event.paired_quantity  -   5550
  event.reference_price  -   15.3199996948
  event.symbol  -   CRF
  event.timestamp  -   1514903100234000
  event.type  -   O