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.
    JimNinjaTrader Customer Service

    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.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        26 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, Yesterday, 09:53 PM
        2 responses
        49 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        192 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,234 views
        0 likes
        Last Post xiinteractive  
        Working...
        X