245 Commits

Author SHA1 Message Date
21in7
852d3a8265 feat: implement multi-symbol trading design and plan documentation
- Added design document outlining the architecture for multi-symbol trading, including independent TradingBot instances and shared RiskManager.
- Created implementation plan detailing tasks for configuration, risk management, and execution structure for multi-symbol support.
- Updated configuration to support multiple trading symbols and correlation symbols, ensuring backward compatibility.
- Introduced shared RiskManager with constraints on position limits and direction to manage global risk effectively.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:34:01 +09:00
21in7
9ac839fd83 docs: update README and ARCHITECTURE for multi-symbol trading
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:32:14 +09:00
21in7
b03182691e docs: update architecture and commands for multi-symbol trading
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:26:59 +09:00
21in7
2bb2bf2896 feat: add per-symbol model/data directories and update .env.example
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:24:50 +09:00
21in7
909d6af944 feat: add --symbol/--all CLI to all training scripts for per-symbol pipeline
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:21:32 +09:00
21in7
ae5692cde4 feat: MLFilter falls back to models/ root if symbol-specific dir not found
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:14:38 +09:00
21in7
7acbdca3f4 feat: main.py spawns per-symbol TradingBot instances with shared RiskManager
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:13:52 +09:00
21in7
e7620248c7 feat: TradingBot accepts symbol and shared RiskManager, removes config.symbol dependency
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:13:04 +09:00
21in7
2e09f5340a feat: exchange client accepts explicit symbol parameter, removes config.symbol dependency
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:07:44 +09:00
21in7
9318fb887e feat: shared RiskManager with async lock, same-direction limit, per-symbol tracking
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:06:41 +09:00
21in7
7aef391b69 feat: add multi-symbol config (symbols list, correlation_symbols, max_same_direction)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 23:05:22 +09:00
21in7
39e55368fd feat: log technical indicators on entry and add dashboard docs to README
- Include RSI, MACD_H, ATR in bot entry log so the log parser can
  extract and store them in the trades DB for dashboard display
- Update log parser regex and _handle_entry() to persist indicator values
- Add dashboard section to README (tech stack, screens, API endpoints)
- Add dashboard/ directory to project structure in README

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:08:16 +09:00
21in7
aef161002d fix: filter non-numeric /proc entries in DB reset parser kill
The previous /proc-based process kill attempted to read cmdline from
non-PID entries like /proc/fb, causing NotADirectoryError in Docker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:01:53 +09:00
21in7
bfecf63f1c refactor: improve log parser termination method in DB reset
- Replaced subprocess-based termination of the log parser with a Python-native approach using os and signal modules.
- Enhanced process handling to ensure proper termination of existing log parser instances before restarting.

This change improves reliability and compatibility across different environments.
2026-03-05 20:59:48 +09:00
21in7
6f3ea44edb feat: add DB reset button to dashboard
- POST /api/reset endpoint: clears all tables and restarts log parser
- UI: Reset DB button in footer with confirmation dialog

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 20:57:00 +09:00
21in7
f75ad9f6b1 fix: log parser duplicate position bug and selective CI/CD deployment
- Log parser: fix entry dedup to check direction instead of price tolerance,
  preventing duplicate OPEN trades for the same position
- Log parser: close all OPEN trades on position close, delete stale duplicates
- Jenkinsfile: detect changed files and only build/deploy affected services,
  allowing dashboard-only changes without restarting the bot

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 20:52:23 +09:00
21in7
07ba510fd8 chore: update Docker image references in docker-compose.yml
- Changed image references for cointrader, dashboard-api, and dashboard-ui services to use the new GitLab registry URL.
- Ensured consistency in image source for better maintainability and deployment.
2026-03-05 20:27:43 +09:00
21in7
565414c5e0 feat: add trading dashboard with API and UI components
- Introduced a new trading dashboard consisting of a FastAPI backend (`dashboard-api`) for data retrieval and a React frontend (`dashboard-ui`) for visualization.
- Implemented a log parser to monitor and store bot logs in an SQLite database.
- Configured Docker setup for both API and UI, including necessary Dockerfiles and a docker-compose configuration.
- Added setup documentation for running the dashboard and accessing its features.
- Enhanced the Jenkins pipeline to build and push the new dashboard images.
2026-03-05 20:25:45 +09:00
21in7
c555afbddc chore: update .gitignore, CLAUDE.md, training_log.json, and ml_filter.py
- Added .worktrees/ to .gitignore to prevent tracking of worktree files.
- Marked `optuna-precision-objective-plan` as completed in CLAUDE.md.
- Added new training log entry for a LightGBM model with updated parameters and performance metrics in training_log.json.
- Updated error handling in ml_filter.py to return False on prediction errors instead of True, improving the robustness of the ML filter.
2026-03-05 20:04:15 +09:00
21in7
2b92fd0dce feat: implement testnet and demo trading setup for XRPUSDT with 125x leverage
- Added support for demo trading on Binance Futures with a new configuration for 1-minute candles and 125x leverage.
- Updated various components including Config, Exchange, DataStream, UserDataStream, and Bot to handle demo and testnet flags.
- Enhanced the training pipeline to collect 1-minute data and adjusted the lookahead for model training.
- Updated environment variables in .env and .env.example to include demo settings.

This commit lays the groundwork for testing ML-based automated trading strategies in a controlled environment.
2026-03-04 20:43:05 +09:00
21in7
8a8c714a7c merge: resolve CLAUDE.md conflict, mark oi-derived-features as completed
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:33:12 +09:00
21in7
b55ddd8868 feat: add OI derived features (oi_change_ma5, oi_price_spread) 2026-03-04 20:32:51 +09:00
21in7
d2773e4dbf docs: update CLAUDE.md with OI derived features plan status and 26-feature count
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:24:18 +09:00
21in7
f2303e1863 feat: add OI long-term collection script for cron-based data accumulation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:24:14 +09:00
21in7
448b3e016b feat: add OI history deque, cold start init, and derived features to bot runtime
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:17:37 +09:00
21in7
ffa6e443c1 feat: add --compare flag for OI derived features A/B comparison
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:13:07 +09:00
21in7
ff9e639142 feat: add OI derived features (oi_change_ma5, oi_price_spread) to dataset builder and ML features
Add two new OI-derived features to improve ML model's market microstructure
understanding:
- oi_change_ma5: 5-candle moving average of OI change rate (short-term trend)
- oi_price_spread: z-scored OI minus z-scored price return (divergence signal)

Both features use 96-candle rolling z-score window. FEATURE_COLS expanded from
24 to 26. Existing tests updated to reflect new feature counts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:07:40 +09:00
21in7
676ec6ef5e docs: add OI derived features implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:00:36 +09:00
21in7
33271013d3 docs: add OI derived features design doc
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:56:42 +09:00
21in7
b50306d68b docs: update README with ML_THRESHOLD configuration and add new training log entry
- Added `ML_THRESHOLD` parameter to README, specifying its role in ML filter predictions.
- Included a new entry in the training log with detailed metrics from a recent model training session, enhancing performance tracking and documentation.
2026-03-03 21:34:57 +09:00
4a2349bdbd Merge pull request 'claude/interesting-mcnulty' (#3) from claude/interesting-mcnulty into main
Reviewed-on: #3
2026-03-03 21:20:59 +09:00
21in7
c39097bf70 docs: add ADX ML migration design/plan and position monitor logging docs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 21:18:22 +09:00
21in7
9c6f5dbd76 feat: remove ADX hard filter from dataset builder, add ADX as ML feature
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 21:17:49 +09:00
21in7
0aeb15ecfb feat: remove ADX hard filter, delegate to ML
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 21:14:50 +09:00
21in7
0b18a0b80d feat: add ADX as 24th ML feature for trend strength learning
Migrate ADX from hard filter (ADX < 25 blocks entry) to ML feature so
the model can learn optimal ADX thresholds from data. Updates FEATURE_COLS,
build_features(), and corresponding tests from 23 to 24 features.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 21:11:04 +09:00
038a1f84ec Merge pull request 'feat: add position monitor logging with real-time price tracking' (#2) from claude/intelligent-shtern into main
Reviewed-on: #2
2026-03-03 20:38:17 +09:00
21in7
a33283ecb3 feat: add position monitor logging with real-time price tracking
Log current price and unrealized PnL every 5 minutes while holding a position,
using the existing kline WebSocket's unclosed candle data for real-time price updates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 20:36:46 +09:00
21in7
292ecc3e33 feat: update ML threshold and configuration for improved model performance
- Added ML_THRESHOLD to .env.example and updated Config class to include ml_threshold with a default value of 0.55.
- Modified MLFilter initialization in bot.py to utilize the new ml_threshold configuration.
- Updated Jenkinsfile to change the registry URL for Docker image management.

These changes enhance the model's adaptability by allowing for a configurable machine learning threshold, improving overall performance.
2026-03-03 20:09:03 +09:00
21in7
6fe2158511 feat: enhance precision optimization in model training
- Introduced a new plan to modify the Optuna objective function to prioritize precision under a recall constraint of 0.35, improving model performance in scenarios where false positives are costly.
- Updated training scripts to implement precision-based metrics and adjusted the walk-forward cross-validation process to incorporate precision and recall calculations.
- Enhanced the active LGBM parameters and training log to reflect the new metrics and model configurations.
- Added a new design document outlining the implementation steps for the precision-focused optimization.

This update aims to refine the model's decision-making process by emphasizing precision, thereby reducing potential losses from false positives.
2026-03-03 00:57:19 +09:00
21in7
3613e3bf18 feat: update active LGBM parameters and training log with new metrics
- Updated active LGBM parameters with new timestamp, trial results, and model configurations to reflect recent training outcomes.
- Added new entries to the training log, capturing detailed metrics including AUC, precision, recall, and tuned parameters for the latest model iterations.

This update enhances the tracking of model performance and parameter tuning in the ML pipeline.
2026-03-03 00:21:43 +09:00
21in7
fce4d536ea feat: implement HOLD negative sampling and stratified undersampling in ML pipeline
Added HOLD candles as negative samples to increase training data from ~535 to ~3,200 samples. Introduced a negative_ratio parameter in generate_dataset_vectorized() for sampling HOLD candles alongside signal candles. Implemented stratified undersampling to ensure signal samples are preserved during training. Updated relevant tests to validate new functionality and maintain compatibility with existing tests.

- Modified dataset_builder.py to include HOLD negative sampling logic
- Updated train_model.py to apply stratified undersampling
- Added tests for new sampling methods

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 00:13:42 +09:00
21in7
74966590b5 feat: apply stratified undersampling to hyperparameter tuning
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 00:09:43 +09:00
21in7
6cd54b46d9 feat: apply stratified undersampling to training pipeline
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 00:03:09 +09:00
21in7
0af138d8ee feat: add stratified_undersample helper function
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 23:58:15 +09:00
21in7
b7ad358a0a fix: make HOLD negative sampling tests non-vacuous
The two HOLD negative tests (test_hold_negative_labels_are_all_zero,
test_signal_samples_preserved_after_sampling) were passing vacuously
because sample_df produces 0 signal candles (ADX ~18, below threshold
25). Added signal_producing_df fixture with higher volatility and volume
surges to reliably generate signals. Removed if-guards so assertions
are mandatory. Also restored the full docstring for
generate_dataset_vectorized() documenting btc_df/eth_df,
time_weight_decay, and negative_ratio parameters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 23:45:10 +09:00
21in7
8e56301d52 feat: add HOLD negative sampling to dataset_builder
Add negative_ratio parameter to generate_dataset_vectorized() that
samples HOLD candles as label=0 negatives alongside signal candles.
This increases training data from ~535 to ~3,200 samples when enabled.

- Split valid_rows into base_valid (shared) and sig_valid (signal-only)
- Add 'source' column ("signal" vs "hold_negative") for traceability
- HOLD samples get label=0 and random 50/50 side assignment
- Default negative_ratio=0 preserves backward compatibility
- Fix incorrect column count assertion in existing test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 23:34:45 +09:00
21in7
99fa508db7 feat: add CLAUDE.md and settings.json for project documentation and plugin configuration
Introduced CLAUDE.md to provide comprehensive guidance on the CoinTrader project, including architecture, common commands, testing, and deployment details. Added settings.json to enable the superpowers plugin for Claude. This enhances the project's documentation and configuration management.
2026-03-02 20:01:18 +09:00
21in7
eeb5e9d877 feat: add ADX filter to block sideways market entries
ADX < 25 now returns HOLD in get_signal(), preventing entries during
trendless (sideways) markets. NaN ADX values fall through to existing
weighted signal logic. Also syncs the vectorized dataset builder with
the same ADX filter to keep training data consistent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 19:55:12 +09:00
21in7
c8a2c36bfb feat: add ADX calculation to indicators
Add ADX (Average Directional Index) with period 14 to calculate_all()
for sideways market filtering. Includes test verifying the adx column
exists and contains non-negative values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 19:47:18 +09:00
21in7
b8b99da207 feat: update training log and enhance ML filter functionality
- Added a new entry to the training log with detailed metrics for a LightGBM model, including AUC, precision, recall, and tuned parameters.
- Enhanced the MLFilter class to include a guard clause that prevents execution if the filter is disabled, improving robustness.
2026-03-02 18:24:38 +09:00