• 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

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 stefanjagger, Today, 07:47 AM
        1 response
        9 views
        0 likes
        Last Post stefanjagger  
        Started by tonynt, Today, 07:07 AM
        1 response
        7 views
        0 likes
        Last Post tonynt
        by tonynt
         
        Started by Marklhc1988, Today, 06:53 AM
        3 responses
        10 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Started by ntbone, Today, 12:05 AM
        0 responses
        10 views
        0 likes
        Last Post ntbone
        by ntbone
         
        Started by cutzpr, Yesterday, 09:33 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X