Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Built a coherent Order Book

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Built a coherent Order Book

    Hello,

    I am using OnMarketDepth event to build a coherent Order Book. I am using the SampleMarketDepth template.
    My question is related to have coherent data in a particular Time.
    In order to have a coherent OrderBook several instructions need to be processed (for example a change on a price level needs a Remove instruction and an Insert instruction). If in the meantime of these instructions, I perform some calculations they would be wrong because they must be done after the second instruction.
    I know it is because race conditions but I wonder if there is any way to know if in a particular time data is coherent.
    Related to this problem, I want to know, what is the purpose of MarketDepth member of MarketDepthEventArgs class? It seems to have MarketDepthRowCollection items. Is it up to date? Is it valid? Can I use them to have a coherent real time Order Book?

    Thank you in advance

    #2
    Hello jbesada,
    If you look into the SampleMarketDepth code, it uses the lock statement to make sure the collection is not modified until we finish the processing (of our custom calculation). Please refer here to know more about the lock statement http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx

    This is however more of a C# query and beyond what we could support.

    The MarketDepth object further exposes the various objects and collections of the level 2 data.

    Yes, it is realtime and updated on each change in the order book.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thank you for the answer but unfortunately it was not my question.
      I know how to use lock and event conditions.
      Sorry if my explanation is not very clear.
      If for example a change on a price level arises, several OnMarketDepth events need to be processed in an atomic way (lets to say a remove and then an insert for example), but because you don't know how many events are needed, you can have a non coherent Order Book in the meantime of these events (a lock statement doesn't prevent this).
      To summarize, changes in the Order Book could need several events to be processed, is there any way to know how many events will come up to have a 'coherent' order book?

      Regards

      Comment


        #4
        Hello jbesada,
        OnMarketDepth is called and guaranteed to be in the correct sequence for every change in level II. However we have no way to know what data is coming. It is chaotic as it would and orders can get added/updated/deleted at any time.

        To know when it is coherent, one needs to have a reference point and also one needs to define what is "coherent".

        I look forward to assisting you further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by marcus2300, Today, 10:21 AM
        4 responses
        7 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by joselube001, Today, 12:17 PM
        0 responses
        4 views
        0 likes
        Last Post joselube001  
        Started by tkaboris, Today, 06:27 AM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_RyanS  
        Started by chemo, Today, 12:05 PM
        0 responses
        3 views
        0 likes
        Last Post chemo
        by chemo
         
        Started by DawnTreader, 05-08-2024, 05:58 PM
        12 responses
        42 views
        0 likes
        Last Post DawnTreader  
        Working...
        X