# RQAlpha Gap Roadmap

This document tracks the remaining RQAlpha backtest capabilities that are not
yet fully aligned in `fidc-backtest-engine`, and the implementation order we
are following.

## Scope

This roadmap focuses on the China A-share stock backtest path first. Multi-asset
coverage such as futures/options is tracked separately and is not part of the
current alignment pass.

## Remaining Gaps

### Phase 1: Strategy API parity

- [x] `order_to` / target-shares style explicit order primitive
- [x] `order_target_portfolio(_smart)` style public API surface
- [x] richer explicit order styles exposed to platform scripts

### Phase 2: Scheduling and execution surface

- [x] minute-level `time_rule` semantics like `market_open`, `market_close`,
      `physical_time`
- [x] finer `1m` / `tick` strategy execution entrypoints beyond `open_auction`
      and `on_day`
- [x] scheduled actions evaluated against explicit intraday times

### Phase 3: Universe and subscription model

- [x] `update_universe`
- [x] `subscribe`
- [x] `unsubscribe`
- [x] tick-frequency subscription guards exposed at strategy API level

### Phase 4: Algo order parity

- [x] `VWAPOrder` first-class explicit action parity (`order.vwap_value/percent`)
- [x] `TWAPOrder` first-class explicit action parity (`order.twap_value/percent`)
- [x] `order_target_portfolio_smart(..., order_prices=AlgoOrder, valuation_prices=...)`

### Phase 5: Position accounting parity

- [x] `trading_pnl`
- [x] `position_pnl`
- [x] `dividend_receivable`
- [x] richer position lifecycle fields exposed to strategy runtime
- [x] RQAlpha-style stock position aliases (`order_book_id`, `avg_price`,
      `sellable`, `closable`, `equity`, `position_prev_close`)

### Phase 6: Strategy data API parity

- [x] `history_bars` numeric helper for daily, intraday, and tick fields
- [x] `current_snapshot`
- [x] `instrument` / `instruments` / `all_instruments`
- [x] `get_trading_dates` / `get_previous_trading_date` /
      `get_next_trading_date`
- [x] phase-aware minute/tick history cursor semantics matching the active
      bar or tick callback

### Phase 7: Remaining stock data-source API parity

- [x] `is_suspended`
- [x] `is_st_stock`
- [x] `get_price` style date-range tabular API
- [x] `active_instruments`
- [x] `instruments_history`

### Phase 8: Order object API parity

- [x] open-order status and unfilled quantity exposed to strategy runtime
- [x] final order object lookup by order id
- [x] order average fill price and transaction cost aggregation

### Phase 9: Account / portfolio API parity

- [x] stock-account runtime view (`ctx.account()` / `ctx.portfolio_view()`)
- [x] `cash`, `available_cash`, `frozen_cash`, `market_value`, `total_value`
      exposed to strategy runtime and DSL
- [x] `unit_net_value`, `static_unit_net_value`, `daily_pnl`,
      `daily_returns`, `total_returns`, `transaction_cost`, `trading_pnl`,
      and `position_pnl` exposed to strategy runtime and DSL
- [x] explicit deposit / withdraw API
- [x] financing liability / repay API
- [x] management-fee rate and callback parity
- [x] stock account map/accessor surface (`accounts`, `stock_account`,
      `account_by_type("STOCK")`)
- [x] standalone futures account model with contract multiplier, long/short
      margin, daily mark-to-market settlement, and short close cashflow
- [x] standalone futures order execution model with open, close, close-today,
      close-yesterday, margin rejection, order/fill/position/account events
- [ ] wire futures account into the generic backtest engine runtime
- [ ] futures intraday matching integration and expiration settlement

## Execution Order

1. Close the explicit order API gap with target-shares / `order_to` parity.
2. Add public batch target-portfolio semantics.
3. Expand scheduler to intraday time rules.
4. Add dynamic universe APIs.
5. Add algo-order styles.
6. Finish position accounting parity.
7. Continue stock data-source API parity.
8. Continue order object API parity.
9. Continue account / portfolio API parity.

## Current Step

Active implementation target: continue account parity after exposing the stock
account runtime view, core Portfolio fields, deposit/withdraw, financing
liability APIs, management-fee callbacks, stock account accessors, and the
standalone futures account/order execution model; next gap is wiring futures
into the generic engine runtime and adding futures intraday/expiration
semantics.
