DXtrade: an entry never closes a hand trade, and a flatten never opens one

DXtrade dropped the intent the engine now passes, so on the live
Tradeify247 accounts an entry could still close a hand position as the
"entry" and the leg's flatten then OPEN a position with no exits. The
open/close decision moves out of vest-helpers into platform-client's
orderEffect, which both clients now follow to pick OPEN or CLOSE.

A flatten's flat read is "nothing to flatten" only when the client's own
record agrees. One empty read just after a fill the client saw may be the
gateway lagging, so it stays a plain refusal and keeps the FLATTEN FAILED
alarm. A check now fails if an engine order drops its intent or a client
stops going by orderEffect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-10-27 14:13:07 -05:00
co-authored by Claude Opus 5.5
parent e90f21ed91
commit 378530595e
7 changed files with 147 additions and 94 deletions
+7 -5
View File
@@ -260,9 +260,10 @@ function unrecordLeg(accountId: number, tradeDate: string, legAmount: number): v
* (OrderNotPlacedError). Anything ambiguous, like an ack or fill timeout,
* keeps the leg: the order may well have filled, and a leg counted that never
* happened only costs a leg, while one forgotten that did can trade the
* account twice. Open-only: where the platform checks (Vest), an account that
* already holds the symbol — a hand trade the synced positions don't show
* yet — is refused rather than having that position closed as the "entry".
* account twice. Open-only: where the platform checks (Vest, DXtrade), an
* account that already holds the symbol — a hand trade the synced positions
* don't show yet — is refused rather than having that position closed as the
* "entry".
*/
async function sendEntry(
tag: string,
@@ -1304,8 +1305,9 @@ const round2 = (n: number) => Math.round(n * 100) / 100;
* report the leg as failed. A flatten that fails too is the worst case: a
* position with no stop, so it is shouted about. Close-only: on an account
* that turned out flat it must not open a fresh position with no exits, and
* where the platform checks (Vest) that flat account has nothing riding — the
* leg still fails, but without the alarm.
* where the platform checks (Vest, DXtrade) and its own record agrees, that
* flat account has nothing riding — the leg still fails, but without the
* alarm. A flat read the record contradicts still gets the alarm.
*/
async function flattenAndFail(
tag: string,