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

totalInvestedValue and totalAssetSize #3

Closed
Waltermelon-lang opened this issue Sep 22, 2022 · 2 comments
Closed

totalInvestedValue and totalAssetSize #3

Waltermelon-lang opened this issue Sep 22, 2022 · 2 comments

Comments

@Waltermelon-lang
Copy link
Collaborator

Can you track the totalInvestedValue and totalAssetSize after each moment of change (trade/liquidation etc.)? -> usually where you currently track PNL.

@Morteza3123
Copy link
Collaborator

Morteza3123 commented Sep 24, 2022

openLongOrder(if the orders match and position is created)

totalInvestedValue[shortOrders[i].owner] += _assetSize * _price;

openShortOrder(if the orders matchand position is created)

totalInvestedValue[longOrders[i].owner] += _assetSize * _price;

closeLongPosition

totalInvestedValue[_user] -= _assetSize * positions[_positionId].longStartPrice;

closeShortPosition

totalInvestedValue[_user] -= _assetSize * positions[_positionId].shortStartPrice;

hardLiquidate(by close pistions total invested value changes)

_closeLongPositionMarket(_user, positionSize, i);

partialLiquidate(by close pistions total invested value changes)

_closeLongPositionMarket(_user, liquidateAmount, i);

@Waltermelon-lang
Copy link
Collaborator Author

this was a difficult one, but I think you did great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants