Mariner Backtesting - Arca Imbalances

arca_imb

md. (object) Overview:

The arca_imb object represents the last imbalance event received for a given symbol from NYSEArca.

Data Attributes:

Sample - Access data attribute

 md.arca_imb.abs_price_diff_from_pc
Name Type Special Information
abs_price_diff_from_pc float NaN
if indicative_match_price > 0 and stat.prev_close > 0:
    abs(indicative_match_price - stat.prev_close) 
else:
    float('NaN')
abs_price_diff_from_pc_percent_atr float NaN
if stat.atr > 0:
    abs_price_diff_from_pc / stat.atr * 100 
else:
    float('NaN')
exchange string None "P" exchange details
flip_count integer 0 Number of times an imbalance flips from buy to sell or sell to buy. If this number goes from 0 to 1, it is the first time it has flipped. Odd numbers indicate it has flipped away from it's initial imbalance side. Even numbers indicate it has flipped back
high_imbalance float 0 The highest value for total_imbalance. '+' shares indicates buy imbalance '-' shares indicates a sell imbalance.
high_imbalance_time muts 0 Time of Imbalance Shares High
indicative_match_price float NaN The best price at which the maximum volume of shares is executable in the applicable auction, subject to Auction Collars. It includes the non-displayed quantity of Reserve Orders.
indicative_match_volume integer 0 The number of shares that would match at the indicative price if the Auction were run at that moment.
last_flip_time muts 0 Time of the latest imbalance flip.
market_imbalance integer 0

market_imbalance - Market Order Imbalance

The market_imbalance volume. '+' shares indicates buy imbalance '-' shares indicates a sell imbalance.

The Market Order Imbalance is the imbalance of any remaining Market Orders (or Market-on-Close orders for the Closing Auction) that cannot execute in a Market Order or Closing Auction. Calculation of match size and indicative match price remain unchanged.

symbol string    
timestamp muts 0 time of the last arca imbalance update
total_imbalance integer 0

The total_imbalance volume. '+' shares indicates buy imbalance '-' shares indicates a sell imbalance.

The total_imbalance is the net imbalance of orders at the indicative match price for all orders eligible for the next upcoming Auction. This includes Market (or Market-on-Close) and Limit Orders. Display of match size and indicative match price remain unchanged.

The number of shares of buy orders minus the number of shares of sell orders. A positive total_imbalance means an excess of buy orders and a negative total_imbalance means an excess of sell orders.

type string 0
  • "o" == Arca Open Imbalance (happens at 4:30 easten)
  • "O" == Arca Market Imbalance (just prior to official open, 9:30 eastern)
  • "C" == Close
  • "H" == halt or ipo
Working Example:

Print attributes of md.arca_imb when on_arca_imbalance() is called.

 from cloudquant.interfaces import Strategy


class ArcaImbalanceExample(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_arca_imbalance(self, event, md, order, service, account):
        print '\n\nin on_arca_imbalance\n\t%s\n' % service.time_to_string(service.system_time, '%H:%M:%S.%f')

        print '\n\nmd.arca_imb'

        print ' md.arca_imb.abs_price_diff_from_pc  -   ', md.arca_imb.abs_price_diff_from_pc
        print ' md.arca_imb.abs_price_diff_from_pc_percent_atr  -   ', md.arca_imb.abs_price_diff_from_pc_percent_atr
        print ' md.arca_imb.exchange    -   ', md.arca_imb.exchange
        print ' md.arca_imb.flip_count  -   ', md.arca_imb.flip_count
        print ' md.arca_imb.high_imbalance  -   ', md.arca_imb.high_imbalance
        print ' md.arca_imb.high_imbalance_time -   ', md.arca_imb.high_imbalance_time
        print ' md.arca_imb.indicative_match_price  -   ', md.arca_imb.indicative_match_price
        print ' md.arca_imb.indicative_match_volume -   ', md.arca_imb.indicative_match_volume
        print ' md.arca_imb.last_flip_time  -   ', md.arca_imb.last_flip_time
        print ' md.arca_imb.market_imbalance    -   ', md.arca_imb.market_imbalance
        print ' md.arca_imb.timestamp   -   ', md.arca_imb.timestamp
        print ' md.arca_imb.total_imbalance -   ', md.arca_imb.total_imbalance
        print ' md.arca_imb.type    -   ', md.arca_imb.type

        service.terminate()

Console

2016-01-04
SPY

in on_arca_imbalance
    15:00:00.016000



md.arca_imb
    md.arca_imb.abs_price_diff_from_pc  -   3.33999633789
    md.arca_imb.abs_price_diff_from_pc_percent_atr  -   134.954799309
    md.arca_imb.exchange    -   P
    md.arca_imb.flip_count  -   994
    md.arca_imb.high_imbalance  -   703925
    md.arca_imb.high_imbalance_time -   1451917737106000
    md.arca_imb.indicative_match_price  -   200.529998779
    md.arca_imb.indicative_match_volume -   574883
    md.arca_imb.last_flip_time  -   1451917799638000
    md.arca_imb.market_imbalance    -   0
    md.arca_imb.timestamp   -   1451917800505000
    md.arca_imb.total_imbalance -   202
    md.arca_imb.type    -   C

Related Links:

http://www.nyxdata.com/nysedata/Default.aspx?tabid=1417