Coder Social home page Coder Social logo

btschwertfeger / python-kraken-sdk Goto Github PK

View Code? Open in Web Editor NEW
36.0 4.0 17.0 2.14 MB

Command-line tool and SDK to access the Kraken Cryptocurrency Exchange API (Spot, NFT & Futures, REST and Websocket API)

Home Page: https://python-kraken-sdk.readthedocs.io/en/stable

License: Apache License 2.0

Python 99.44% Makefile 0.46% Shell 0.10%
kraken trading cryptocurrency python-trading trading-api trading-client exchange market-data websocket python

python-kraken-sdk's Introduction

Futures, Spot and NFT - REST and Websocket API Python SDK for the Kraken Cryptocurrency Exchange ๐Ÿ™

GitHub License Generic badge Downloads

Ruff Typing CI/CD codecov

OpenSSF ScoreCard OpenSSF Best Practices

release release DOI Documentation Status Stable

โš ๏ธ This is an unofficial collection of REST and websocket clients for Spot and Futures trading on the Kraken cryptocurrency exchange using Python. Payward Ltd. and Kraken are in no way associated with the authors of this package and documentation.

Please note that this project is independent and not endorsed by Kraken or Payward Ltd. Users should be aware that they are using third-party software, and the authors of this project are not responsible for any issues, losses, or risks associated with its usage.

๐Ÿ“Œ Disclaimer

There is no guarantee that this software will work flawlessly at this or later times. Of course, no responsibility is taken for possible profits or losses. This software probably has some errors in it, so use it at your own risk. Also no one should be motivated or tempted to invest assets in speculative forms of investment. By using this software you release the author(s) from any liability regarding the use of this software.


Features

General:

  • command-line interface
  • access both public and private, REST and websocket endpoints
  • responsive error handling and custom exceptions
  • extensive example scripts (see /examples and /tests)
  • tested using the pytest framework
  • releases are permanently archived at Zenodo

Available Clients:

  • Spot REST Clients (sync and async; including access to NFT trading)
  • Spot Websocket Client (using Websocket API v2)
  • Spot Orderbook Client (using Websocket API v2)
  • Futures REST Clients (sync and async)
  • Futures Websocket Client

Documentation:


โ—๏ธ Attention

ONLY tagged releases are available at PyPI. So the content of the master may not match with the content of the latest release. - Please have a look at the release specific READMEs and changelogs.

It is also recommended to pin the used version to avoid unexpected behavior on new releases.


Table of Contents

๐Ÿ›  Installation and setup

1. Install the package into the desired environment

python3 -m pip install python-kraken-sdk

2. Register at Kraken and generate API keys

3. Start using the provided example scripts

4. Error handling

If any unexpected behavior occurs, please check your API permissions, rate limits, update the python-kraken-sdk, see the Troubleshooting section, and if the error persists please open an issue.

๐Ÿ“ Command-line interface

The python-kraken-sdk provides a command-line interface to access the Kraken API using basic instructions while performing authentication tasks in the background. The Spot, NFT and Futures API are accessible and follow the pattern kraken {spot,futures} [OPTIONS] URL. See examples below.

# get server time
kraken spot https://api.kraken.com/0/public/Time
{'unixtime': 1716707589, 'rfc1123': 'Sun, 26 May 24 07:13:09 +0000'}

# get user's balances
kraken spot --api-key=<api-key> --secret-key=<secret-key> -X POST https://api.kraken.com/0/private/Balance
{'ATOM': '17.28229999', 'BCH': '0.0000077100', 'ZUSD': '1000.0000'}

# get user's trade balances
kraken spot --api-key=<api-key> --secret-key=<secret-key> -X POST https://api.kraken.com/0/private/TradeBalance --data '{"asset": "DOT"}'
{'eb': '2.8987347115', 'tb': '1.1694303513', 'm': '0.0000000000', 'uv': '0', 'n': '0.0000000000', 'c': '0.0000000000', 'v': '0.0000000000', 'e': '1.1694303513', 'mf': '1.1694303513'}

# get 1D candles for a futures instrument
kraken futures https://futures.kraken.com/api/charts/v1/spot/PI_XBTUSD/1d
{'candles': [{'time': 1625616000000, 'open': '34557.84000000000', 'high': '34803.20000000000', 'low': '33816.32000000000', 'close': '33880.22000000000', 'volume': '0' ...

# get user's open futures positions
kraken futures --api-key=<api-key> --secret-key=<secret-key> https://futures.kraken.com/derivatives/api/v3/openpositions
{'result': 'success', 'openPositions': [], 'serverTime': '2024-05-26T07:15:38.91Z'}

... All endpoints of the Kraken Spot and Futurs API can be accessed like that.

๐Ÿ“ Spot Clients

The python-kraken-sdk provides lots of functions to easily access most of the REST and websocket endpoints of the Kraken Cryptocurrency Exchange API. Since these endpoints and their parameters may change, all implemented endpoints are tested on a regular basis.

The Kraken Spot API can be accessed by executing requests to the endpoints directly using the request method provided by any client. This is demonstrated below.

See https://docs.kraken.com/api/docs/guides/global-intro for information about the available endpoints and their usage.

SpotClient

The Spot client provides access to all un-and authenticated endpoints of Kraken's Spot and NFT API.

from kraken.spot import SpotClient

client = SpotClient(key="<your-api-key>", secret="<your-secret-key>")
print(client.request("POST", "/0/private/Balance"))

SpotAsyncClient

The async Spot client allows for asynchronous access to Kraken's Spot and NFT API endpoints. Below are two examples demonstrating its usage.

Using SpotAsyncClient without a context manager; In this example, the client is manually closed after the request is made.

import asyncio
from kraken.spot import SpotAsyncClient

async def main():
    client = SpotAsyncClient(key="<your-api-key>", secret="<your-secret-key>")
    try:
        response = await client.request("POST", "/0/private/Balance")
        print(response)
    finally:
        await client.async_close()

asyncio.run(main())

Using SpotAsyncClient as a context manager; This example demonstrates the use of the context manager, which ensures the client is automatically closed after the request is completed.

import asyncio
from kraken.spot import SpotAsyncClient

async def main():
    async with SpotAsyncClient(key="<your-api-key>", secret="<your-secret-key>") as client:
        response = await client.request("POST", "/0/private/Balance")
        print(response)

asyncio.run(main())

SpotWSClient (Websocket API)

Kraken offers two versions of their websocket API (V1 and V2). Since V2 is offers more possibilities, is way faster and easier to use, only the never version is supported by this SDK.

The official documentation for can be found at:

Note that authenticated Spot websocket clients can also un-/subscribe from/to public feeds.

The example below can be found in an extended way in examples/spot_ws_examples.py.

import asyncio
from kraken.spot import SpotWSClient

class Client(SpotWSClient):
    """Can be used to create a custom trading strategy"""

    async def on_message(self, message):
        """Receives the websocket messages"""
        if message.get("method") == "pong" \
            or message.get("channel") == "heartbeat":
            return

        print(message)
        # Here we can access lots of methods, for example to create an order:
        # if self.is_auth:  # only if the client is authenticated โ€ฆ
        #     await self.send_message(
        #         message={
        #             "method": "add_order",
        #             "params": {
        #                 "limit_price": 1234.56,
        #                 "order_type": "limit",
        #                 "order_userref": 123456789,
        #                 "order_qty": 1.0,
        #                 "side": "buy",
        #                 "symbol": "BTC/USD",
        #                 "validate": True,
        #             },
        #         }
        #     )
        # โ€ฆ it is also possible to call regular REST endpoints
        # but using the websocket messages is more efficient.
        # You can also un-/subscribe here using self.subscribe/self.unsubscribe.

async def main():

    # Public/unauthenticated websocket client
    client = Client()  # only use this one if you don't need private feeds
    await client.start()
    await client.subscribe(
        params={"channel": "ticker", "symbol": ["BTC/USD", "DOT/USD"]}
    )
    await client.subscribe(
        params={"channel": "book", "depth": 25, "symbol": ["BTC/USD"]}
    )
    # wait because unsubscribing is faster than unsubscribing โ€ฆ (just for that example)
    await asyncio.sleep(3)
    # print(client.active_public_subscriptions) # to list active subscriptions
    await client.unsubscribe(
        params={"channel": "ticker", "symbol": ["BTC/USD", "DOT/USD"]}
    )
    # โ€ฆ

    # AS default, the authenticated client starts two websocket connections,
    # one for authenticated and one for public messages. If there is no need
    # for a public connection, it can be disabled using the ``no_public``
    # parameter.
    client_auth = Client(key="api-key", secret="secret-key", no_public=True)
    await client_auth.start()
    await client_auth.subscribe(params={"channel": "balances"})

    while not client.exception_occur and not client_auth.exception_occur:
        await asyncio.sleep(6)


if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        pass
        # The websocket client will send {'event': 'asyncio.CancelledError'}
        # via on_message so you can handle the behavior/next actions
        # individually within your strategy.

Futures Clients

The Kraken Spot API can be accessed by executing requests to the endpoints directly using the request method provided by any client. This is demonstrated below.

See https://docs.kraken.com/api/docs/guides/global-intro for information about the available endpoints and their usage.

FuturesClient

The simple Futures client provides access to all un-and authenticated endpoints.

from kraken.futures import FuturesClient

client = FuturesClient(key="<your-api-key>", secret="<your-secret-key>")
print(client.request("GET", "/derivatives/api/v3/accounts"))

FuturesAsyncClient

The async Futures client allows for asynchronous access to Kraken's Futures endpoints. Below are two examples demonstrating its usage.

Using FuturesAsyncClient without a context manager; In this example, the client is manually closed after the request is made.

import asyncio
from kraken.futures import FuturesAsyncClient

async def main():
    client = FuturesAsyncClient(key="<your-api-key>", secret="<your-secret-key>")
    try:
        response = await client.request("GET", "/derivatives/api/v3/accounts")
        print(response)
    finally:
        await client.async_close()

asyncio.run(main())

Using FuturesAsyncClient as context manager; This example demonstrates the use of the context manager, which ensures the client is automatically closed after the request is completed.

import asyncio
from kraken.futures import FuturesAsyncClient

async def main():
    async with FuturesAsyncClient(key="<your-api-key>", secret="<your-secret-key>") as client:
        response = await client.request("GET", "/derivatives/api/v3/accounts")
        print(response)

asyncio.run(main())

FuturesWSClient (Websocket API)

Not only REST, also the websocket API for Kraken Futures is available. Examples are shown below and demonstrated in examples/futures_ws_examples.py.

Note: Authenticated Futures websocket clients can also un-/subscribe from/to public feeds.

import asyncio
from kraken.futures import FuturesWSClient

class Client(FuturesWSClient):

    async def on_message(self, event):
        print(event)

async def main():
    # Public/unauthenticated websocket connection
    client = Client()
    await client.start()

    products = ["PI_XBTUSD", "PF_ETHUSD"]

    # subscribe to a public websocket feed
    await client.subscribe(feed="ticker", products=products)
    # await client.subscribe(feed="book", products=products)
    # โ€ฆ

    # unsubscribe from a public websocket feed
    # await client.unsubscribe(feed="ticker", products=products)

    # Private/authenticated websocket connection (+public)
    client_auth = Client(key="key-key", secret="secret-key")
    await client_auth.start()

    # print(client_auth.get_available_private_subscription_feeds())

    # subscribe to a private/authenticated websocket feed
    await client_auth.subscribe(feed="fills")
    await client_auth.subscribe(feed="open_positions")
    await client_auth.subscribe(feed="open_orders")
    # โ€ฆ

    # unsubscribe from a private/authenticated websocket feed
    await client_auth.unsubscribe(feed="fills")

    while not client.exception_occur and not client_auth.exception_occur:
        await asyncio.sleep(6)

if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        # do some exception handling โ€ฆ
        pass

๐Ÿ†• Contributions

โ€ฆ are welcome - but:

  • First check if there is an existing issue or PR that addresses your problem/solution. If not - create one first - before creating a PR.
  • Typo fixes, project configuration, CI, documentation or style/formatting PRs will be rejected. Please create an issue for that.
  • PRs must provide a reasonable, easy to understand and maintain solution for an existing problem. You may want to propose a solution when creating the issue to discuss the approach before creating a PR.
  • Please have a look at CONTRIBUTION.md.

๐Ÿšจ Troubleshooting

  • Check if you downloaded and installed the latest version of the python-kraken-sdk.
  • Check the permissions of your API keys and the required permissions on the respective endpoints.
  • If you get some Cloudflare or rate limit errors, please check your Kraken Tier level and maybe apply for a higher rank if required.
  • Use different API keys for different algorithms, because the nonce calculation is based on timestamps and a sent nonce must always be the highest nonce ever sent of that API key. Having multiple algorithms using the same keys will result in invalid nonce errors.

๐Ÿ“ Notes

The versioning scheme follows the pattern v<Major>.<Minor>.<Patch>. Here's what each part signifies:

  • Major: This denotes significant changes that may introduce new features or modify existing ones. It's possible for these changes to be breaking, meaning backward compatibility is not guaranteed. To avoid unexpected behavior, it's advisable to specify at least the major version when pinning dependencies.
  • Minor: This level indicates additions of new features or extensions to existing ones. Typically, these changes do not break existing implementations.
  • Patch: Here, you'll find bug fixes, documentation updates, and changes related to continuous integration (CI). These updates are intended to enhance stability and reliability without altering existing functionality.

Coding standards are not always followed to make arguments and function names as similar as possible to those of the Kraken API documentations.

Considerations

The tool aims to be fast, easy to use and maintain. In the past, lots of clients were implemented, that provided functions for almost all available endpoints of the Kraken API. The effort to maintain this collection grew to a level where it was not possible to check various changelogs to apply new updates on a regular basis. Instead, it was decided to concentrate on the request functions of the SpotClient, SpotAsyncClient, FuturesClient and the FuturesAsyncClient (as well as their websocket client implementations). All those clients named "User", "Trade", "Market", "Funding" and so on will no longer be extended, but maintained to a certain degree.

๐Ÿ”ญ References


python-kraken-sdk's People

Contributors

btschwertfeger avatar dependabot[bot] avatar jcr-jeff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python-kraken-sdk's Issues

user.get_orders_info says it accepts a 'string containing a comma delimited list of txids' but it doesn't.

The title says it all. :)

This does not work:

(Pdb) !info=user.get_orders_info("['OH56BN-YYV5I-A57HQZ']")
*** kraken.exceptions.KrakenException.KrakenInvalidOrderError: Order is invalid.

This does work:

(Pdb) !info=user.get_orders_info("OH56BN-YYV5I-A57HQZ")

It would be great if it accepted the stringified list because then you can make an order and look up it's status later. It's confusing to me why an API would return a list of ids for a single creation of a single object. I would expect to get an 'order_id" or something, not a list of things.

Add a workflow or jobs that run all tests before a merge is done

Upload development releases to test.pypi.org within the CI

Is your feature request related to a problem? Please describe.
It would be nice to upload the development releases, for example to validate that the builds are uplaodable.

Describe the solution you'd like
Integrate an upload job into the ci for all pushes without a tag

`kraken.spot.Trade.create_order`: Ability to use floats as trade amounts or prices

The Kraken create_order API only allows string amounts and volumes, since it strictly enforces how many decimal points can be used in a way that is different per trade pair.

Python-Kraken-SDK's create_order on the other hand, says it allows float arguments, which is really nice as it seems to abstract away this pesky detail. However, if you try to use it with arbitrary float arguments, for example float(1/9), the Kraken API gives an error that there is an invalid number of decimal places provided.

So, we "kinda" support float arguments, but not really because they have to be a specific subset of float arguments that have the precice number of decimal places provided.

I'm not entirely sure what the "best" behavior would be. On one hand, I would like to be able to pass .5000000001 to create_order, and it knows to truncate it to .500000000. On the other hand, it might be considered "wrong" to place any order that isn't precicely what was asked for.

Maybe there can be a 'truncate' flag to create_order that truncates the amounts appropriately? Maybe by default it's not enabled, just so we don't confuse anyone, but a simple truncate=True would truncate the amounts to the correct number of decimal places.

I'm using this code currently as a work-around. It could be adapted pretty easily to create this Truncate feature, but before I offer a pull request, I want to make sure we agree this is an improvement.

truncate.py

from math import floor

def truncate(amount, amount_type, pair):
    '''
    Kraken only allows volume and price amounts to be specified with a specific number of decimal places, and these
    varry depending on the currency pair used.
    
    This function converts an amount of a specific type and pair to a string that uses the correct number of decimal
    places.
    
    Inputs:
        amount          - The floating point amount we want to represent.
        amount_type     - What the amount represents.  Either ('price'|'volume')
        pair            - The currency pair the amount is in reference to.
    
    Outputs:
        amount_str      - A string representation of the amount.
    '''
    
    tradeable_asset_pairs=tradeable_asset_pairs_get()['result']
    
    #Extract the data we need for this from the tradeable_asset_pairs:
    pair_decimals=tradeable_asset_pairs[pair]['pair_decimals']
    lot_decimals=tradeable_asset_pairs[pair]['lot_decimals']
    
    if amount_type=='price':
        decimals=pair_decimals
    elif amount_type=='volume':
        decimals=lot_decimals
    else:
        assert 0, f'Invalid {amount_type=}.'
    
    amount_rounded=floor(amount*10**decimals)/10**decimals
    
    #Convert with the right number of decimal places:
    amount_str='{:.{}f}'.format(amount_rounded, decimals)
    
    return amount_str

tradeable_asset_pairs_get.py ( this is referenced by another issue too)

from .timed_lru_cache import timed_lru_cache
import requests

@timed_lru_cache(seconds=120, maxsize=100)
def tradeable_asset_pairs_get():
    'Gets information about all of the currency conversions we can do.'
    
    response=requests.get('https://api.kraken.com/0/public/AssetPairs')
    assert response.status_code ==200, 'Error getting tradeable asset pairs.'
    
    return response.json()

Create a workflow that builds the documentation

Is your feature request related to a problem? Please describe.
When the documentation is implemented (#58) there should be a workflow that builds the documentation and uploads it to Github pages (only on the master branch, when a new release is made?).

Missing package (dotenv) in requirements.txt

Will keep this brief, rather than use the typical bug report format because it's simple.

Required package dotenv for the spot_ws_examples.py is missing from requirements.txt. There may be packages missing, as I haven't taken a good look through the repository.

I also think that this is a somewhat unnecessary and non-standard method of retrieving variables from environment variables, and can probably be done away with to reduce unecessarry dependencies by just using

api_key = os.getenv('api_key')
or
api_key = os.environ.get('api_key')

or some other more common alternative, but obviously it's your call :)

Optionally disable the custom KrakenErrors

Is your feature request related to a problem? Please describe.
It would be nice to disable the custom KrakenErrors in some cases, since it would enable to handle the failures and responses without catching the custom KrakenErrors.

Describe the solution you'd like
Just add a flag like ignore_error when instantiating the Spot and Futures clients, so the functions that check for errors are not called. This can be done by adding the flag here: kraken/base_api/init.py#L268-L269 and kraken/base_api/init.py#L504-L509.

Cannot access private historical events of the Futures Market client

Describe the bug (python-kraken-sdk==v1.0.1)
When using any endpoint listed in the futures Market client like get_execution_events and get_order_events I cannot use the parameters since within the _get_historical_events method of the futures Market client there is a GET request, but passing post_params. This should be changed to query_params.

Create `kraken.spot.Market.get_asset` to use caching

Is your feature request related to a problem? Please describe.
There is already an existing kraken.spot.Market.get_assets endpoint which can be used to retrieve all or filtered assets. Since its inputs allow lists, and thus are not hashable, the functools caching cannot be applied. To workaround this, a new function as named in the issue title could be added to archive caching for individual asset pairs.

Release workflow skips the PyPI publish

Describe the bug
The release workflow skips the PyPI upload since the following line must run on master and not on a release triggered workflow:

if: success() && github.ref == 'refs/heads/master'

To fix this - simply remove the line, because releases of the python-kraken-sdk are always on the master branch and there is no need to check the github.ref.

(inconsistent spelling/typo) recend --> recent in kraken.spot

I'm going to skip over a more detailed explanation here, as I opened a PR correcting the problem already (if you are accepting outside PRs)- but essentially, there is a misspelling of recent as recend in many (but not all) of the methods in kraken.spot, which also makes it inconsistent with the naming in the actual Kraken REST API.

Please see the PR for more details.

Thanks

`kraken.spot.User(...).get_balances('ZUSD')` silently does the wrong thing.

I have 10.9226 of ZUSD in my Kraken account (for testing). I have one open order to buy 5 BTC in exchange for 5 ZUSD, tying up $5. So my user.available_balances('ZUSD')['available_balance'] should be 5.9226. Instead, what I get is 10.9226.

Notice the difference:

(Pdb) p user.get_balances('ZUSD')
{'currency': 'ZUSD', 'balance': 10.9226, 'available_balance': 10.9226}
(Pdb) p user.get_balances('USD')
{'currency': 'USD', 'balance': 10.9226, 'available_balance': 5.9226}

If I try the same thing with "USD" it works fine, but Kraken recently added Z's in front of their fiat currency names, and uses those versions of the names as the "base" and "quote" currencies on each of the pairs. Any program that gets the currency name from Kraken will likely end up using the Z version, so I hope we can play nicely with that version of the name too.

`kraken.spot.Trade.cancel_order_batch` endpoint in Spot trading does not work. `{'error': ['EAPI:Bad request']}`

Describe the bug
When trying to cancel multiple orders using the cancel_order_batch endpoint there is always an Bad Request error (still in python-kraken-sdk==v1.1.0).

How to reproduce:

from kraken.spot import Trade
trade = Trade(key="api-key", secret="secret-key")
print(trade.cancel_order_batch(orders=["OG5IL4-6AR7I-ZAPZEZ", "OAUHYR-YCVK6-P22G6P"]))

There is always the following response:

{'error': ['EAPI:Bad request']}

EDIT:
This seems to be an error with the Kraken API since their example also returns the same error message https://docs.kraken.com/rest/#tag/User-Trading/operation/cancelOrderBatch.

/public/AssetPairs would be nice.

Many apps will need at some point to find out how to refer to specific currencies in a kraken-API-friendly (with all the Z's, X's, etc).

I've found the /public/AssetPairs endpoint to be helpful for that, as it maps the asset names to the pair names without having to rely on a concatenation mapping that is ill-defined in reverse. (Is "ABCDEFG" "ABC/DEFG" or "ABCD"/"EFG" or "A"/"BCDEFG"?)

I'm using this currently:

from functools import lru_cache
import requests

@lru_cache(maxsize=100)
def tradeable_asset_pairs_get():
    'Gets information about all of the currency conversions we can do.'
    
    response=requests.get('https://api.kraken.com/0/public/AssetPairs')
    assert response.status_code ==200, 'Error getting tradeable asset pairs.'
    
    return response.json()

I imagine other people might want this endpoint too. Can it be added to the SDK please?

Remove the unnecessary `client` module when importing the clients

Is your feature request related to a problem? Please describe.
Importing the User class from kraken.spot.client is unhandy - it would be easy to move the content from kraken.spot.client ti the kraken.spot.__init__.py to enable imports like from kraken.spot import User.

`kraken.spot.Trade.create_order`: documentatoin for txid outdated.

The documentation states that the result when you create an order has txid as a string:

trade.create_order(
    ordertype="market",
    side="buy",
    pair="XBTUSD",
    volume="0.0001"
)
{
    'txid': 'TNGMNU-XQSRA-LKCWOK',
    'descr': {
        'order': 'buy 4.00000000 XBTUSD @ limit 23000.0'
    }
}

Unfortunately, I'm getting a list, not a string.

The latest Kraken API documentatoin for /private/AddOrder states that txid is:

Transaction IDs for order
(if order was added successfully)

So, I think the documentation for create_order should probably be updated to reflect the fact that txid is now a list.

Thanks! :)

Extend the docstrings with parameter description and examples

Is your feature request related to a problem? Please describe.
Just having a link/url to the official Kraken documentation is not enough, there should be more "hardcoded" parameter descriptions and examples to not always switch to the Kraken docs to view some configurations.

Describe the solution you'd like
Include more content to the docstrings of all methods, maybe even document the workflows to make it easier to understand the whole project. Also examples like provided in the examples directory within the docstrings would be nice.

see: https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html

Move `kraken.exceptions.exceptions.KrakenExceptions` to `kraken.exceptions.KrakenException`

Is your feature request related to a problem? Please describe.
As it has been before with the clients, the class KrakenExceptions can be moved into a __init__.py, which makes it easier to import.

Before (bad):

from kraken.exceptions.exceptions import KrakenExceptions

After (good):

from kraken.exceptions import KrakenException

Additional context
Even though the KrakenExceptions class are a collection of Kraken-specific errors, it would be good to stick to the singular standard.

Avoid raising ValueError in `get_balance` if currency is not found in the portfolio

Is your feature request related to a problem? Please describe.
When using kraken.spot.client.User.get_balances it raises a ValueError if the currency is not found in the portfolio or if the value is 0. This occurs in the current version v1.0.1. This is bad, because I have to catch the exception and set the values to zero by hand. There is no reason for raising the ValueError.

Describe the solution you'd like
The behaviour should be like not raising this error, instead returning zero balances.

Additional context
Remove this lines: kraken/spot/user/user.py#L27-L28

Extend the typing - using mypy

Is your feature request related to a problem? Please describe.
As the title says - the typing should be extended - mypy can be used for this.

Create `CONTRIBUTING.md`

Since this project is intended to be open and welcomes contributors, there must be a contributing guideline that includes at least the following bullet points:

  • How and when to contribute
  • What is needed for an accepted PR?
    • All code changes must be tested
    • All workflows must be run through - successfully (on your local fork).
    • Add/adjust examples and doc strings
    • Use the provided pre-commit config!
      ....

Pull request workflows fail in test stage

Describe the bug
CI/CD workflows when triggered by pushing to a pull request will always fail in the Test stage since the push and pull request pipeline are in conflict to the API Rate limits. They should not be executed in parallel.

Create `kraken.spot.Market.get_asset_pair` to use caching

Is your feature request related to a problem? Please describe.
There is already an existing kraken.spot.Market.get_asset_pairs endpoint which can be used to retrieve all or filtered currency pairs. Since its inputs allow lists, and thus are not hashable, the functools caching cannot be applied. To workaround this, a new function as named in the issue title could be added to archive caching for individual asset pairs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.