Skip to content

Commit b7784c5

Browse files
authored
Merge pull request #2611 from DerekMelchin/bug-agents-distracted-by-liquidation-orders
Update orders skill so assistants aren't distracted by liquidation orders
2 parents 7fbeb34 + ea6b883 commit b7784c5

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

skill-templates/orders/SKILL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Market-on-close fills at an exchange's official closing auction. Cryptocurrencie
5555
- Exit AT THE CLOSE: py`liquidate`cs`Liquidate` sends a market order, so for a close fill flatten with an MOC order for the negative of the current position:
5656
py`self.market_on_close_order(symbol, -self.portfolio[symbol].quantity)`cs`MarketOnCloseOrder(symbol, -Portfolio[symbol].Quantity)`.
5757

58+
## Engine-generated delisting liquidations in the order records
59+
When a held security delists, LEAN automatically closes the position with a market order tagged `Liquidate from delisting` — outside the strategy's own schedule. These are platform processing, not strategy orders: expect a few in any long backtest that holds many names. When verifying order records against the strategy's timing invariants ("orders only at rebalances", "flat by close", ...), count these engine liquidations as compliant platform behavior, not violations — and do not add special delisting handling unless the method explicitly requires it.
60+
5861
## Reversing a position
5962
A reversal needs only ONE order, not a py`liquidate`cs`Liquidate` then a separate entry. With py`set_holdings`cs`SetHoldings` this is automatic — py`set_holdings(symbol, new_weight)`cs`SetHoldings(symbol, newWeight)` (e.g. the opposite sign) computes and places the single net order for you, so prefer it and write nothing extra. Manage it by hand ONLY when the spec mandates a manual share count; then place one order for the NET delta:
6063
```python

skills/csharp/orders/SKILL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Market-on-close fills at an exchange's official closing auction. Cryptocurrencie
4141
- Exit AT THE CLOSE: `Liquidate` sends a market order, so for a close fill flatten with an MOC order for the negative of the current position:
4242
`MarketOnCloseOrder(symbol, -Portfolio[symbol].Quantity)`.
4343

44+
## Engine-generated delisting liquidations in the order records
45+
When a held security delists, LEAN automatically closes the position with a market order tagged `Liquidate from delisting` — outside the strategy's own schedule. These are platform processing, not strategy orders: expect a few in any long backtest that holds many names. When verifying order records against the strategy's timing invariants ("orders only at rebalances", "flat by close", ...), count these engine liquidations as compliant platform behavior, not violations — and do not add special delisting handling unless the method explicitly requires it.
46+
4447
## Reversing a position
4548
A reversal needs only ONE order, not a `Liquidate` then a separate entry. With `SetHoldings` this is automatic — `SetHoldings(symbol, newWeight)` (e.g. the opposite sign) computes and places the single net order for you, so prefer it and write nothing extra. Manage it by hand ONLY when the spec mandates a manual share count; then place one order for the NET delta:
4649
```csharp

skills/python/orders/SKILL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Market-on-close fills at an exchange's official closing auction. Cryptocurrencie
4141
- Exit AT THE CLOSE: `liquidate` sends a market order, so for a close fill flatten with an MOC order for the negative of the current position:
4242
`self.market_on_close_order(symbol, -self.portfolio[symbol].quantity)`.
4343

44+
## Engine-generated delisting liquidations in the order records
45+
When a held security delists, LEAN automatically closes the position with a market order tagged `Liquidate from delisting` — outside the strategy's own schedule. These are platform processing, not strategy orders: expect a few in any long backtest that holds many names. When verifying order records against the strategy's timing invariants ("orders only at rebalances", "flat by close", ...), count these engine liquidations as compliant platform behavior, not violations — and do not add special delisting handling unless the method explicitly requires it.
46+
4447
## Reversing a position
4548
A reversal needs only ONE order, not a `liquidate` then a separate entry. With `set_holdings` this is automatic — `set_holdings(symbol, new_weight)` (e.g. the opposite sign) computes and places the single net order for you, so prefer it and write nothing extra. Manage it by hand ONLY when the spec mandates a manual share count; then place one order for the NET delta:
4649
```python

0 commit comments

Comments
 (0)