-
Notifications
You must be signed in to change notification settings - Fork 6
Close Short Accounting #29
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
963e001 to
f9e1f2c
Compare
jrhea
reviewed
Feb 2, 2023
Contributor
jrhea
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions/comments and I'm cornfused about the share reserve accounting
27ab347 to
2620280
Compare
jrhea
approved these changes
Feb 2, 2023
Contributor
jrhea
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. approved
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds the accounting used to close shorts.
The short pnl is given by$s_{pnl} = c_0 \cdot z_0 - c_1 \cdot z_1 + loss$ , where $c_0$ is the initial share price, $c_1$ is the share price when the short is closed, $z_0$ is the amount of shares the bonds were worth at opening, $z_1$ is the amount of shares the bonds are worth at closing, and $loss = y - c_0 \cdot z_0$ . $y$ is the equal to the amount of bonds that were shorted. Thus, we can restate the short pnl as $s_{pnl} = y - c_1 \cdot z_1$ . We can generalize this to allow the partial closing of shorts by assuming that we have $c_i$ as the share price of the ith transaction, $z_i$ as the shares paid in the ith transaction, and $y_i$ are the amount of shorts closed in the ith transaction with the sum of the all $y_i$ equal to $y$ . Then we have the short pnl given as:
Aside from trading pnl, shorts also receive interest on their shorts. The initial shares value of the bonds being shorted is given by$\frac{y}{c_0}$ . In general, we can calculate interest on shares as $(c_1 - c_0) \cdot z$ , so the interest on the bonds being shorted is given by: $(c_1 - c_0) \cdot \frac{y}{c_0} = (\frac{c_1}{c_0} - 1) \cdot y$ . To generalize this to the case of partial closing, we again assume that we have $y_i$ bonds shorted in the ith partial closing where the sum of the $y_i$ equal to $y$ and that we have $c_i$ as the share price at the time of the ith partial closing. Then, the interest proceeds are given by:
Finally, we have that the total pnl is given by: