# position-size

> Calculate position size given risk tolerance and distance to stop-loss

Latest version **1.0.23** (published 2020-02-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install position-size
pnpm add position-size
yarn add position-size
bun add position-size
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.23 |
| Published | 2020-02-17 |
| First published | 2020-02-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eric Crosson |
| Maintainers | hamroctopus |
| Keywords | position, size, calculator, risk, tolerance, stop-loss |

## Links

- npm: https://www.npmjs.com/package/position-size
- Repository: https://github.com/strong-roots-capital/position-size
- Issues: https://github.com/strong-roots-capital/position-size/issues
- npm.io page: https://npm.io/package/position-size

## Dependencies (1)

- [purify-ts](https://npm.io/package/purify-ts.md) ^0.14.1

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.23 (latest) — 2020-02-17
- 1.0.22 — 2020-02-17
- 0.0.1 — 2020-02-16

## README

# position-size
[![License][]](https://opensource.org/licenses/ISC)
[![NPM Package][]](https://npmjs.org/package/position-size)
[![Build status][]](https://travis-ci.org/strong-roots-capital/position-size)
[![Code Coverage][]](https://codecov.io/gh/strong-roots-capital/position-size)
[![Dependencies][]](https://david-dm.org/strong-roots-capital/position-size)

[License]: https://img.shields.io/badge/License-ISC-blue.svg
[NPM Package]: https://img.shields.io/npm/v/position-size.svg
[Build status]: https://travis-ci.org/strong-roots-capital/position-size.svg?branch=master
[Code Coverage]: https://codecov.io/gh/strong-roots-capital/position-size/branch/master/graph/badge.svg
[Dependencies]: https://david-dm.org/strong-roots-capital/position-size/status.svg

> Calculate position-size given risk tolerance and distance to stop-loss

## Install

```shell
npm install position-size
```

## Use

▸ **positionSize**(`capital`: number, `riskAsPercentOfCapital`: number, `percentDistanceToStopLoss`: number): *Either‹string, number›*

*Defined in [src/position-size.ts:39](https://github.com/strong-roots-capital/position-size/blob/0bbd628/src/position-size.ts#L39)*

Calculate position-size given risk-tolerance and distance to
stop-loss.

**Parameters:**

Name | Type |
------ | ------ |
`capital` | number |
`riskAsPercentOfCapital` | number |
`percentDistanceToStopLoss` | number |

**Returns:** *Either‹string, number›*

```typescript
import { positionSize } from 'position-size'

positionSize(1000, 1, 2.6)
//=> Right(384.6153846153846

positionSize(1000, 150, 2.6)
//=> Left('Risk cannot exceed 100 percent')
```

## Documentation

See [generated documentation](doc/README.md).

## Related

- [position-size-calculator](https://github.com/strong-roots-capital/position-size-calculator)

---
_Source: https://npm.io/package/position-size · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
