# discretionary_engine_risk
![Minimum Supported Rust Version](https://img.shields.io/badge/nightly-1.92+-ab6000.svg)
[<img alt="crates.io" src="https://img.shields.io/crates/v/discretionary_engine_risk.svg?color=fc8d62&logo=rust" height="20" style=flat-square>](https://crates.io/crates/discretionary_engine_risk)
[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs&style=flat-square" height="20">](https://docs.rs/discretionary_engine_risk)
![Lines Of Code](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/valeratrades/b48e6f02c61942200e7d1e3eeabf9bcb/raw/discretionary_engine_risk-loc.json)
<br>
[<img alt="ci errors" src="https://img.shields.io/github/actions/workflow/status/valeratrades/discretionary_engine_risk/errors.yml?branch=master&style=for-the-badge&style=flat-square&label=errors&labelColor=420d09" height="20">](https://github.com/valeratrades/discretionary_engine_risk/actions?query=branch%3Amaster) <!--NB: Won't find it if repo is private-->
[<img alt="ci warnings" src="https://img.shields.io/github/actions/workflow/status/valeratrades/discretionary_engine_risk/warnings.yml?branch=master&style=for-the-badge&style=flat-square&label=warnings&labelColor=d16002" height="20">](https://github.com/valeratrades/discretionary_engine_risk/actions?query=branch%3Amaster) <!--NB: Won't find it if repo is private-->


## Usage
```sh
discretionary_engine_risk size binance:btc-usdt --percent-sl 2%
```

can configure using `.nix` because why wouldn't you be able to. Who needs tomls when you can just nix. The final config form. Ex in [../examples/config.nix]. // You can `.toml` it too, if you wanna be lame

## Roadmap
### `size` command
#### Goal
want to be able to quickly get correct size I need to use when opening a trade on a given ticker, based on expected volatility (in future based on pattern and my trading history with it too, but that's later).


#### Args
- coin (exchange doesn't matter, and we ignore liquidity for now, so neither does pair)
- --sl | -s
	% away: convert to exact price, print it (small reduction to possible human error)
	OR
	exact: print back % away (also to reduce possible human error)
	OR
	None: assume 20%


#### Steps
- [x] get total balance (today means bybit and binance, all margins (sapi and fapi))
- [x] get coin's price 

- [ ] risk est, mul the with default % of depo
  Large, requires a <plan>

#### Plan
- [x] 0.1: random criterion based on time it took to go same distance last time. 

- [ ] 1.0:
+ make a formula to quantify indirectional-vol
+ take entries from 3x back from the distance it last took to go the SL length
+ Exponentially weigh them, feed into da formula
+ trial and error the answer. Get any starting point, use the thing to trade, adjust as the intuition of this develops


#### Optimisations
- [ ] make all requests in one bunch, then after one comes through, check if we still need to await the rest.

#### Problems
- could have existing, correlatory with target, positions (ignore for now)

#### Blockers
- way of quantifying indirectional volatility


<br>

<sup>
	This repository follows <a href="https://github.com/valeratrades/.github/tree/master/best_practices">my best practices</a> and <a href="https://github.com/tigerbeetle/tigerbeetle/blob/main/docs/TIGER_STYLE.md">Tiger Style</a> (except "proper capitalization for acronyms": (VsrState, not VSRState) and formatting).
</sup>

#### License

<sup>
	Licensed under <a href="LICENSE">Blue Oak 1.0.0</a>
</sup>

<br>

<sub>
	Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
be licensed as above, without any additional terms or conditions.
</sub>

