Tradeify247: each person sizes a little apart from everyone else
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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ed56e306d1
commit
6dd2528fe2
@@ -1440,6 +1440,44 @@ export function botStopsActive(cfg: { firstDayStop: boolean; minDayStop: boolean
|
||||
/** The hold a leg is sized for when the firm doesn't set one. */
|
||||
export const DEFAULT_TARGET_HOLD_HOURS = 12;
|
||||
|
||||
/** How far one person's DXtrade sizes move off the plan, each way. */
|
||||
export const PERSON_SIZE_SPREAD = 0.15;
|
||||
|
||||
/**
|
||||
* One person's size factor for a trade date, in [1 − spread, 1 + spread].
|
||||
* Seeded (FNV-1a) by the person, so all of one person's accounts size alike
|
||||
* while another person's land elsewhere, and drawn afresh each trade date.
|
||||
* FNV alone barely moves its top bits when only the key's last character
|
||||
* changes (the next day's date), so the hash is mixed (murmur3's finalizer)
|
||||
* before it is scaled.
|
||||
*/
|
||||
export function personSizeFactor(personKey: string, tradeDate: string): number {
|
||||
const key = `size|${personKey}|${tradeDate}`;
|
||||
let hash = 0x811c9dc5;
|
||||
for (let i = 0; i < key.length; i++) {
|
||||
hash ^= key.charCodeAt(i);
|
||||
hash = Math.imul(hash, 0x01000193) >>> 0;
|
||||
}
|
||||
hash ^= hash >>> 16;
|
||||
hash = Math.imul(hash, 0x85ebca6b);
|
||||
hash ^= hash >>> 13;
|
||||
hash = Math.imul(hash, 0xc2b2ae35);
|
||||
hash = (hash ^ (hash >>> 16)) >>> 0;
|
||||
return 1 - PERSON_SIZE_SPREAD + (hash / 0x100000000) * 2 * PERSON_SIZE_SPREAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hold a person's DXtrade leg is sized for: the firm's target, moved so
|
||||
* the size comes out personSizeFactor times the plan. Size goes as 1/√hold
|
||||
* (sizeNotional), so hold / factor² does it, and every rule that ranks or
|
||||
* checks against the hold sees the same number the size was made for.
|
||||
*/
|
||||
export function personHoldHours(targetHoldHours: number, personKey: string, tradeDate: string): number {
|
||||
const hold = targetHoldHours > 0 ? targetHoldHours : DEFAULT_TARGET_HOLD_HOURS;
|
||||
const factor = personSizeFactor(personKey, tradeDate);
|
||||
return hold / (factor * factor);
|
||||
}
|
||||
|
||||
/** Share of the broker's margin headroom a new position may use: the rest
|
||||
* absorbs the price moving between sizing and the fill, and the entry fee. */
|
||||
export const MARGIN_HEADROOM = 0.97;
|
||||
|
||||
Reference in New Issue
Block a user