mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-02 01:27:24 -04:00
Previously, profit calculations compared portfolio value to the previous day's final value. This caused trades to appear as losses since buying stocks decreases cash and increases stock value equally (net zero change). Now profit calculations compare to the start-of-day portfolio value (action_id=0 for current date), which accurately reflects gains/losses from price movements and trading decisions. Changes: - agent_tools/tool_trade.py: Fixed profit calc in _buy_impl() and _sell_impl() - tools/price_tools.py: Fixed profit calc in add_no_trade_record_to_db() Test: test_profit_calculation_accuracy now passes