position-size
v1.0.23
Published
Calculate position size given risk tolerance and distance to stop-loss
Downloads
10
Maintainers
Readme
position-size
Calculate position-size given risk tolerance and distance to stop-loss
Install
npm install position-size
Use
▸ positionSize(capital
: number, riskAsPercentOfCapital
: number, percentDistanceToStopLoss
: number): Either‹string, number›
Defined in src/position-size.ts:39
Calculate position-size given risk-tolerance and distance to stop-loss.
Parameters:
Name | Type |
------ | ------ |
capital
| number |
riskAsPercentOfCapital
| number |
percentDistanceToStopLoss
| number |
Returns: Either‹string, number›
import { positionSize } from 'position-size'
positionSize(1000, 1, 2.6)
//=> Right(384.6153846153846
positionSize(1000, 150, 2.6)
//=> Left('Risk cannot exceed 100 percent')