93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
/**
|
||
|
||
* Synthetic candle generation and stake-pool outcome resolution.
|
||
|
||
*/
|
||
export type RoundOutcome = {
|
||
type: 'short_win';
|
||
winner: 'short';
|
||
neutralColor: null;
|
||
} | {
|
||
type: 'long_win';
|
||
winner: 'long';
|
||
neutralColor: null;
|
||
} | {
|
||
type: 'neutral';
|
||
winner: null;
|
||
neutralColor: 'red' | 'green';
|
||
};
|
||
export type GeneratedCandle = {
|
||
open: number;
|
||
high: number;
|
||
low: number;
|
||
close: number;
|
||
colorHint: 'red' | 'green';
|
||
};
|
||
export type PrevCandleOhlc = {
|
||
open: number;
|
||
high: number;
|
||
low: number;
|
||
close: number;
|
||
};
|
||
export declare function defaultSeedCandle(price: number): PrevCandleOhlc;
|
||
/**
|
||
|
||
* Resolves round outcome from stake pools.
|
||
|
||
* Winner side is chosen by pool_winner_rule when pools are not neutral; otherwise neutral (push).
|
||
|
||
*/
|
||
export type PoolWinnerRule = 'minority' | 'majority';
|
||
export type PoolNeutralityRules = {
|
||
/** When |short% − long%| <= this value, round is neutral (pools too close). */
|
||
minTolerancePercent: number;
|
||
/** When max(short%, long%) >= this value, round is neutral (pools too one-sided). */
|
||
maxTolerancePercent: number;
|
||
minToleranceEnabled: boolean;
|
||
maxToleranceEnabled: boolean;
|
||
};
|
||
/**
|
||
* Shared neutrality checks used by majority/minority and daily-revenue modes.
|
||
* Returns a neutral outcome when rules apply; otherwise null.
|
||
*/
|
||
export declare function resolvePoolNeutrality(shortPool: number, longPool: number, rules: PoolNeutralityRules): RoundOutcome | null;
|
||
export declare function resolvePoolOutcome(shortPool: number, longPool: number, rules: PoolNeutralityRules, poolWinnerRule?: PoolWinnerRule): RoundOutcome;
|
||
export type DirectionalOutcomeType = 'short_win' | 'long_win';
|
||
/**
|
||
|
||
* Counts how many of the most recent directional outcomes (short/long) share the same type.
|
||
|
||
* Neutral outcomes break the streak and are skipped.
|
||
|
||
*/
|
||
export declare function countConsecutiveDirectionalOutcomes(recentOutcomesNewestFirst: Array<'short_win' | 'long_win' | 'neutral'>): {
|
||
type: DirectionalOutcomeType | null;
|
||
count: number;
|
||
};
|
||
/**
|
||
|
||
* Random short/long outcome for rounds with no player predictions.
|
||
|
||
* After five consecutive candles of the same direction, the next must be the opposite.
|
||
|
||
*/
|
||
export declare function resolveAutoNoBetOutcome(recentOutcomesNewestFirst: Array<'short_win' | 'long_win' | 'neutral'>): Extract<RoundOutcome, {
|
||
type: DirectionalOutcomeType;
|
||
}>;
|
||
/**
|
||
|
||
* Neutral = exact copy of previous OHLC (same body, wicks, and price level).
|
||
|
||
* Only colorHint differs for display.
|
||
|
||
*/
|
||
export declare function replicateNeutralCandle(prev: PrevCandleOhlc, colorHint: 'red' | 'green'): GeneratedCandle;
|
||
/**
|
||
|
||
* Builds OHLC for the synthetic candle following the resolved outcome.
|
||
|
||
* Long candles anchor at the top-right of the previous body; short at the bottom-right.
|
||
|
||
*/
|
||
export declare function generateSyntheticCandle(prev: PrevCandleOhlc, outcome: RoundOutcome): GeneratedCandle;
|
||
//# sourceMappingURL=candleGenerationService.d.ts.map
|