I've just updated the list of pairs being traded by a strategy. I've created a new file with the new symbols formatted the same as the previous version (which was running fine). I've also created corresponding new dataset to match and updated it.
I've also updated the strategy settings to point to the new dataset and also edited the script to point to the correct new pairs file.
However, when I run the script I get the following errors (these are for all symbols that weren't in the previous file). The new pairs file is at the end of this post, which shows that the errored symbols are actually present in the pairs file.
The code that reads the pairs file is:
...and the piece of code that throws the error is:
I've clearly missed a crucial step but am stumped as to what. Thx
I've also updated the strategy settings to point to the new dataset and also edited the script to point to the correct new pairs file.
However, when I run the script I get the following errors (these are for all symbols that weren't in the previous file). The new pairs file is at the end of this post, which shows that the errored symbols are actually present in the pairs file.
CODE:
Initialize Exception (FBP) Line 64 - Symbol not found in Pairs file: FBP Initialize Exception (AGCO) Line 64 - Symbol not found in Pairs file: AGCO Initialize Exception (FIBK) Line 64 - Symbol not found in Pairs file: FIBK Initialize Exception (FTS) Line 64 - Symbol not found in Pairs file: FTS Initialize Exception (FUL) Line 64 - Symbol not found in Pairs file: FUL Initialize Exception (ETR) Line 64 - Symbol not found in Pairs file: ETR Initialize Exception (CUBE) Line 64 - Symbol not found in Pairs file: CUBE Initialize Exception (PB) Line 64 - Symbol not found in Pairs file: PB Initialize Exception (EIX) Line 64 - Symbol not found in Pairs file: EIX Initialize Exception (PPBI) Line 64 - Symbol not found in Pairs file: PPBI at WealthScript9.MyStrategy.Initialize(BarHistory bars) in :line 64 at WealthLab.Backtest.UserStrategyExecutor.AssetListener(List`1 symbols)
The code that reads the pairs file is:
CODE:
//create pairs dictionary on-demand if (_pairs == null) { _pairs = new Dictionary<string, (string, double)>(); SetGlobal("PairsData", _pairs); //load pairs file contents string fileName = Path.Combine(WLHost.Instance.DataFolder, "pairs2024_Jul.csv"); if (!File.Exists(fileName)) throw new FileNotFoundException("Pairs file not found: " + fileName); string[] lines = File.ReadAllLines(fileName); foreach (string line in lines) { if (line.Trim() == "") continue; string[] tokens = line.Split(';'); string[] pairTokens = tokens[0].Split('/'); (string, double) pw; pw.Item1 = pairTokens[1]; pw.Item2 = Double.Parse(tokens[1], CultureInfo.InvariantCulture); _pairs[pairTokens[0]] = pw; } }
...and the piece of code that throws the error is:
CODE:
if (!_pairs.ContainsKey(bars.Symbol)) throw new InvalidOperationException("Symbol not found in Pairs file: " + bars.Symbol);
I've clearly missed a crucial step but am stumped as to what. Thx
CODE:
ABCB/CADE;0.077 AGCO/DE;0.154 AOS/ITW;0.154 ARCC/TSLX;0.077 ASB/HBAN;0.077 CDNS/MANH;0.062 CUBE/FR;0.062 DRH/HST;0.062 EIX/EVRG;0.077 ETR/FE;0.077 FBP/MTB;0.077 FFBC/ONB;0.077 FIBK/UCBI;0.077 FTS/LNT;0.077 FUL/RPM;0.077 LADR/RITM;0.062 PB/PNC;0.077 PMT/RC;0.062 PPBI/VLY;0.077 QGEN/TMO;0.154
Rename
Try restarting WL8, the pairs data is stored in WL8 Global Memory, so you might need a restart to force it to read the file again.
Thx - that fixed it.
Your Response
Post
Edit Post
Login is required