Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OptionIndicators cannot run IndicatorHistory #8591

Open
4 tasks done
LouisSzeto opened this issue Feb 17, 2025 · 0 comments · May be fixed by #8608
Open
4 tasks done

OptionIndicators cannot run IndicatorHistory #8591

LouisSzeto opened this issue Feb 17, 2025 · 0 comments · May be fixed by #8608
Assignees
Labels

Comments

@LouisSzeto
Copy link
Collaborator

Expected Behavior

Option Greeks indicators with base class OptionIndicatorsBase can work with IndicatorHistory for warming up manually.

Actual Behavior

Option Greeks indicators with base class OptionIndicatorsBase failed to work with IndicatorHistory.

Potential Solution

public IndicatorHistory IndicatorHistory(PyObject indicator, PyObject symbol, DateTime start, DateTime end, Resolution? resolution = null, PyObject selector = null)
{
var symbols = symbol.ConvertToSymbolEnumerable();
if (indicator.TryConvert(out IndicatorBase<IndicatorDataPoint> indicatorDataPoint))
{
return IndicatorHistory(indicatorDataPoint, symbols, start, end, resolution, selector?.ConvertToDelegate<Func<IBaseData, decimal>>());
}
else if (indicator.TryConvert(out IndicatorBase<IBaseDataBar> indicatorBar))
{
return IndicatorHistory(indicatorBar, symbols, start, end, resolution, selector?.ConvertToDelegate<Func<IBaseData, IBaseDataBar>>());
}
else if (indicator.TryConvert(out IndicatorBase<TradeBar> indicatorTradeBar))
{
return IndicatorHistory(indicatorTradeBar, symbols, start, end, resolution, selector?.ConvertToDelegate<Func<IBaseData, TradeBar>>());
}
return IndicatorHistory(WrapPythonIndicator(indicator), symbols, start, end, resolution, selector?.ConvertToDelegate<Func<IBaseData, IBaseData>>());
}
/// <summary>
/// Gets the historical data of an indicator and convert it into pandas.DataFrame
/// </summary>
/// <param name="indicator">The target indicator</param>
/// <param name="history">Historical data used to calculate the indicator</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>pandas.DataFrame containing the historical data of <paramref name="indicator"/></returns>
public IndicatorHistory IndicatorHistory(PyObject indicator, IEnumerable<Slice> history, PyObject selector = null)
{
if (indicator.TryConvert(out IndicatorBase<IndicatorDataPoint> indicatorDataPoint))
{
return IndicatorHistory(indicatorDataPoint, history, selector?.ConvertToDelegate<Func<IBaseData, decimal>>());
}
else if (indicator.TryConvert(out IndicatorBase<IBaseDataBar> indicatorBar))
{
return IndicatorHistory(indicatorBar, history, selector?.ConvertToDelegate<Func<IBaseData, IBaseDataBar>>());
}
else if (indicator.TryConvert(out IndicatorBase<TradeBar> indicatorTradeBar))
{
return IndicatorHistory(indicatorTradeBar, history, selector?.ConvertToDelegate<Func<IBaseData, TradeBar>>());
}
return IndicatorHistory(WrapPythonIndicator(indicator), history, selector?.ConvertToDelegate<Func<IBaseData, IBaseData>>());
}

should include implementation with IndicatorBase<IBaseData> or MultiSymbolIndicator<IBaseData>.

Reproducing the Problem

https://www.quantconnect.com/forum/discussion/18683/historical-options-greeks-in-research-environment/p1

System Information

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants