Trader: add comprehensive loss detection logging - #273
Open
konard wants to merge 3 commits into
Open
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #200
- Enhanced GetMinimumSellPrice() with loss detection warnings when MinimumProfitSteps < 0 - Added profit/loss logging when placing sell orders to detect loss scenarios - Added early sell loss detection with clear warnings when selling at top bid results in loss - Added price change loss detection when sell order prices are adjusted downward - Added realized profit/loss tracking in UpdateCashBalance() for executed sell trades - All loss scenarios now logged with LogWarning level for easy detection and investigation - Profit scenarios logged with LogInformation level for comparison - Each log message includes source price, target price, actual loss/profit amount, and lot quantity This allows careful investigation of loss reasons as requested in issue #200. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
konard
marked this pull request as ready for review
September 11, 2025 10:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements comprehensive loss detection logging for the trader bot as requested in issue #200. The enhanced logging allows careful investigation of reasons for losses by tracking all scenarios where trades might result in losses.
Changes Made
1. Enhanced Loss Detection in Core Methods
MinimumProfitSteps < 0indicating loss selling is allowed2. Realized Profit/Loss Tracking
ActiveSellOrderSourcePriceto compare execution price vs original buy price3. Comprehensive Logging Strategy
LogWarninglevel for easy detection and filteringLogInformationlevel for comparisonLoss Detection Points
MinimumProfitSteps < 0)Configuration Context
The bot is currently configured to allow losses:
MinimumProfitSteps: -1(allows 1 price step loss)MinimumProfitSteps: -2(allows 2 price step loss)Example Log Output
Testing
Fixes #200
🤖 Generated with Claude Code