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

Improve caching #102

Merged

Conversation

btschwertfeger
Copy link
Owner

@btschwertfeger btschwertfeger commented May 20, 2023

Summary

  • As described in Create kraken.spot.Market.get_asset_pair to use caching #100 and Create kraken.spot.Market.get_asset to use caching #101 - creating functions that only accept hashable parameters allow to use the @lru_cache decorator of the functools package which improves the execution time significantly.

    That seemed to be the right way - but then I realized creating a decorator that casts the unhashable lists into a string before the caching function is called might be the better way. For this reason no new market functions were added. Just a decorator that ensures that the critical parameters will be a string when the lru_cache decorator is called.

  • The truncate function moved from kraken.spot.Utils to kraken.spot.Trade to benefit from caching.

  • A defined function was added to simplify all x is not None comparisons of the python-kraken-sdk.

@btschwertfeger btschwertfeger added enhancement New feature or request Could Something that could be cool bit is not really important Spot Topic related to Spot trading labels May 20, 2023
@btschwertfeger btschwertfeger added this to the v1.3.0 milestone May 20, 2023
@btschwertfeger btschwertfeger self-assigned this May 20, 2023
@codecov
Copy link

codecov bot commented May 20, 2023

Codecov Report

Attention: Patch coverage is 97.35450% with 5 lines in your changes missing coverage. Please review.

Project coverage is 87.02%. Comparing base (f4862b1) to head (38944e4).
Report is 97 commits behind head on master.

Files with missing lines Patch % Lines
kraken/spot/funding/__init__.py 60.00% 2 Missing ⚠️
kraken/base_api/__init__.py 93.75% 1 Missing ⚠️
kraken/futures/market/__init__.py 91.66% 1 Missing ⚠️
kraken/spot/staking/__init__.py 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #102      +/-   ##
==========================================
+ Coverage   86.71%   87.02%   +0.30%     
==========================================
  Files          18       17       -1     
  Lines        1453     1472      +19     
==========================================
+ Hits         1260     1281      +21     
+ Misses        193      191       -2     
Flag Coverage Δ
unittests 87.02% <97.35%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
kraken/futures/funding/__init__.py 60.86% <ø> (ø)
kraken/futures/trade/__init__.py 96.05% <100.00%> (ø)
kraken/futures/user/__init__.py 86.15% <100.00%> (ø)
kraken/spot/__init__.py 100.00% <ø> (ø)
kraken/spot/market/__init__.py 100.00% <100.00%> (ø)
kraken/spot/trade/__init__.py 94.17% <100.00%> (+2.06%) ⬆️
kraken/spot/user/__init__.py 99.09% <100.00%> (+0.02%) ⬆️
kraken/spot/websocket/__init__.py 80.08% <100.00%> (ø)
kraken/spot/ws_client/__init__.py 69.56% <100.00%> (+2.53%) ⬆️
kraken/base_api/__init__.py 90.62% <93.75%> (+0.46%) ⬆️
... and 3 more

@btschwertfeger btschwertfeger changed the title Improve caching + add kraken.spot.Market.get_asset and kraken.spot.Market.get_asset_pair Improve caching May 20, 2023
@btschwertfeger btschwertfeger marked this pull request as ready for review May 20, 2023 15:08
@btschwertfeger btschwertfeger merged commit 54f79c6 into master May 20, 2023
@btschwertfeger btschwertfeger deleted the 100-create-krakenspotmarketget_asset_pair-to-use-caching branch May 20, 2023 15:11
btschwertfeger added a commit that referenced this pull request Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Could Something that could be cool bit is not really important enhancement New feature or request Spot Topic related to Spot trading
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant