Skip to content

feat: Daily spot DCA — auto-buy SOL at midnight UTC#10

Merged
ArielB1980 merged 1 commit intomainfrom
feat/spot-dca-sol
Feb 20, 2026
Merged

feat: Daily spot DCA — auto-buy SOL at midnight UTC#10
ArielB1980 merged 1 commit intomainfrom
feat/spot-dca-sol

Conversation

@ArielB1980
Copy link
Owner

Summary

  • Adds a daily spot DCA (Dollar Cost Averaging) feature that auto-purchases SOL using available USD balance on the Kraken spot account at midnight UTC
  • Runs as an asyncio background task within the existing live trading loop
  • New place_spot_order() method on KrakenClient using the spot CCXT instance
  • Also fixes pre-existing bug: get_account_balance() was missing await on fetch_balance()

Safety guards

  • Skips purchase if balance < min_purchase_usd ($5 default)
  • Respects reserve_usd — keeps configured amount untouched
  • Caps at max_purchase_usd if configured
  • Graceful error handling: API failures logged, never crash the trading loop
  • DRY_RUN mode support (logs intent without placing orders)
  • Telegram alerts on success and failure

Config (config.yaml)

spot_dca:
  enabled: true
  asset: SOL
  schedule_hour_utc: 0    # Midnight UTC
  use_full_balance: true
  min_purchase_usd: 5.0
  reserve_usd: 0.0

Test plan

  • 18/18 unit tests pass (config, scheduling, purchase logic, safety guards)
  • Config loads cleanly with new spot_dca section
  • Observe first midnight execution in production logs

Made with Cursor

Adds a background task that runs alongside the live trading loop.
At midnight UTC each day, it fetches the available USD balance on
the Kraken spot account and places a market buy for SOL (configurable).

Components:
- SpotDCAConfig: Pydantic config with asset, schedule, sizing controls
- KrakenClient.place_spot_order(): New spot order method via CCXT
- src/live/spot_dca.py: Scheduler + purchase executor with safety guards
- LiveTrading: Background task integration with proper cleanup
- Fix: get_account_balance() missing await (pre-existing bug)

Safety guards:
- Skips if available balance < min_purchase_usd ($5 default)
- Respects reserve_usd (keeps N dollars untouched)
- Caps at max_purchase_usd if configured
- Graceful handling of API failures (no crash)
- DRY_RUN mode support
- Telegram alerts on success and failure

18 unit tests covering config, scheduling, purchase logic, and all
safety edge cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ArielB1980 ArielB1980 merged commit 8bbc7cd into main Feb 20, 2026
1 check failed
@cursor
Copy link

cursor bot commented Feb 20, 2026

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on March 2.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

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