Every machine sized a like account in a like state to the same position as every other person's, so two people's positions could match to the unit. Each person now draws a size factor in [0.85, 1.15] per trade date, seeded by the master's uuid for them; all of one person's accounts share it. The factor moves the hold a DXtrade leg is sized for (hold / factor², since size goes as 1/√hold), so the instrument pick, the dashboard's next leg and the Firms page's reach test all see the hold the size was made for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
1.0 KiB
TypeScript
25 lines
1.0 KiB
TypeScript
/**
|
|
* 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);
|
|
}
|