I modifed a script I found on this forum and I am trying to get IV and OI of a Option.
I can see in ToS that the IV changes with every Strike whereas I can only get it to give me the IV from GetUnderlyingSymbol(), which remains the same no matter the strike
.
I'm also only able to see N/A for Open Interest most of the time.
Someone know how to correctly get the IV and OI for each bar when limited to a specific Option Contract?
I can see in ToS that the IV changes with every Strike whereas I can only get it to give me the IV from GetUnderlyingSymbol(), which remains the same no matter the strike
.
I'm also only able to see N/A for Open Interest most of the time.
Someone know how to correctly get the IV and OI for each bar when limited to a specific Option Contract?
Ruby:
declare upper;
declare once_per_bar;
input startTime = 930;
input endTime = 1600;
def adjStartTime = startTime;# - 1;
def adjEndTime = endTime;# - 1;
def agg = GetAggregationPeriod();
# we use a 1 bar offset to get orders to line up, so adjust for that here
def marketOpen = if agg >= AggregationPeriod.DAY then 1 else if SecondsTillTime(adjEndTime) >= 60 and SecondsFromTime(adjStartTime) >= -60 then 1 else 0;
def open_int = open_interest();
def imp_vol = imp_volatility(GetUnderlyingSymbol());
AddOrder(OrderType.BUY_TO_OPEN, marketOpen, low, 1, Color.WHITE, Color.WHITE,
name = "SOHLCP|"+GetSymbol()+"|"+open_int[-1]+"|"+imp_vol[-1]);
AddOrder(OrderType.SELL_TO_CLOSE, marketOpen, high, 1, Color.WHITE, Color.WHITE);