add calculate_short_bonds_given_deposit
#199
Merged
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.
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: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.*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 with1M
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.