Skip to content

feat: Deduplicate coin list at startup with warning log#121

Merged
keitaj merged 1 commit into
mainfrom
feat/deduplicate-coins
Apr 24, 2026
Merged

feat: Deduplicate coin list at startup with warning log#121
keitaj merged 1 commit into
mainfrom
feat/deduplicate-coins

Conversation

@keitaj

@keitaj keitaj commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Detect and remove duplicate coins in the trading list at startup, logging a WARNING with the duplicates
  • Prevents issues like the TSLA duplication bug where .env.farming and start_farming_us.sh both added TSLA, causing XYZ_COINS=...,TSLA,TSLA,...
  • Extracted as _deduplicate_coins() static method for testability

Motivation

A real bug was discovered where TSLA appeared twice in the US session coin list. This caused the bot to allocate double position slots to TSLA and potentially worsened cost efficiency ($/1K went from $0.058 to $0.202). This validation catches such configuration errors at startup.

Changes

  • bot.py: Add _deduplicate_coins() static method and call it during coin list assembly. Logs WARNING with duplicate names.
  • tests/test_deduplicate_coins.py: 8 tests covering no-dups, single/multi dups, order preservation, empty list, mixed HL/HIP-3, case sensitivity.

Test plan

  • Unit tests added (8 new tests)
  • flake8 passes
  • pytest passes (744 tests, 0 failures)
  • No regressions in existing tests

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@keitaj keitaj left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review: Deduplicate coin list at startup

Simple, well-tested defensive validation. Addresses a real bug (TSLA duplication in US session).


1. Return type annotation (nit)

bot.py L253:

-> tuple could be more specific: -> Tuple[List[str], List[str]]. Minor readability improvement.


Verdict: LGTM

  • No blockers or should-fix items
  • 8 tests with real assertions covering all edge cases
  • Additive-only change, fully backward compatible
  • Static method is clean and testable
  • One nit (return type annotation) — optional

Merging after CI check.

@keitaj
keitaj merged commit afa07ff into main Apr 24, 2026
6 checks passed
@keitaj
keitaj deleted the feat/deduplicate-coins branch April 24, 2026 22:31
@keitaj keitaj changed the title feat: Deduplicate coin list at startup with warning log (#121) feat: Deduplicate coin list at startup with warning log Apr 24, 2026
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