Skip to content

Small-account research, MomentumRotation1d, research-paper case study, v0.1.0 packaging - #5

Merged
devam2001 merged 6 commits into
mainfrom
feature/small-account
Oct 10, 2026
Merged

devam2001 merged 6 commits into
mainfrom
feature/small-account

Conversation

@devam2001

@devam2001 devam2001 commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #4. This branch contains #4's commit, so merge #4 first; this PR's diff then shrinks to its own four commits.

Why

  • Can the bot trade a ~100 AUD account, and can profit be pushed higher?
  • The case study should be a research paper in a black theme.
  • Ridgeline needs its first release: a Windows installer and a Docker image.

Research

OOS 2025-06-01 → 2026-10-10 (market −32.8%) Return Max DD Gates
TrendRider4h +17.3% 9.8% 8 / 9 (99 of 100 trades)
MomentumRotation1d (new) +13.1% 5.2% 7 / 9
EmaRsiMomentum +5.1% 18.1% 6 / 9
TrendDipBuyer1h −17.8% 19.2% 4 / 9
  • 100 AUD (≈65 USDT) works. research.py gates --balance 65 gives the same percentage results. Positions are ~6–26 USDT, above Binance's minimum order.
  • More risk doesn't create more edge. 3% risk per trade: OOS +20.7% vs +17.5%, but the drawdown doubled and the profit factor fell below the gate. 4.5% lost money in-sample.
  • MomentumRotation1d: a daily cross-sectional momentum rotation, with settings chosen in-sample only.
    • Lowest OOS drawdown and best profit factor.
    • Fails the trade-count and walk-forward gates.
    • Fragile to its lookback (7d −15% … 14d +37% … 21d −4% in-sample).
    • Its "catch bull runs" rationale isn't supported by the walk-forward.
  • Two measurement fixes (no strategy's eligibility changes):
    • Lookahead for cross-sectional strategies. Freqtrade's lookahead-analysis reloads one pair at a time, which always flags a ranking. These strategies are now checked by removing later data from every pair and requiring identical earlier trades: 132 of 132 matched. A unit test covers it too.
    • Indicator stability is measured at the strategy's own warm-up or longer. The check also caught a real bug: the rotation's BTC EMA200 warm-up was raised from 210 to 360 days.

Case study

scripts/case_study.py builds Crypto Trading Bot Case Study.pdf from the latest research JSON. It has a black theme and research structure:

  • abstract and research questions
  • condensed market background, with the original 50 sources kept
  • methodology, results with two charts, discussion, limitations, references

Release packaging (v0.1.0)

  • Windows installer (installer/):
    • Inno Setup, per-user, with a private Python 3.12, Freqtrade and FreqUI.
    • Start-menu shortcuts for the panel and "Update market data".
    • Never overwrites config.json; keeps user_data on upgrade and uninstall.
  • Docker: the image now contains the code, and compose mounts only user_data. Servers can docker compose pull ghcr.io/devam2001/ridgeline.
  • .github/workflows/release.yml: a v* tag builds and smoke-tests both, pushes the image, and creates the release with the installer and case study attached. This PR runs the build and smoke tests without publishing.
  • requirements.txt, scripts/update_data.py, and the version shown in the panel.

Testing

  • ruff check . clean; pytest 67 passed (new: rotation ranking/no-lookahead, recursive-gate parsing, version consistency).
  • Both gate suites re-run end to end at 1000 and 65 USDT.
  • Docker image built locally:
    • all 4 strategies load
    • the panel imports
    • user_data defaults are present and nothing private is in the image
  • Case study PDF rendered and checked page by page.
  • The Windows installer can't be built on this machine (no Inno Setup). The Release workflow on this PR builds it and runs installer/smoke-test.ps1 (silent install → strategies load → panel answers → uninstall keeps user_data).

Replays the exact period a paper session ran (same strategy, pairs, balance,
max open trades), matches trades by pair and entry time, and checks that paper
results are close to the replay: 28+ days, 80%+ of trades in both, realised
return within 2 points, fills within 0.3% per side. The return gap is split
into matched-trade execution, paper-only and replay-only trades, and anything
the replay can't reproduce (manual pause/resume/flatten, halts, code changed
mid-session) is flagged.

- ridgeline/reconcile.py: session discovery, trade matching, checks
- panel/replay.py: data top-up, session replay, background jobs
- panel: Paper vs replay card; the Research tab's last gate shows real results
- scripts/reconcile.py: CLI for panel sessions and the Docker bot
- panel sessions now record their pairs, balance, start and a code
  fingerprint in <session>.meta.json (config.json's pair list changes monthly)
…ategies

- MomentumRotation1d: daily cross-sectional momentum rotation (top 3 of the
  whitelist by 14-day risk-adjusted momentum while BTC is risk-on), with
  risk-based sizing under the shared portfolio limits. Settings chosen on
  in-sample data only.
- research.py: Freqtrade's lookahead-analysis reloads one pair at a time, so
  it reports any cross-sectional ranking as biased. Strategies that declare
  `cross_sectional = True` are checked instead by backtesting with later data
  removed from every pair and requiring identical earlier trades.
- research.py --balance: run the gates at any starting balance (65 USDT is
  about 100 AUD); results go to latest-<balance>.json.
- Tests: the ranking never looks ahead when future days are cut from all pairs.
- Gates re-run with MomentumRotation1d at 1000 and 65 USDT (about 100 AUD,
  `research.py gates --balance 65` -> latest-65.json). No strategy is
  eligible yet: TrendRider4h 8/9 (99 of 100 trades), MomentumRotation1d 7/9.
- Indicator stability is measured at the strategy's own warm-up or longer;
  columns with fewer startup candles than the strategy declares test a setup
  that never runs. No strategy's eligibility changes.
- RESEARCH.md: small-account results, the risk-per-trade experiment (more
  risk added little return and doubled drawdown), the rotation's lookback
  sensitivity, and both check changes.
- scripts/case_study.py builds the case study PDF (black theme, research
  format: abstract, methodology, results, discussion, limitations,
  references) from the latest research results. The market background is
  the earlier case study, condensed with its sources kept.
…(v0.1.0)

- installer/: Inno Setup installer with a private Python, Freqtrade and
  FreqUI; per-user install, Start-menu shortcuts for the panel and for
  updating market data. user_data (private config, sessions, data, audit)
  survives upgrades and uninstall; config.json is never overwritten.
  smoke-test.ps1 installs it silently, starts the panel and uninstalls.
- Docker image now carries the code; compose mounts only user_data and can
  pull ghcr.io/devam2001/ridgeline instead of building.
- .github/workflows/release.yml: a v* tag builds and smoke-tests both,
  publishes the image and creates the GitHub release with the installer and
  case study attached. Pull requests touching packaging build and test both.
- requirements.txt pins the runtime; scripts/update_data.py runs the README's
  data steps; the panel shows the version.
Copying "<python>\*" into a stage folder that doesn't exist yet made the
first file the destination and then failed on the subfolders ("Container
cannot be copied onto existing leaf item"). Copy the folder itself instead.

Also: install Inno Setup with choco if the runner lacks it, use the x64
architecture flag every Inno Setup 6 accepts, anchor the config.json exclude,
and make the smoke test wait for the uninstaller's helper process.
@devam2001
devam2001 force-pushed the feature/small-account branch from ccdb52c to 59af70b Compare October 10, 2026 15:49
@devam2001
devam2001 merged commit 2bfe10d into main Oct 10, 2026
8 checks passed
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