- ago
When setting parameter priceIsStrike: true an excpetion is thrown:

CODE:
underlyingPriceShort = 29.5; theLine = $">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> UnderlyingPriceShort {underlyingPriceShort}"; WriteToDebugLog(theLine); String oSynShort = OptionSynthetic.GetOptionsSymbol(tradingBars, OptionType.Put, underlyingPriceShort, tradingBars.DateTimes[idx], minDaysAhead: 40, allowExpired: true, priceIsStrike: true);


PostExecute Exception (04.02.2016) Line 261 - The input string '29.5' was not in a correct format.

at System.Number.ThrowFormatException[TChar](ReadOnlySpan`1 value)
at WealthLab.Backtest.OptionsHelper.ParseSymbol(String symbol)
at WealthLab.Backtest.OptionSynthetic.GetHistory(BarHistory underlier, String optionSymbol, Double iv)
at WealthScript1.MyStrategy.PostExecute(DateTime dt, List`1 participants) in :line 261
at WealthLab.Backtest.UserStrategyExecutor.InitGetter(List`1 lst, DateTime dt)
0
179
Solved
4 Replies

Reply

Bookmark

Sort
Cone8
 ( 24.31% )
- ago
#1
The code above works fine. The problem occurs when you call GetHistory(). It would be easy to pinpoint with a full (minimal) example that exhibits the error.
0
- ago
#2
Sorry, the issue in this case is the method OptionSynthetic.GetHistory()

Tested on IBM, most recent N years: 1

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; namespace WealthScript4 { public class MyStrategy : UserStrategyBase {                 //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          StartIndex = bars.Count - 1; } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) {          double underlyingPriceShort = 180.5;          String oSynShort = OptionSynthetic.GetOptionsSymbol(bars, OptionType.Put, underlyingPriceShort, bars.DateTimes[idx], minDaysAhead: 40, allowExpired: true, priceIsStrike: true);                    //why is a strike of 180.5 not possible?          BarHistory oBars = OptionSynthetic.GetHistory(bars, oSynShort, iv: 0.4); }       } }


Exception:
Execute Exception (IBM,249) Line 27 - The input string '180.5' was not in a correct format.
at System.Number.ThrowFormatException[TChar](ReadOnlySpan`1 value)
at WealthLab.Backtest.OptionsHelper.ParseSymbol(String symbol)
at WealthLab.Backtest.OptionSynthetic.GetHistory(BarHistory underlier, String optionSymbol, Double iv)
at WealthScript4.MyStrategy.Execute(BarHistory bars, Int32 idx) in :line 27
at WealthLab.Backtest.UserStrategyExecutor.InitGetter(List`1 lst, DateTime dt)
0
Glitch8
 ( 10.85% )
- ago
#3
I think I see the issue, but let's be sure. Are you using a non-US number format on your computer, so that the decimal character is not a "." I think we need to force the dot as the decimal character in the conversion routine in the OptionsHelper class. I'll fix that for next Build.
0
Best Answer
- ago
#4
Correct, I have german settings on PC:

0

Reply

Bookmark

Sort