Skip to content

[Core] Paper trading engine — simulated order fill and portfolio tracking #7

@jackby03

Description

@jackby03

Summary

There is no paper trading mode. Users cannot test strategies without real money. This is a critical safety feature for any trading platform.

What needs to be done

PaperTradingEngine in Omnijure.Core

  • Implements IExchangeClient so it is a drop-in replacement
  • Maintains a virtual Portfolio with initial balance (configurable, default $10,000 USDT)
  • On PlaceOrderAsync:
    • Market order: fills immediately at the last known candle close price
    • Limit order: queues the order and fills when price crosses the limit level
  • Tracks open orders, filled orders, P&L per trade, total return %
  • Emits OrderFilledEvent via IEventBus just like the real client would
  • Exposes PaperPortfolio: Balance, Positions, OpenOrders, TradeHistory

Mode switching

  • AppSettings.General gets a TradingMode enum: Live | Paper
  • IExchangeClientFactory returns either BinanceClient or PaperTradingEngine based on the setting

Acceptance criteria

  • PaperTradingEngine implements IExchangeClient
  • Market orders fill at current price on next tick
  • Limit orders queue and fill when price is reached
  • PaperPortfolio tracks balance, positions, PnL correctly
  • Mode can be toggled from settings without restart
  • Unit tests: place → fill → assert portfolio state

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions