Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to call historical volatility from IB

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

    How to call historical volatility from IB

    Hi NT,

    I was reading NT7 guide searching how to call the instrument's historical volatility from IB. I'm don't know if IB's connectivity allows this procedure. So, let's suppose that IB gives this info, that would be through this method:

    Code:
    protected override void OnFundamentalData(FundamentalDataEventArgs e)
    {
        if (e.FundamentalDataType == FundamentalDataType.HistoricalVolatility)
             Print("HistoricalVolatility = " + e.HistoricalVolatility);
    }
    Questions:

    - How to call this method once a day? Where to put in the code?
    - I've read in IB's TWS documentation that historical volatility that is given is 30 days, so what if I need 1 year?

    Thanks

    #2
    Hello pstrusi,

    Thanks for your post.

    Getting Fundamental data information is similar to realtime market data feeds like OnMarketData, there is not an ability to get this information historically and they update as they are sent from the data provider. When the script starts, OnFundamentalData will show the values which already exists. I suggest saving these values to a variable to use them elsewhere in your script and then you can reference those values at your desired point in time.

    One item to note, is that you will want to print e.DoubleValue for the value of HistoricalVolatility.

    Code:
            protected override void OnFundamentalData(FundamentalDataEventArgs e)
            {
                if (e.FundamentalDataType == FundamentalDataType.HistoricalVolatility)
                     Print("HistoricalVolatility = " + e.DoubleValue);
            }
    Please let me know if I can be of further assistance.

    Comment


      #3
      Hi Jim, thanks for addressing the questions, allow me to rephrase them in order to get a better understanding of properties:

      1. Where would this method go in the code, before OnBarUpte, after OnStartUp....?

      2. If I understand well, this info will be thrown by IB as soon is updated and it will feed into my code?

      3. How to call ImpliedVolatility from IB ? IB's TWS gives this info but in the NT7 guide I just see these fields:
      FundamentalDataType Possible values:



      AverageDailyVolume

      Beta

      CalendarYearHigh

      CalendarYearHighDate

      CalendarYearLow

      CalendarYearLowDate

      CurrentYearsEarningsPerShare

      FiveYearsGrowthPercentage

      High52Weeks

      High52WeeksDate

      HistoricalVolatility

      Low52Weeks

      Low52WeeksDate

      NextYearsEarningsPerShare

      PercentHeldByInstitutions

      PriceEarningsRatio

      SharesOutstanding

      Thanks
      Last edited by pstrusi; 07-15-2019, 11:26 AM.

      Comment


        #4
        Hello pstrusi,

        The code would reside in your NinjaScript's class. Neither in OnStartUp or OnBarUpdate but at the same level as those methods.

        When the data provider updates these values, OnFundamentalData will iterate for any updates here.

        ImpliedVolatility is not a supported Fundamental Data value, only the values listed for FundamentalDataEventArgs could be referenced with OnFundamentalData.

        Please let me know if I can be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        56 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        37 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        18 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        20 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        49 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X