Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: floor slippage #1638

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions protocol/0019-MCAL-margin_calculator.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ and

if `open_volume > 0` then

`slippage_per_unit = Product.value(market_observable) - Product.value(exit_price)`,
`slippage_per_unit = max(0, Product.value(market_observable) - Product.value(exit_price))`,

else `slippage_per_unit = 0`.

Expand Down Expand Up @@ -167,7 +167,7 @@ where meanings of terms in Step 1 apply except for:

`slippage_volume = min( open_volume, 0 )`,

`slippage_per_unit = -1 * (Product.value(market_observable) - Product.value(exit_price) )`
`slippage_per_unit = max(0, Product.value(exit_price)-Product.value(market_observable))`

### **Step 3**

Expand Down Expand Up @@ -244,7 +244,7 @@ riskiest_short = min( open_volume + sell_orders, 0 ) = min( 10 - 8, 0 ) = 0

## exit price considers what selling the open position (10) on the order book would achieve.

slippage_per_unit = Product.value(previous_mark_price) - Product.value(exit_price) = Product.value($144) - Product.value((1*120 + 4*110 + 5*108)/10) = 144 - 110 = 34
slippage_per_unit = max(0, Product.value(previous_mark_price) - Product.value(exit_price)) = max(0, Product.value($144) - Product.value((1*120 + 4*110 + 5*108)/10)) = max(0, 144 - 110) = 34

slippage_volume = max( open_volume, 0 ) = max ( 10, 0 ) = 10

Expand Down