Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
feat: allow change of hedge bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Verreault committed Nov 17, 2022
1 parent 255bbe4 commit 749ec1e
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions dealer/src/OkexPerpetualSwapStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ export class OkexPerpetualSwapStrategy implements HedgingStrategy {
)
} else if (
exposureInUsd >
totalCollateralInUsd * hedgingBounds.HIGH_BOUND_LEVERAGE
totalCollateralInUsd * hedgingBounds.HIGH_BOUND_LEVERAGE * 0.90
) {
const newCollateralInUsd =
exposureInUsd / hedgingBounds.HIGH_SAFEBOUND_LEVERAGE
Expand All @@ -1210,23 +1210,24 @@ export class OkexPerpetualSwapStrategy implements HedgingStrategy {
result.out.transferSizeInBtc = roundBtc(
result.out.transferSizeInUsd / btcPriceInUsd,
)
} else if (
totalCollateralInUsd <
usedCollateralInUsd * hedgingBounds.LOW_BOUND_LEVERAGE
) {
const transferSizeInUsd =
hedgingBounds.LOW_SAFEBOUND_LEVERAGE * usedCollateralInUsd -
totalCollateralInUsd
const newCollateralInUsd = totalCollateralInUsd + transferSizeInUsd
result.out.transferSizeInUsd = transferSizeInUsd
result.out.fundTransferSide = FundTransferSide.Deposit
result.out.newLiabilityRatio = liabilityInUsd / newCollateralInUsd
result.out.newLeverageRatio = exposureInUsd / newCollateralInUsd
result.out.newMarginRatio = newCollateralInUsd / usedCollateralInUsd
result.out.transferSizeInBtc = roundBtc(
result.out.transferSizeInUsd / btcPriceInUsd,
)
}
}
// else if (
// totalCollateralInUsd <
// usedCollateralInUsd * hedgingBounds.LOW_BOUND_LEVERAGE
// ) {
// const transferSizeInUsd =
// hedgingBounds.LOW_SAFEBOUND_LEVERAGE * usedCollateralInUsd -
// totalCollateralInUsd
// const newCollateralInUsd = totalCollateralInUsd + transferSizeInUsd
// result.out.transferSizeInUsd = transferSizeInUsd
// result.out.fundTransferSide = FundTransferSide.Deposit
// result.out.newLiabilityRatio = liabilityInUsd / newCollateralInUsd
// result.out.newLeverageRatio = exposureInUsd / newCollateralInUsd
// result.out.newMarginRatio = newCollateralInUsd / usedCollateralInUsd
// result.out.transferSizeInBtc = roundBtc(
// result.out.transferSizeInUsd / btcPriceInUsd,
// )
// }

addAttributesToCurrentSpan({
[`${SemanticAttributes.CODE_FUNCTION}.results.success`]: true,
Expand Down

0 comments on commit 749ec1e

Please sign in to comment.