-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
calculate_short_bonds_given_deposit
(#199)
# Resolved Issues working towards #185 Also makes more progress towards #21 # Description This provides an alternative function to `calculate_max_short` that includes a tolerance parameter and guarantees* convergence with sufficient number of iterations. I changed the signature & behavior from `calculate_max_short` in these ways: - Most importantly, we now ask for the absolute max short (aka pool's max regardless of budget) as an input argument. This is to make clear to the user that there are two required iterative processes to get this answer: first one is to find the absolute max short, second is to find a max short relative to a budget. - This function should also not be used with an unlimited budget to find the max short. Use `calculate_absolute_max_short` for that. If you provide a budget that is larger than the max possible, then this function will throw an error. - The result is guaranteed to be less than or equal to your budget; it will not overshoot the target base amount even if the result is within tolerance and solvent. *I tested a lot of options, but I don't have any formal guarantees on convergence. The most extreme values I tried was `1e5` tolerance with `1M` steps. These two knobs can be tuned as needed for trading off compute speed against tolerance. # Remaining tasks for future PRs - The new test is pretty janky because of the need to put several checks around calculating the absolute max bond amount. That function needs to be investigated next. - I still need to make the wasm & python bindings. This should be done after I fix up absolute max bond amount. - I created this as a new function because I want to give it a chance to exist on its own and be tested before we deprecate the existing `calculate_max_short` function. Once we have battle tested it, we will want to do a cleanup. - The method for calculating the conservative price is still not guaranteed to be safe.
- Loading branch information
Showing
1 changed file
with
221 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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