Skip to content

Add trading improvements: history logging, strategies framework, and bug fix#6

Open
alogotron wants to merge 1 commit intoCreator-Bid:mainfrom
alogotron:feature/trading-improvements
Open

Add trading improvements: history logging, strategies framework, and bug fix#6
alogotron wants to merge 1 commit intoCreator-Bid:mainfrom
alogotron:feature/trading-improvements

Conversation

@alogotron
Copy link

Summary

This PR adds trading utilities and fixes a code duplication issue.

Changes

🐛 Bug Fix: DRY Token Definitions

File: clawlett/scripts/balance.js

  • Removed duplicate VERIFIED_TOKENS and ERC20_ABI definitions
  • Now imports from tokens.js (single source of truth)
  • Fixed ETH address mapping (was WETH address, now uses NATIVE_ETH constant)
  • Ensures token list updates only need to happen in one place

✨ Feature: Trade History Logging

File: clawlett/scripts/history.js

New module for tracking trades:

  • logTrade() - Record completed trades with timestamps
  • getHistory() - Query trade history with filters (token, date, limit)
  • getPnL() - Calculate net position changes across all trades
  • clearHistory() - Reset trade log

Useful for:

  • Performance analysis
  • Tax reporting
  • Strategy backtesting

📚 Feature: Trading Strategies Documentation

File: clawlett/STRATEGIES.md

Comprehensive guide covering:

  • Strategy framework pattern
  • Example strategies (DCA, rebalancing, grid trading)
  • Integration with history module
  • Deployment options (nohup, PM2, systemd)
  • Best practices and CoW Protocol tips

Testing

  • balance.js imports work correctly
  • No breaking changes to existing functionality
  • Documentation examples are syntactically correct

Related

Addresses contribution ideas from CONTRIBUTING.md:

  • ✅ Improved error handling (via consistent token resolution)
  • ✅ Documentation improvements

…bug fix

Changes:
- Fix: Import VERIFIED_TOKENS from tokens.js in balance.js (DRY)
- Feature: Add history.js for trade logging and PnL tracking
- Feature: Add STRATEGIES.md with trading strategy framework and examples

The balance.js fix removes duplicate token definitions and imports
from the canonical tokens.js source. This ensures consistency and
makes token list updates easier to maintain.

The history module provides trade logging with filtering and basic
PnL calculation for strategy performance analysis.

STRATEGIES.md documents common trading patterns (DCA, rebalancing,
grid trading) and best practices for running automated strategies.
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