brighter-trading/tests
rob b555f6e004 Fix high-severity issues identified by Codex
1. Paper equity calculation (High):
   - get_balance() now correctly includes position value (size * current_price)
   - Previously only added unrealized_pnl, missing position principal

2. Buy affordability checks (High):
   - place_order() now uses execution price including slippage for market orders
   - Uses limit price for limit orders instead of current price
   - Prevents orders that would drive cash negative

3. ExchangeInterface price stubs (High):
   - get_trade_executed_price() now handles order_price=0.0 (market orders)
   - Falls back to current price or entry price when order_price is zero

4. Determinism hash strengthening (Medium):
   - Hash now includes full trade sequence with individual trade details
   - Added test for different trade sequences with same totals

5. Live mode consistency (Medium):
   - Factory now falls back to paper trading with warning instead of raising
   - Consistent behavior between factory.py and Strategies.py

Added test: test_paper_broker_equity_calculation to verify fix #1

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-28 17:23:58 -04:00
..
__pycache__ Updated project structure and staged modified files 2024-07-25 08:21:15 -03:00
BrighterTrading.db Updated project structure and staged modified files 2024-07-25 08:21:15 -03:00
Brng.db Updated project structure and staged modified files 2024-07-25 08:21:15 -03:00
__init__.py Classes implemented in python and javascript. UML class diagram. Rough sequence uml. TODO: local file getting dirty from refresh. Signals implemented. Strategies implemented. Trades implemented but still needs some testing. 2023-02-17 22:47:13 -04:00
config.yml Many improvements. 2023-05-14 17:33:13 -03:00
conftest.py Phase 0: Stabilize baseline 2026-02-28 16:44:11 -04:00
test_BrighterTrades.py Updated project structure and staged modified files 2024-07-25 08:21:15 -03:00
test_DataCache.py Indicators are fixed after last update. 2024-09-18 13:47:07 -03:00
test_Exchange.py Extended DataCache with indicator caching functionality. All DataCache tests pass. 2024-09-07 19:51:01 -03:00
test_Users.py Phase 0: Stabilize baseline 2026-02-28 16:44:11 -04:00
test_app.py Fixed query_uptodate function and added comprehensive test cases 2024-08-02 01:36:45 -03:00
test_backtest_determinism.py Fix high-severity issues identified by Codex 2026-02-28 17:23:58 -04:00
test_brokers.py Fix high-severity issues identified by Codex 2026-02-28 17:23:58 -04:00
test_candles.py Extended DataCache with indicator caching functionality. All DataCache tests pass. 2024-09-07 19:51:01 -03:00
test_database.py Extended DataCache with indicator caching functionality. All DataCache tests pass. 2024-09-07 19:51:01 -03:00
test_exchangeinterface.py implemented tests for Exchangeinterface.py 2024-08-04 02:06:23 -03:00
test_indicators.py Phase 0: Stabilize baseline 2026-02-28 16:44:11 -04:00
test_live_exchange_integration.py Completed unittests for Database and DataCache. 2024-08-03 16:56:13 -03:00
test_paper_trading.py Phase 4: Paper trading implementation 2026-02-28 17:07:34 -04:00
test_shared_utilities.py Extended DataCache with indicator caching functionality. All DataCache tests pass. 2024-09-07 19:51:01 -03:00
test_trade.py implemented tests for Exchangeinterface.py 2024-08-04 02:06:23 -03:00
test_trade2.py Updated project structure and staged modified files 2024-07-25 08:21:15 -03:00