BacktestingBrokerage charges no fee for partially filled orders that are later cancelled

Abierto
#9,991 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp

Línea de trabajo

Start in BacktestingBrokerage.Scan, where the issue says fee models run only for fills with OrderStatus.Filled; trace how partial fills and cancellation events carry order fees. Before changing behavior, resolve whether fees should be charged per partial fill or accumulated until cancellation or closure, including the stated effects on fee models. Done means the filled quantity is charged appropriately while the cancelled remainder pays nothing, with fee model assumptions addressed.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

BacktestingBrokerage.Scan only invokes fee models for fills whose status is OrderStatus.Filled:

// invoke fee models for completely filled order events
foreach (var fill in fills)
{
    if (fill.Status == OrderStatus.Filled)
    {
        ...
        fill.OrderFee = legKVP.Value.FeeModel.GetOrderFee(new OrderFeeParameters(legKVP.Value, legKVP.Key));
    }
}

An order that fills partially and is then cancelled emits a PartiallyFilled fill (no fee is computed) followed by a Canceled event carrying OrderFee.Zero, so the filled portion is never charged any fee. The cancelled remainder correctly pays nothing.

This is framework-level and affects every fee model, not just one.

Question for maintainers

Should the fee for a partial fill be charged at the time of the fill, or accumulated and charged when the order is cancelled/closed?

Charging per partial fill is not a drop-in change: fee models currently assume a single fee per order and use the order's full quantity. Per-trade caps (e.g. the FINRA TAF maximum), per-order minimums and flat fees would all need to be reworked if fees started arriving on PartiallyFilled events.

Steps to reproduce

Run a backtest in which an order partially fills and is then cancelled, and observe that no order fee is recorded for the filled quantity.

Expected

The filled portion should carry its share of the order fees.

Context

Raised while reviewing the Trading 212 fee model (#9983), but it is not specific to that model.

Lenguaje dominante
C#
Estrellas
22.5k
Forks
5.4k
Merge medio
22 h 6 min
PR fusionados (30 d)
81

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de QuantConnect/Lean

Todos los issues de QuantConnect/Lean

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.