Skip to content

Feat/template#26

Merged
LeFi8 merged 8 commits into
mainfrom
feat/template
Jun 9, 2026
Merged

Feat/template#26
LeFi8 merged 8 commits into
mainfrom
feat/template

Conversation

@LeFi8

@LeFi8 LeFi8 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the flat lessons.md file with a SQLite-backed runs/lessons.db store, introduces equal_weight and momentum_rotation as reference strategies, and upgrades the init-strategy command to support templates and a non-interactive silent mode. Additionally, the upper bound on turnover_limit has been removed. Feedback on the changes highlights two key issues: first, the momentum_rotation strategy fails to filter for positive momentum as documented, which could lead to allocating capital to assets with negative returns; second, formatting the drawdown percentage using int(mdd * 100) in the template renderer can cause truncation errors due to floating-point precision, which should be resolved by using round() instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread strategies/momentum_rotation.py Outdated

returns = hist.pct_change(trading_days).iloc[-1]
ranked = returns.dropna().sort_values(ascending=False)
selected = [t for t in ranked.index if t in available and t != cash_asset][:top_n]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The implementation does not filter for positive momentum, which contradicts the docstring stating: 'If no assets have positive momentum the full allocation goes to the cash asset.' Currently, it will allocate to the top assets even if they have negative returns. Filter the selected assets to ensure they have a positive return.

Suggested change
selected = [t for t in ranked.index if t in available and t != cash_asset][:top_n]
selected = [t for t in ranked.index if t in available and t != cash_asset and ranked[t] > 0][:top_n]

Comment thread src/autobacktest/templates/__init__.py Outdated
"__NAME__": strategy_name,
"__UNIVERSE__": universe_str,
"__BENCHMARK__": benchmark,
"__DRAWDOWN_PCT__": str(int(mdd * 100)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Using int(mdd * 100) can lead to precision issues due to floating-point representation (for example, 0.29 * 100 evaluates to 28.999999999999996, which int() truncates to 28). Use round() to ensure correct rounding.

Suggested change
"__DRAWDOWN_PCT__": str(int(mdd * 100)),
"__DRAWDOWN_PCT__": str(round(mdd * 100)),

LeFi8 added 4 commits June 9, 2026 21:48
Removes all filesystem I/O from the templates module, which was the
root cause of FileNotFoundError in non-editable installs (CI Linux +
Python 3.14.5). Strategy .py source and program .md are now stored as
inline string constants; the _find_project_root / _PACKAGE_ROOT /
_source_path machinery is fully removed.
@LeFi8 LeFi8 merged commit d18936a into main Jun 9, 2026
3 checks passed
@LeFi8 LeFi8 deleted the feat/template branch June 9, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant