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

add get_targeted_long #882

Merged
merged 12 commits into from
Apr 5, 2024
Merged

add get_targeted_long #882

merged 12 commits into from
Apr 5, 2024

Conversation

dpaiton
Copy link
Member

@dpaiton dpaiton commented Mar 22, 2024

addresses #775

The solution first attempts to directly compute targeted reserve levels:
For some target rate, $r_t$, the pool share reserves, $z_t$, must be:

$$ z_t = \frac{1}{\mu} \left( \frac{k}{\frac{c}{\mu} + \left( (r_t t + 1)^{\frac{1}{T}} \right)^{1 - T}} \right)^{\tfrac{1}{1 - T}} $$

and the pool bond reserves, $y_t$, must be:

$$ y_t = \left( \frac{k}{ \frac{c}{\mu} + \left( \left( r_t t + 1 \right)^{\frac{1}{T}} \right)^{1-T}} \right)^{1-T} \left( r_t t + 1 \right)^{\frac{1}{T}} $$

where $c$ is the vault share price, $\mu$ is the initial vault share price, $t$ is the annualized position duration, and $T$ is the time stretch constant. The corresponding deltas are then:

$$ \Delta x = c * (z_t - z_e) $$

$$ \Delta y = y - y_t - c(\Delta x) $$

If that is not successful, then it performs newtons method to minimize

$$ l(x) = r(x) - r_t $$

for some realized fixed rate, $r(x) = (1 - p(x)) / (p(x) t)$ after a long was opened with $x$ base, where $p(x)$ is the spot price after the long was opened.

This was linked to issues Mar 26, 2024
@dpaiton dpaiton force-pushed the dpaiton/targeted-long branch 12 times, most recently from cf82bbe to dec0819 Compare April 2, 2024 00:27
@dpaiton dpaiton marked this pull request as ready for review April 2, 2024 00:27
@dpaiton dpaiton force-pushed the dpaiton/targeted-long branch 2 times, most recently from 8a6aa0e to 740c3ab Compare April 2, 2024 00:34
@dpaiton
Copy link
Member Author

dpaiton commented Apr 2, 2024

A detailed derivation of the solution can be found in section 2 of the attached document.
get_targeted_long.pdf

@dpaiton dpaiton force-pushed the dpaiton/targeted-long branch 2 times, most recently from 4603c43 to 56a26c9 Compare April 5, 2024 20:19
@dpaiton dpaiton enabled auto-merge April 5, 2024 20:38
@dpaiton dpaiton added this pull request to the merge queue Apr 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 5, 2024
@dpaiton dpaiton added this pull request to the merge queue Apr 5, 2024
@dpaiton dpaiton removed this pull request from the merge queue due to a manual request Apr 5, 2024
@dpaiton dpaiton enabled auto-merge April 5, 2024 21:33
@dpaiton dpaiton added this pull request to the merge queue Apr 5, 2024
Merged via the queue into main with commit ed2bc6d Apr 5, 2024
36 checks passed
@dpaiton dpaiton deleted the dpaiton/targeted-long branch April 5, 2024 22:07
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

Successfully merging this pull request may close these issues.

calculate_targeted_long Implement get_targeted_long
2 participants