delvtech / agent0

Analysis & simulation repo for Delv
https://agent0.readthedocs.io/en/latest/
Apache License 2.0
49 stars 21 forks source link

Allow for lazy pnl calculation #1561

Closed slundqui closed 3 months ago

slundqui commented 3 months ago

This PR allows for only calculating pnl when calling get_positions for speed. To utilize this, set calc_pnl = False in the Chain.Config. If this configuration is set to False, get_positions accepts a calc_pnl argument, which fills the pnl values in the resulting dataframe.

Includes a bugfix to get_positions when getting positions from multiple pools.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 90.47619% with 4 lines in your changes missing coverage. Please review.

Project coverage is 81.41%. Comparing base (84d0837) to head (6efccdc).

:exclamation: Current head 6efccdc differs from pull request most recent head e864186

Please upload reports for the commit e864186 to get more accurate results.

Files Patch % Lines
src/agent0/chainsync/db/hyperdrive/interface.py 87.50% 2 Missing :warning:
...t0/core/hyperdrive/interactive/hyperdrive_agent.py 88.88% 1 Missing :warning:
...e/hyperdrive/interactive/local_hyperdrive_agent.py 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1561 +/- ## ========================================== + Coverage 81.24% 81.41% +0.17% ========================================== Files 98 98 Lines 7053 7071 +18 ========================================== + Hits 5730 5757 +27 + Misses 1323 1314 -9 ``` | [Flag](https://app.codecov.io/gh/delvtech/agent0/pull/1561/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=delvtech) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/delvtech/agent0/pull/1561/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=delvtech) | `81.41% <90.47%> (+0.17%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=delvtech#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.