how to get total Ask/Bid quantity

Hi Experts,

Im trying to get total ask quantity and total bid quantity at any time of market. whats the right parameters to use.

Ive tried,
md.L1.daily_askvol # Daily Ask Volume
md.L1.daily_bidvol # Daily Bid Volume

but it results to 0.

Tagged:

Comments

  • ptunneyptunney Posts: 246
    edited September 2019

    Not sure how you are getting zero but this is how you do it...

    # Question in forum and via chatt about daily_askvol and daily_bidvol
    # You will see a difference in the values in the minute bars and the daily numbers because not all trades are included in minute bars.
    
    from cloudquant.interfaces import Strategy
    
    class Forum_kk24100(Strategy):
    
        @classmethod
        def is_symbol_qualified(cls, symbol, md, service, account):
            return symbol=="SPY"
    
    #    def on_trade(self, event, md, order, service, account):
    #        print "Trade {} {} BidVol {} AskVol {} Last {:8.2f}  Bid {:8.2f}  Ask {:8.2f}  LastSize {}".format(self.symbol,service.time_to_string(event.timestamp),md.L1.daily_bidvol,md.L1.daily_askvol,"Last",md.L1.last,"Bid",md.L1.bid,md.L1.ask,md.L1.last_size)
    
        def on_minute_bar(self, event, md, order, service, account, bar): 
            mybar= md.bar.minute(-1,include_extended=True)
            if len(mybar.askvol)!=0:
                print "Bar   {} {}  AskVol {:10}  BidVol {:10}  Volume {:10}  Day BidVol {:10}  Day AskVol {:10}  Day Volume {:10}  Core Hrs Volume {:10}".format(self.symbol,service.time_to_string(event.timestamp),mybar.askvol,mybar.bidvol,mybar.volume,md.L1.daily_askvol,md.L1.daily_bidvol,md.L1.acc_volume,md.L1.core_acc_volume)
    
  • ptunneyptunney Posts: 246

    Of course you do not have to fetch a bar, you can just reference the md.L1. data...

    from cloudquant.interfaces import Strategy
    
    class Forum_kk24100(Strategy):
    
        @classmethod
        def is_symbol_qualified(cls, symbol, md, service, account):
            return symbol=="SPY"
    
        def on_minute_bar(self, event, md, order, service, account, bar): 
            print "Bar   {} {}  Day BidVol {:10}  Day AskVol {:10}  Day Volume {:10}  Core Hrs Volume {:10}".format(self.symbol,service.time_to_string(event.timestamp),md.L1.daily_askvol,md.L1.daily_bidvol,md.L1.acc_volume,md.L1.core_acc_volume)
    
  • Hi Thanks a lot for the response!!

    I want to confirm my understanding of the parameters are correct.
    1. md.L1.daily_bidvol ---> is this paramater means total number of bidvol so far executed OR total bidvolume outstanding waiting to be executed ?
    2. whats the parameter for the total bidvolume outstanding waiting to be executed ?
    3. what are below parameter signifies please explain (may be a silly question)
    md.L1.acc_volume .
    md.L1.agr_ask_size
    md.L1.bid_change
    md.L1.minute_askvol [whats the difference between md.L1.minute_askvol and md.L1.daily_bidvol]

  • @kk24100 check out this page in the documentation. It has verbal definitions for all the quantities inside L1
    https://app.cloudquant.com/#/glossary/106

  • kk24100kk24100 Posts: 11
    edited September 2019

    the link you provided doesn't work !.
    Could not fetch documentation page
    HTTP Code: 403
    Unauthorized

    if this is what you are referring to https://app.cloudquant.com/#/glossary/0 I've already gone through with it. still it doesn't clarify my queries.

    im pasting my questions again, please spare 2 minutes to answer it

    I want to confirm my understanding of the parameters are correct.
    1. md.L1.daily_bidvol ---> is this paramater means total number of bidvol so far executed OR total bidvolume outstanding waiting to be executed ?
    2. whats the parameter for the total bidvolume outstanding waiting to be executed?
    3. what are below parameter signifies (may be a silly question)
    md.L1.acc_volume .
    md.L1.agr_ask_size
    md.L1.bid_change
    md.L1.minute_askvol [whats the difference between md.L1.minute_askvol and md.L1.daily_bidvol]

  • ptunneyptunney Posts: 246

    You could not access the page KC975943 referenced because you were a CQ Lite user and that page is for access to Level 1 data.
    You now have Elite access and will be able to reach that page.

    1. md.L1.daily_bidvol = amount of volume that has traded at or near the bid for the day so far (I believe this is market hours only).
    2. You cannot access depth of book in a backtester... that is too much data... if you have ever looked at a symbols depth of book in a live trading situation, it is constantly changing. Depth of book is available in a live trading situation but one limits how often one requests it as calculating "size down to price" or "price down to size" is a loop and one generally avoids anything that uses loops in trading algos.
    3. md.L1.acc_volume = total accumulated volume for the day so far (from 4am), md.L1.agr_ask_size = sum of ask volume in book - live trading only - not available in backtesting, md.L1.bid_change = Difference between previous and current bid. Positive for increase and negative for decrease.
  • kk24100kk24100 Posts: 11
    edited September 2019

    thanks for Quick response!!

    im NOT looking for enitre L1 market depth. All i need is 2 params (numbers)
    1. total outstanding bid volume of all bidprices. (= sum of volumes of all bidprices)
    2. total outstanding ask volume of all ask prices.

    is it avalable only in live ?

  • According to the documentation, yes:
    Objects:
    Name Type Information
    L1 Level1 A snapshot of the current market state (Level 1 Data).
    L2 Level2 Stubbed out in backtesting. Available in forward and live trading.

  • ptunneyptunney Posts: 246

    KK I think you are asking for the areas in this image outlined in red (left is bid right is ask)

    That is data which is constantly changing with every fraction of a second. It is known as Level 2 data. If one attempted to store that data for 8000 symbols for a single full trading day at every instant it would be HUGE.

    We allow our traders to request some Level 2 data in live (because it is not being stored, it is just a snapshot of that instant) but even then it is discouraged as it can be a severe resource hog.

    Also, it is ill advised.
    If you do it your way, in the example above, for the bid you would be including size at $267 when the Level 1 NBBO Bid is 295.56. You would never want to consider that value.
    So we supply our live traders with "size down to a price" or "price to a size".
    So they can say, what would be my averaged price if I was to buy 1000 shares right now?
    Or how many shares would I get if I was prepared to pay up to 298.00?

    But this is a moot point as this data is not available in Backtesting.

  • kk24100kk24100 Posts: 11
    edited September 2019

    thank for the detailed explanation. I think the params I'm asking should be there in L1 market depth [not sure in US market certainly available in Indian market].

    1. total outstanding bid volume of all bidprices. (= sum of volumes of all bid prices) = in this scenario sum of all the sizes (from snapshot)
    2. total outstanding ask volume of all ask prices.

    doesn't these params available in L1 ?

    just to give better idea, ive attached the

    this is from one of Indian broker that green marked 2 numbers am looking for . which is changing in every second. but I need it in the minute interval

  • ptunneyptunney Posts: 246

    No, not available. Plus, what kind of number is 1,72,079?

  • 172079 is the total ask quantity that is to be executed. i.e sum of all ask quantiies of all ask prices

    1. the previous comment says md.L1.agr_ask_size available only in live. But im trying in backtesting it shows the values.

    2. can you please tell me what would be the value of md.L1.agr_ask_size for the snapshot you shared ?

    3. doc says ELITE ONLY Sum of all ask participants in the SIP data. See md.L2 for live options
      what is SIP ?

  • ptunneyptunney Posts: 246

    Facts about the Securities Information Processor (SIP) https://www.ctaplan.com/index

    The Securities Information Processor (SIP) links the U.S. markets by processing and consolidating all protected bid/ask quotes and trades from every trading venue into a single, easily consumed data feed.
    The SIP disseminates and calculates critical regulatory information including the National Best Bid and Offer (NBBO) and Limit Up Limit Down (LULD) price bands among other important information such as short sale restriction and regulatory halts.
    CTA metrics on SIP performance (system availability, capacity, latency) and Subscriber use (non-professionals, professionals, quote usage, households) is available monthly and historically at SIP Metrics.

    Yesterday I looked at that variable, for the first time ever. I do not think the value it contains makes a lot of sense to me or has a great value. It certainly is not what you are looking for (total size down the book). I do have access to the code that creates that value and I cannot, at the moment, get that information. For now, I would disregard that variable.

Sign In or Register to comment.