• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Possible bugs with OnFundamentalData

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

  • jmneto
    started a topic Possible bugs with OnFundamentalData

    Possible bugs with OnFundamentalData

    Hi,


    I found while developing an AddOn using as basis your sample AddOn from the NT documentation that a thread gets stuck in fundamentalData.Update -= OnFundamentalData; while it progresses without problems the other event subscriptions

    Hangs in my code
    marketData.Update -= OnMarketData;
    barsRequest.Update -= OnBarUpdate;
    fundamentalData.Update -= OnFundamentalData; <== Hangs here.

    Also found that if you subscribe to fundamentalData.Update += OnFundamentalData; we stop receiving MarketData.DailyVolume in OnMarketData if you are also not subscribed to OnBarsUpdate.

    Do you have any suggestions for the thread stuck issue? Have you seen this before?



  • NinjaTrader_Jim
    replied
    Hello jmneto,

    I don't see anything internally regarding threading issues with OnFundamentalData, but we do document some precautions for cross thread exceptions. Due to the multi-threaded nature of NinjaTrader 8 it would be expected to run into such issues with separate threads. Subscribing and Unsubscribing on separate threads would qualify here.

    Our cross thread exception advisories can be referenced in the Multi-threading considerations page of the help guide.

    Cross Thread Exceptions

    When accessing objects included on the UI, you may receive the following error if you attempt to access a certain property/method from the wrong thread:

    "Error on calling 'OnBarUpdate' method on bar 0: You are accessing an object which resides on another thread. I.E. creating your own Brush without calling .Freeze(), or trying to access a UI control from the wrong thread without using a Dispatcher"

    This error can be avoided by invoking the Dispatcher used on the appropriate UI thread.
    I have asked that this particular case gets noted in this advisory page, however we cannot document every particular case that could be encountered with cross thread exceptions. More general notes are typically preferred in the documentation, so I could not say if the specific note will be added.

    If you disagree that this is explained (in general) in the Multi Threading Considerations page, please send us a test script so we can forward your inquiry to Development. (We are capable of creating test scripts on the NinjaScript team for review, but we also have other priorities that we need to take first. It is best if we can receive a test script from you that explains the matter in clear terms so we can avoid any guess work, get the issue reported as you see it, and so we can continue assisting others in a timely manner.)

    I look forward to being of any further assistance.

    Leave a comment:


  • jmneto
    replied
    I think I found the problem: Appears that if you call
    fundamentalData.Update += OnFundamentalData in one thread, and then later you attempt to call fundamentalData.Update -= OnFundamentalData on another diferrent thread to unsubscribe the event for the same object, the later thread hangs. It does not happen when subscribing/unsubscribing to the other data subscription events, onmarketdata or onbarupdate.

    In other words, you have to subscribe to fundamental data and unsubscribe to fundamental data from the same thread. (again other market data subscriptions are not affected by this).

    Please let me know your developers thoughts on this. For now I found a workaround, but this is something you might want to investigate.

    Leave a comment:


  • jmneto
    replied
    In your sample, all the subscription to these events is started (+=) or removed (-=) from the UI thread or Dispatcher.InvokeAsync. In my code, to add the event subscriptions to MarketData, BarsRequest and Fundamenta Data I use a thread started via Task.Run. Do you have any history about issues with this setup?

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Hello jmneto,

    If you would like to share a reduced AddOn that demonstrates the issue without taking any other action, with some steps to reproduce, we could open up a ticket with the development team. Without such a case, we are left to guess at how you are hitting an issue.

    I'll be happy to file a report with you if you can provide such a case.

    Leave a comment:


  • jmneto
    replied
    Hi, I am well past samples, I have written a complex multithreaded app that uses these events. Interesting enough is that I create the events subscriptions all together, and unsubscribe all together like you see in the code extract I provided. The thread only hangs when unsubscribing the fundamenta data. I found other odd behaviors with Fundamenta Data also. Anyways, I just wanted to report this to your developers to take a second peek around this.

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Hello jmneto,

    Thanks for your post.

    The AddOnFramework example unsubscribes from these sequentially in the Instrument's setter, and in the AddOn window's CleanUp method. There are not any threading errors seen here. You may find some further direction by reducing the AddOnFramework script into what functionality you are looking for.

    I have included a demonstration showing Market Data update subscriptions and prints where unsubscriptions take place.

    Demo - https://drive.google.com/file/d/1cR6...w?usp=drivesdk

    As far as Daily Volume is concerned, OnBarUpdate events should not effect this. I have attached the script I have used to test in the video. I commented out subscriptions to OnBarUpdate, and I am still able to see valid output for DailyVolume.

    Please let me know if you have any questions.
    Attached Files

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Newtrader101, Today, 06:31 PM
1 response
6 views
0 likes
Last Post NinjaTrader_EricB  
Started by Tyler7498, Today, 07:34 PM
0 responses
4 views
0 likes
Last Post Tyler7498  
Started by Woomera, Today, 07:24 PM
1 response
4 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by Newtrader101, Today, 12:31 PM
2 responses
13 views
0 likes
Last Post Newtrader101  
Started by kweiss, Today, 06:42 PM
0 responses
2 views
0 likes
Last Post kweiss
by kweiss
 
Working...
X