/** * The hold this machine sizes DXtrade legs for. Every person's machine would * otherwise size a like account in a like state to the same position as * everyone else's; each person's own draw (personHoldHours) puts their sizes * within ±PERSON_SIZE_SPREAD of the plan instead, the same for all of their * accounts and new each trade date. */ import { getSetting } from './db'; import { currentTradeDateCT, personHoldHours, DEFAULT_TARGET_HOLD_HOURS } from './trading-logic'; /** Who this machine trades for: the master's uuid for the person, else the * instance name it reports under. */ function personKey(): string { return getSetting('instance_id') || getSetting('instance_name') || ''; } /** The hold a DXtrade firm's legs are sized for on this machine today. */ export function sizingHoldHours( firm: { targetHoldHours?: number } | null | undefined, tradeDate: string = currentTradeDateCT(), ): number { return personHoldHours(firm?.targetHoldHours || DEFAULT_TARGET_HOLD_HOURS, personKey(), tradeDate); }