One side per machine: no lane opens against a position another lane holds

Each lane chose its batch's side on its own coin flip. So one person's
machine could be long NQ in the futures lane while its Vest accounts sat
short NDX, hedging that person against themselves across firms.

- Every new entry now takes the side of whatever the machine holds in any
  lane (machineSide in trading-logic). That includes another firm's
  positions and hand trades on any of the machine's accounts.
- With positions on both sides already, nothing is added: the batch reports
  positions-open with the reason, and a manual leg is refused.
- A side chosen with nothing held is reserved while its batch places it, so
  a lane deciding meanwhile follows it.
- It works on the side, not the instrument: NQ against an NDX perp is the
  same bet, and the indices and crypto are close enough that one side for
  everything is the only rule that never hedges.
- Unchanged: one direction per batch within a lane, and the DXtrade and Vest
  clients' own guards against opening opposite another of their accounts.
  The fleet still doesn't coordinate sides across people.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-10-26 15:27:18 -05:00
co-authored by Claude Opus 5.5
parent 769d96883f
commit 335af486d4
3 changed files with 88 additions and 7 deletions
+16 -1
View File
@@ -13,7 +13,7 @@ import {
botStopsActive, sizeNotional, isNoTradeTime, isPastSessionClose, nextTradingDate, effectiveCombine, DEFAULT_TARGET_HOLD_HOURS,
projectPerfectPath, cycleCompletion, DLL_RESERVE_FRACTION, DLL_MIN_STOP, notionalCap, expectedSwapToWin, MARGIN_HEADROOM,
dllReserve, DLL_SLIPPAGE_FRACTION, maxLossRoom, lastStand, breachDistance, LAST_STAND_FRACTION, planLegSize, rankForTarget,
currentTradeDateCT, foldReason, withinFirmCaps, personSizeFactor, personHoldHours, PERSON_SIZE_SPREAD,
currentTradeDateCT, foldReason, withinFirmCaps, personSizeFactor, personHoldHours, PERSON_SIZE_SPREAD, machineSide,
} from '../lib/trading-logic.ts';
// Deterministic PRNG so a failure reproduces.
@@ -952,3 +952,18 @@ test('fund reconcile: a transient that outlasts the confirmation is taken back w
assert.deepEqual(imported.kinds, ['unconfirmed', 'book']);
assert.equal(imported.row, -1);
});
test('machineSide: one side per machine, across every lane', () => {
// Nothing held, nothing being placed: free.
assert.equal(machineSide([], null), null);
// Vest shorts held (hand trades or the bot's): every lane must short.
assert.equal(machineSide([-42.6545, -12.1], null), 'Sell');
// A long NQ in the futures lane: the Vest lane must go long.
assert.equal(machineSide([3], null), 'Buy');
// Another lane's batch is placing longs right now, nothing filled yet.
assert.equal(machineSide([], 'Buy'), 'Buy');
assert.equal(machineSide([2], 'Buy'), 'Buy');
// Both sides already: nothing may be added.
assert.equal(machineSide([1, -1], null), 'mixed');
assert.equal(machineSide([-5], 'Buy'), 'mixed');
});