Skip to content

Commit 6057c49

Browse files
michaelchuclaude
andcommitted
Fix cross-symbol signal_symbol handling per PR review
- Strip whitespace from signal_symbol to prevent cache key issues - Gate cross-symbol remapping on needs_stock to avoid duplicating rows when signal_symbol is set on IV or date-only signals Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bd90450 commit 6057c49

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

optopsy/ui/tools/_signals_builder.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def _handle_build_signal(arguments, dataset, signals, datasets, results, _result
8585

8686
signal_data = None
8787
signal_symbol = arguments.get("signal_symbol")
88+
if signal_symbol:
89+
signal_symbol = signal_symbol.strip()
8890

8991
if has_iv_signal:
9092
iv_data = _iv_signal_data(dataset)
@@ -167,8 +169,11 @@ def _handle_build_signal(arguments, dataset, signals, datasets, results, _result
167169
# Compute valid dates, intersected with actual options dates.
168170
raw_signal_dates = signal_dates(signal_data, combined)
169171

170-
# Cross-symbol: remap signal symbol to options dataset symbol(s)
171-
if signal_symbol and not raw_signal_dates.empty:
172+
# Cross-symbol: remap signal symbol to options dataset symbol(s).
173+
# Only applies when we actually fetched data for signal_symbol (i.e.
174+
# needs_stock was true). IV and date-only signals already use the
175+
# options dataset's symbols, so remapping would duplicate rows.
176+
if signal_symbol and needs_stock and not raw_signal_dates.empty:
172177
options_symbols = dataset["underlying_symbol"].unique().tolist()
173178
frames = []
174179
for opt_sym in options_symbols:
@@ -259,6 +264,8 @@ def _handle_build_custom_signal(
259264

260265
# Fetch OHLCV data for signal computation
261266
signal_symbol = arguments.get("signal_symbol")
267+
if signal_symbol:
268+
signal_symbol = signal_symbol.strip()
262269
if signal_symbol:
263270
signal_data = _fetch_stock_data_for_symbol(signal_symbol, dataset)
264271
else:

0 commit comments

Comments
 (0)