Skip to content

[Interactive Brokers] Incorrectly skips producing position reports for flat positions #3023

@idobz

Description

@idobz

Bug Report

Confirmation

Before opening a bug report, please confirm:

  • [v ] I’ve re-read the relevant sections of the documentation.
  • [v ] I’ve searched existing issues and discussions to avoid duplicates.
  • [v ] I’ve reviewed or skimmed the source code (or examples) to confirm the behavior is not by design.
  • [v ] I’ve tested this issue using a recent development wheel (dev develop or a nightly) and can still reproduce it.

Expected Behavior

When positions have been closed in the client but remain open in the cache (due to DB persistence), the expected behavior is for NT to identify this and remove the phantom positions

Actual Behavior

In practice, this case is not recognized by NT, and the phantom positions remain open in the cache/DB, causing downstream mayhem

Steps to Reproduce the Problem

The set up is a bit complex, and I have only thought it out for NETTING accounts:

  1. the setup is a cache that is persisted to DB, and a pattern of running NT that includes node shutdowns and then restarts (which makes sense when running strategies for days and weeks)
  2. run NT and have your strategy open a position
  3. make sure that the DB is reflecting this open position
  4. 'offline' (w/o NT running) close the position through direct interaction with the client

This is where the expected behavior comes in:

run NT again - NT is expected to recognize that the DB and the client are not aligned, and update the DB by closing the positions

Code Snippets or Logs

Specifications

  • OS platform: Ubuntu
  • Python version: 3.12.7
  • nautilus_trader version: 1.221.0a20251002

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions