incorrect position when partially filled in live trading
Dear Catalyst Maintainers,
Before I tell you about my issue, let me describe my environment:
Environment
- Operating System: Windows
- Python Version: 3.6
- Python Bitness:
- How did you install Catalyst: pip
- Python packages: catalyst 0.5.20
Now that you know a little about me, let me tell you about the issue I am having:
Description of Issue
The position is not updating when an order is partially filled on HitBTC (updates: found same issue on Binance too). It will update when fully filled.
For a test case, the algo sends out a sell order with -100 * xem_eth at best ask price. -10 were filled.
context.portfolio.positions[context.asset].amount remains 0 till all -100 were filled.
Here is my code that does the test
, where context.cmx_risk.position is updated by calling context.portfolio.positions[context.asset].amount.
The context.cmx_exec.send_orders is my order manager who maintains order quantity and keeps the queue position. In this case, when -10 filled, the order manager sent out another order with amount of -10 to achieve the targeted -100 quantity.
In the log, the position remained 0 while order was partially filled. The position didn't change until the order was fully filled.

- What did you expect to happen? When partial fill happens, position updates by the filled amount.
- What happened instead? Position doesn't update until fully filled.
Here is how you can reproduce this issue on your machine:
Reproduction Steps
- pick a slow moving product (I used XEM.ETH) and make algo send out a buy / sell order to make a new BBO on exchange hitbtc;
- manually place an opposite order on exchange with a smaller amount than it was in 1, so the algo order is now partially filled;
- check position, 'context.portfolio.positions[context.asset].amount'
- when the algo's order is fully filled, check position again.
Sincerely, Frank
Hi @FWangTrading ,
Thanks for reporting this, we will investigate.
Lena
@lenak25 @EmbarAlmog Thanks for digging into this. I think this issue happens on all the supported exchanges, not only HitBTC.
@EmbarAlmog Sorry, I unassigned you unintentionally. I changed the title and the system automatically did that.
Are there any workarounds for this? This makes using limit orders practically unusable. Any single partial fill hoses the portfolio objects tracking.
@hanibash I created a PnL calculator locally, which reads trade updates and calculates positions and pnls. I am surprising that no one reported the similar issue