Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error OnFundamentalData

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

    Error OnFundamentalData

    I need to obtain the market Cap of this companies, and when I try to use protected override void OnFundamentalData(FundamentalDataEventArgs fundamentalDataUpdate), the data that comes out does not match the data Series that I have registered.

    I established a print with the symbol and I can see that it does the perfect route, but when it compares fundamentalDataUpdate.Instrument.FullName it does not match because the information it is reading is wrong.

    I appreciate your help

    Thank you​


    public class SevenFPonderado : Indicator
    {
    private string[] symbols = {"AAPL", "MSFT", "GOOGL", "AMZN", "META", "TSLA", "NVDA"}; // Add more symbols
    private double[] prices;
    private double[] ask;
    private double[] marketCaps;


    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "SevenFPonderado";
    Calculate = Calculate.OnPriceChange;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }


    else if (State == State.Configure)
    {
    foreach (string symbol in symbols)
    {
    AddDataSeries(symbol, Data.BarsPeriodType.Second,1, Data.MarketDataType.Last);
    }

    prices = new double[symbols.Length];
    ask = new double[symbols.Length];
    marketCaps = new double[symbols.Length];
    }
    }


    protected override void OnFundamentalData(FundamentalDataEventArgs fundamentalDataUpdate)
    {

    for (int i = 0; i < symbols.Length; i++)
    {
    string symbol = symbols[i];
    // Print("Symbolo " + symbol);

    // Print("Fundamnetal " + fundamentalDataUpdate.Instrument.FullName);

    // NOTA imprimo Symbols y Fundamental no son igual, cuando deberian serlo
    // La Informacion de Fundamentales no me Toma AAPL ni NVDA, y esta tomando NQ como fundamental al final

    if (fundamentalDataUpdate.Instrument.FullName == symbols[i] && fundamentalDataUpdate.FundamentalDataType == FundamentalDataType.MarketCap)
    {
    marketCaps[i] = fundamentalDataUpdate.DoubleValue;
    Print(symbol + " Market Cap " + marketCaps[i]);
    }
    }
    }​


    #2
    Hello HGTrader,

    From the given information it is not clear what problem you are having. do you have a sample of the print output that shows what problem you are describing?

    Comment


      #3
      In the for it prints the complete list in the order they are in, which is 7.

      When I print the fundamentals, it prints them without any Order and never includes AAPL.

      My main Chart is NQ

      What I need is to obtain the market Cap of each of the companies that I have in the DataSeries, being in any instrument on the graph​

      Thnaks
      Attached Files

      Comment


        #4
        Hello HGTrader,

        The fundamental data is sent by the data provider so there is not a specific ordering for that, its just sent when the provider has an event to send.

        Your symbols array and marketcaps array are not going to be in the same order so comparing a specific index in those is not going to work. You could use a dictionary instead if you wanted to collect the value from the instrument of the event.

        Dictionary<string, double>

        You would use the instrument name as the dictionary key and for the dictionary value use the value passed in from the OnFundamentalData, that would let you pick values from the dictionary by the instrument name.

        If you are unsure how to use dictionaries in C# I would suggest to first look up some examples in external resources of how to use dictionaries in C#.




        Comment


          #5
          ​I work on my stock data with TD Ameritrade. When I connected with Kinetick I was able to print 5 of the Market Caps.

          I think that is the problem, that when we have another data source other than yours, I cannot obtain the fundamentals​

          Comment


            #6
            Sorry I'm missing the Attach
            Attached Files

            Comment


              #7
              Hello HGTrader,

              NinjaTrader platform just recieves what the data provider offers, if your provider does not offer fundamental data events then you wouldn't be able to use that override. You can contact your data provider for more information about your subscription and if they offer marketcap fundamental data.

              Comment


                #8
                Thank you very much for the help, how can I obtain the last value of the market cap of the fundamentals, as we already know if there are no changes then I will not have the data, but I need the last value available

                Comment


                  #9
                  Hello HGTrader,

                  You would need to wait for that event, there is not a way to request that information manually. The data provider pushes those events when there is new data or at the rate they specify.

                  Comment


                    #10
                    I can see that the marketcap used in market Analyzer works perfectly, is it possible to adapt this to an indicator?


                    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                    {
                    public class MarketCap : MarketAnalyzerColumn
                    {
                    protected override void OnStateChange()
                    {
                    if (State == State.SetDefaults)
                    {
                    Description = NinjaTrader.Custom.Resource.NinjaScriptMarketAnaly zerColumnDescriptionMarketCap;
                    Name = NinjaTrader.Custom.Resource.NinjaScriptMarketAnaly zerColumnNameMarketCap;
                    IsDataSeriesRequired = false;
                    }
                    else if (State == State.Realtime)
                    {
                    if (Instrument != null && Instrument.FundamentalData != null && Instrument.FundamentalData.MarketCap != null)
                    CurrentValue = Instrument.FundamentalData.MarketCap.Value;
                    }
                    }

                    protected override void OnFundamentalData(Data.FundamentalDataEventArgs fundamentalDataUpdate)
                    {
                    if (fundamentalDataUpdate.IsReset)
                    CurrentValue = double.MinValue;
                    else if (fundamentalDataUpdate.FundamentalDataType == Data.FundamentalDataType.MarketCap)
                    CurrentValue = fundamentalDataUpdate.DoubleValue;
                    }

                    region Miscellaneous
                    public override string Format(double value)
                    {
                    return (value == double.MinValue ? string.Empty : Core.Globals.FormatCurrency(value));
                    }
                    #endregion
                    }
                    }​

                    Comment


                      #11
                      Hello HGTrader,

                      That is the same override that you are using already. That override waits for the data provider to push an event and then will set the value of the column. That is identical to what you are doing in your code except your code uses some additional logic to filter instruments .The only other difference is that it uses Instrument.FundamentalData.MarketCap.Value to get an existing value, if you had already observed fundamental data events that will be populated, if you have not had an event pushed by the data provider that will not return a value. FundamentalData events are pushed by the data provider so you need to wait for at least one event to be observed before a value is present.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      633 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      364 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      105 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      567 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      568 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X