10 lines
446 B
TypeScript
10 lines
446 B
TypeScript
import { parseFinancialDecimal, type FinancialDecimal } from '@stock-bot/types';
|
|
|
|
/** Whole-share desired exposure only; Rust admits orders, reserves fees and accounts for fills. */
|
|
export function wholeShareTarget(
|
|
budget: FinancialDecimal,
|
|
price: FinancialDecimal
|
|
): FinancialDecimal {
|
|
const units = (value: FinancialDecimal) => BigInt(value.replace('.', ''));
|
|
return parseFinancialDecimal((units(budget) / units(price)).toString());
|
|
}
|