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 the truncate parameter to kraken.spot.Trade.create_order #95

Conversation

btschwertfeger
Copy link
Owner

@btschwertfeger btschwertfeger commented May 18, 2023

Summary

As described in #94, in some cases the Kraken API returns invalid volume or invalid price errors, since Python creates strings like "1e-05" from float values like 0.00001 which cannot be interpreted by the Kraken API. To also ensure that users of the python-kraken-sdk don't need to worry about the right rounding, the new truncate function was implemented that can round volume and price. If the new truncate parameter of kraken.spot.Trade.create_order is set to True, the price and volume will be rounded to the lowest - last decimal.

The price2 parameter is not affected since that would break the custom commands described in Kraken Docs addOrder Closes: #94

Also the kraken.spot.Trade.create_order examples were adjusted. Closes #96

@btschwertfeger btschwertfeger added enhancement New feature or request Spot Topic related to Spot trading labels May 18, 2023
@btschwertfeger btschwertfeger added this to the v1.3.0 milestone May 18, 2023
@btschwertfeger btschwertfeger self-assigned this May 18, 2023
@codecov
Copy link

codecov bot commented May 18, 2023

Codecov Report

Merging #95 (2100627) into master (2e81e4f) will increase coverage by 0.29%.
The diff coverage is 95.12%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #95      +/-   ##
==========================================
+ Coverage   86.03%   86.33%   +0.29%     
==========================================
  Files          17       18       +1     
  Lines        1425     1456      +31     
==========================================
+ Hits         1226     1257      +31     
  Misses        199      199              
Flag Coverage Δ
unittests 86.33% <95.12%> (+0.29%) ⬆️

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

Impacted Files Coverage Δ
kraken/base_api/__init__.py 90.16% <ø> (-0.06%) ⬇️
kraken/spot/market/__init__.py 100.00% <ø> (ø)
kraken/spot/websocket/__init__.py 80.08% <66.66%> (-0.09%) ⬇️
kraken/futures/market/__init__.py 91.20% <100.00%> (+0.51%) ⬆️
kraken/spot/__init__.py 100.00% <100.00%> (ø)
kraken/spot/trade/__init__.py 92.10% <100.00%> (+0.10%) ⬆️
kraken/spot/utils/__init__.py 100.00% <100.00%> (ø)

@btschwertfeger
Copy link
Owner Author

Hey @andyDoucette - is there anything missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Spot Topic related to Spot trading
Projects
None yet
1 participant