Skip to content

Instantly share code, notes, and snippets.

@steveast
Created December 8, 2025 08:30
Show Gist options
  • Select an option

  • Save steveast/605064ef9356d1e3d47059ad0120eaf4 to your computer and use it in GitHub Desktop.

Select an option

Save steveast/605064ef9356d1e3d47059ad0120eaf4 to your computer and use it in GitHub Desktop.
рассчитывает размер позиции так, чтобы риск составлял ровно 1% от депозита, даже если стоп широкий (например, 5%).
function calcPositionSize(deposit, riskPercent, stopPercent) {
const riskSum = deposit * (riskPercent / 100); // сколько деньгами ты готов потерять
const position = riskSum / (stopPercent / 100); // размер позиции
return position;
}
// Пример:
const deposit = 10000; // депозит
const riskPercent = 1; // рискуешь 1%
const stopPercent = 5; // стоп 5%
const positionSize = calcPositionSize(deposit, riskPercent, stopPercent);
console.log("Размер позиции:", positionSize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment