Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion 7_XAUUSD_Long_Short_Features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4516,7 +4516,29 @@
{
"cell_type": "code",
"source": [
"#### Cell to work ON"
"# Align indicator values so short trades mirror the long setup",
"if \'Open_Trade\' not in df_diff.columns:",
" if \'Open_Trade\' in df.columns:",
" df_diff = pd.merge(",
" df_diff,",
" df[[\'Date\', \'Open_Trade\']],",
" on=\'Date\',",
Comment on lines +4519 to +4525

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Fix invalid escaping in notebook cell

The added cell is not valid JSON: running python -m json.tool 7_XAUUSD_Long_Short_Features.ipynb now fails with Invalid \escape: line 4520 column 13 (char 199663), while the parent version loads correctly. The new strings include backslashes that don’t form legal JSON escapes (e.g. "if \'Open_Trade\' not in df_diff.columns:"), so the notebook cannot be opened by Jupyter or any JSON parser. Re‑save the notebook or adjust the inserted code so the JSON contains only valid escape sequences.

Useful? React with 👍 / 👎.

" how=\'left\'",
" )",
" else:",
" raise KeyError(\"'Open_Trade' column not found in df_diff or source df.\")",
"",
"numeric_indicator_cols = [",
" col",
" for col in df_diff.columns",
" if col not in [\'Date\', \'label\', \'Open_Trade\']",
" and pd.api.types.is_numeric_dtype(df_diff[col])",
"]",
"",
"short_mask = df_diff['Open_Trade'] == -1",
"df_diff.loc[short_mask, numeric_indicator_cols] = (",
" df_diff.loc[short_mask, numeric_indicator_cols].mul(-1)",
")"
],
"metadata": {
"id": "4TPpba7UChUY"
Expand Down