Commit Graph

43 Commits

Author SHA1 Message Date
21in7
dfd4990ae5 feat: fetch realtime OI and funding rate on candle close for ML features
- Add asyncio import to bot.py
- Add _prev_oi state for OI change rate calculation
- Add _fetch_market_microstructure() for concurrent OI/funding rate fetch with exception fallback
- Add _calc_oi_change() for relative OI change calculation
- Always call build_features() before ML filter check in process_candle()
- Pass oi_change/funding_rate kwargs to build_features() in both process_candle() and _close_and_reenter()
- Update _close_and_reenter() signature to accept oi_change/funding_rate params

Made-with: Cursor
2026-03-02 13:55:29 +09:00
21in7
4669d08cb4 feat: build_features accepts oi_change and funding_rate params
Made-with: Cursor
2026-03-02 13:50:39 +09:00
21in7
2b315ad6d7 feat: add get_open_interest and get_funding_rate to BinanceFuturesClient
Made-with: Cursor
2026-03-02 13:46:25 +09:00
21in7
7a1abc7b72 chore: update python-binance dependency and improve error handling in BinanceFuturesClient
- Changed python-binance version requirement from 1.0.19 to >=1.0.28 for better compatibility and features.
- Modified exception handling in the cancel_all_orders method to catch all exceptions instead of just BinanceAPIException, enhancing robustness.
2026-03-02 13:24:27 +09:00
21in7
de2a402bc1 feat: enhance cancel_all_orders method to include Algo order cancellation
- Updated the cancel_all_orders method to also cancel all Algo open orders in addition to regular open orders.
- Added error handling to log warnings if the cancellation of Algo orders fails.
2026-03-02 02:15:49 +09:00
21in7
684c8a32b9 feat: add Algo Order API support and update ML feature handling
- Introduced support for Algo Order API, allowing automatic sending of STOP_MARKET and TAKE_PROFIT_MARKET orders.
- Updated README.md to include new features related to Algo Order API and real-time handling of ML features.
- Enhanced ML feature processing to fill missing OI and funding rate values with zeros for consistency in training data.
- Added new training log entries for the lgbm model with updated metrics.
2026-03-02 02:03:50 +09:00
21in7
c89374410e feat: enhance trading bot functionality and documentation
- Updated README.md to reflect new features including dynamic margin ratio, model hot-reload, and multi-symbol streaming.
- Modified bot logic to ensure raw signals are passed to the `_close_and_reenter` method, even when the ML filter is loaded.
- Introduced a new script `run_tests.sh` for streamlined test execution.
- Improved test coverage for signal processing and re-entry logic, ensuring correct behavior under various conditions.
2026-03-02 01:51:53 +09:00
21in7
9ec78d76bd feat: implement immediate re-entry after closing position on reverse signal
- Added `_close_and_reenter` method to handle immediate re-entry after closing a position when a reverse signal is detected, contingent on passing the ML filter.
- Updated `process_candle` to call `_close_and_reenter` instead of `_close_position` for reverse signals.
- Enhanced test coverage for the new functionality, ensuring correct behavior under various conditions, including ML filter checks and position limits.
2026-03-02 01:34:36 +09:00
21in7
725a4349ee chore: Update MLXFilter model deployment and logging with new training results and ONNX file management
- Added new training log entries for lgbm backend with AUC, precision, and recall metrics.
- Enhanced deploy_model.sh to manage ONNX and lgbm model files based on the selected backend.
- Adjusted output shape in mlx_filter.py for ONNX export to support dynamic batch sizes.
2026-03-02 01:08:12 +09:00
21in7
5e6cdcc358 fix: _on_candle_closed async 콜백 구조 수정 — asyncio.create_task 제거
동기 콜백 내부에서 asyncio.create_task()를 호출하면 이벤트 루프
컨텍스트 밖에서 실패하여 캔들 처리가 전혀 이루어지지 않는 버그 수정.

- _on_candle_closed: 동기 → async, create_task → await
- handle_message (KlineStream/MultiSymbolStream): 동기 → async, on_candle await
- test_callback_called_on_closed_candle: AsyncMock + await handle_message로 수정

Made-with: Cursor
2026-03-02 01:00:59 +09:00
21in7
361b0f4e00 fix: Update TradingBot signal processing to handle NaN values and improve MLFilter ONNX session configuration 2026-03-02 00:47:17 +09:00
21in7
7fdd8bff94 fix: MLXFilter self._mean/std 저장 전 nan_to_num 적용 — 전체-NaN 컬럼 predict_proba 오염 차단
Made-with: Cursor
2026-03-02 00:31:08 +09:00
21in7
bcc717776d fix: RS 계산을 np.divide(where=) 방식으로 교체 — epsilon 이상치 폭발 차단
Made-with: Cursor
2026-03-02 00:30:36 +09:00
21in7
6ae0f9d81b fix: MLXFilter fit/predict에 nan-safe 정규화 적용 (nanmean + nan_to_num)
Made-with: Cursor
2026-03-01 23:53:49 +09:00
21in7
820d8e0213 refactor: 분모 연산을 1e-8 epsilon 패턴으로 통일
Made-with: Cursor
2026-03-01 23:52:59 +09:00
21in7
417b8e3c6a feat: OI/펀딩비 결측 구간을 np.nan으로 마스킹 (0.0 → nan)
Made-with: Cursor
2026-03-01 23:52:19 +09:00
21in7
24d3ba9411 feat: enhance data fetching and model training with OI and funding rate integration
- Updated `fetch_history.py` to collect open interest (OI) and funding rate data from Binance, improving the dataset for model training.
- Modified `train_and_deploy.sh` to include options for OI and funding rate collection during data fetching.
- Enhanced `dataset_builder.py` to incorporate OI change and funding rate features with rolling z-score normalization.
- Updated training logs to reflect new metrics and features, ensuring comprehensive tracking of model performance.
- Adjusted feature columns in `ml_features.py` to include OI and funding rate for improved model robustness.
2026-03-01 22:25:38 +09:00
21in7
4245d7cdbf feat: implement 15-minute timeframe upgrade for model training and data processing
- Introduced a new markdown document detailing the plan to transition the entire pipeline from a 1-minute to a 15-minute timeframe, aiming to improve model AUC from 0.49-0.50 to over 0.53.
- Updated key parameters across multiple scripts, including `LOOKAHEAD` adjustments and default data paths to reflect the new 15-minute interval.
- Modified data fetching and training scripts to ensure compatibility with the new timeframe, including changes in `fetch_history.py`, `train_model.py`, and `train_and_deploy.sh`.
- Enhanced the bot's data stream configuration to operate on a 15-minute interval, ensuring real-time data processing aligns with the new model training strategy.
- Updated training logs to capture new model performance metrics under the revised timeframe.
2026-03-01 22:16:15 +09:00
21in7
a6697e7cca feat: implement LightGBM model improvement plan with feature normalization and walk-forward validation
- Added a new markdown document outlining the plan to enhance the LightGBM model's AUC from 0.54 to 0.57+ through feature normalization, strong time weighting, and walk-forward validation.
- Implemented rolling z-score normalization for absolute value features in `src/dataset_builder.py` to improve model robustness against regime changes.
- Introduced a walk-forward validation function in `scripts/train_model.py` to accurately measure future prediction performance.
- Updated training log to include new model performance metrics and added ONNX model export functionality for compatibility.
- Adjusted model training parameters for better performance and included detailed validation results in the training log.
2026-03-01 22:02:32 +09:00
21in7
c6428af64e feat: enhance Jenkins pipeline with Discord notifications and model hot-reload functionality
- Added a new stage to the Jenkins pipeline to notify Discord when a build starts, succeeds, or fails, improving communication during the CI/CD process.
- Implemented model hot-reload functionality in the MLFilter class, allowing automatic reloading of models when file changes are detected, enhancing responsiveness to updates.
- Updated deployment scripts to provide clearer messaging regarding model loading and container status, improving user experience and debugging capabilities.
2026-03-01 21:46:36 +09:00
21in7
d9238afaf9 feat: enhance MLX model training with combined data handling
- Introduced a new function `_split_combined` to separate XRP, BTC, and ETH data from a combined DataFrame.
- Updated `train_mlx` to utilize the new function, improving data management and feature handling.
- Adjusted dataset generation to accommodate BTC and ETH features, with warnings for missing features.
- Changed default data path in `train_mlx` and `train_model` to point to the combined dataset for consistency.
- Increased `LOOKAHEAD` from 60 to 90 and adjusted `ATR_TP_MULT` for better model performance.
2026-03-01 21:43:27 +09:00
21in7
db144750a3 feat: enhance model training and deployment scripts with time-weighted sampling
- Updated `train_model.py` and `train_mlx_model.py` to include a time weight decay parameter for improved sample weighting during training.
- Modified dataset generation to incorporate sample weights based on time decay, enhancing model performance.
- Adjusted deployment scripts to support new backend options and improved error handling for model file transfers.
- Added new entries to the training log for better tracking of model performance metrics over time.
- Included ONNX model export functionality in the MLX filter for compatibility with Linux servers.
2026-03-01 21:25:06 +09:00
21in7
ab580b18af feat: apply dynamic margin ratio in bot position sizing
Made-with: Cursor
2026-03-01 20:39:07 +09:00
21in7
795689ac49 feat: replace risk_per_trade with margin_ratio in calculate_quantity
Made-with: Cursor
2026-03-01 20:38:18 +09:00
21in7
fe9690698a feat: add get_dynamic_margin_ratio to RiskManager
Made-with: Cursor
2026-03-01 20:37:46 +09:00
21in7
95abac53a8 feat: add dynamic margin ratio config params
Made-with: Cursor
2026-03-01 20:37:04 +09:00
21in7
d1af736bfc feat: implement BTC/ETH correlation features for improved model accuracy
- Added a new design document outlining the integration of BTC/ETH candle data as additional features in the XRP ML filter, enhancing prediction accuracy.
- Introduced `MultiSymbolStream` for combined WebSocket data retrieval of XRP, BTC, and ETH.
- Expanded feature set from 13 to 21 by including 8 new BTC/ETH-related features.
- Updated various scripts and modules to support the new feature set and data handling.
- Enhanced training and deployment scripts to accommodate the new dataset structure.

This commit lays the groundwork for improved model performance by leveraging the correlation between BTC and ETH with XRP.
2026-03-01 19:30:17 +09:00
21in7
de933b97cc feat: remove in-container retraining, training is now mac-only
Made-with: Cursor
2026-03-01 18:54:00 +09:00
21in7
e1560f882b feat: add vectorized dataset builder (1x pandas_ta call)
Made-with: Cursor
2026-03-01 18:52:34 +09:00
21in7
7e4e9315c2 feat: implement ML filter with LightGBM for trading signal validation
- Added MLFilter class to load and evaluate LightGBM model for trading signals.
- Introduced retraining mechanism to update the model daily based on new data.
- Created feature engineering and label building utilities for model training.
- Updated bot logic to incorporate ML filter for signal validation.
- Added scripts for data fetching and model training.

Made-with: Cursor
2026-03-01 17:07:18 +09:00
21in7
3d05806155 feat: Discord 알림, 포지션 복구, 설정 개선 및 docs 추가
Made-with: Cursor
2026-03-01 15:57:08 +09:00
21in7
117fd9e6bc fix: AsyncClient.futures_klines await 누락 수정
Made-with: Cursor
2026-03-01 13:04:02 +09:00
21in7
4940de16fc feat: 봇 시작 시 과거 캔들 200개 프리로드 (즉시 신호 계산 가능)
Made-with: Cursor
2026-03-01 13:02:42 +09:00
21in7
8e5ec82244 fix: BinanceSocketManager 메서드명 수정 (futures_kline_socket → kline_futures_socket)
Made-with: Cursor
2026-03-01 12:56:53 +09:00
21in7
a90618896d feat: 엔트리포인트 및 로깅 설정 완료, 테스트 mock 개선
Made-with: Cursor
2026-03-01 12:54:21 +09:00
21in7
726e9cfd65 feat: TradingBot 메인 루프 구현 (진입/청산/손절/익절)
Made-with: Cursor
2026-03-01 12:53:40 +09:00
21in7
69b5675bfd feat: WebSocket 실시간 캔들 스트림 구현
Made-with: Cursor
2026-03-01 12:52:40 +09:00
21in7
4bab4cdba3 feat: 리스크 매니저 구현 (일일 손실 한도, 포지션 수 제한)
Made-with: Cursor
2026-03-01 12:52:05 +09:00
21in7
8bbf376425 feat: Notion 거래 이력 저장 모듈 구현
Made-with: Cursor
2026-03-01 12:51:27 +09:00
21in7
7a3dde2146 feat: 복합 기술 지표 모듈 구현 (RSI/MACD/BB/EMA/ATR/StochRSI)
Made-with: Cursor
2026-03-01 12:50:51 +09:00
21in7
b1a7632bbe feat: BinanceFuturesClient 구현
Made-with: Cursor
2026-03-01 12:49:26 +09:00
21in7
81b7a7f714 feat: Config 모듈 추가 (Notion 연동 포함)
Made-with: Cursor
2026-03-01 12:48:34 +09:00
21in7
60b0e01a01 chore: 프로젝트 초기 설정 및 의존성 추가
Made-with: Cursor
2026-03-01 12:48:03 +09:00