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

Extend unittests #32

Merged
merged 16 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: CI/CD

on:
Expand All @@ -12,7 +9,7 @@ on:
- "**"

concurrency:
group: ${{ github.ref }}
group: CICD-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -79,20 +76,38 @@ jobs:
- name: Install package
run: python setup.py install

- name: Testing Spot endpoints with pytest
- name: Testing Spot REST endpoints
env:
SPOT_API_KEY: ${{ secrets.SPOT_API_KEY }}
SPOT_SECRET_KEY: ${{ secrets.SPOT_SECRET_KEY }}
run: |
pytest tests/test_spot_rest.py

- name: Testing Futures endpoints with pytest
- name: Testing Spot websocket client
env:
SPOT_API_KEY: ${{ secrets.SPOT_API_KEY }}
SPOT_SECRET_KEY: ${{ secrets.SPOT_SECRET_KEY }}
run: |
pytest tests/test_spot_websocket.py

- name: Testing Futures REST endpoints
env:
FUTURES_API_KEY: ${{ secrets.FUTURES_API_KEY }}
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
run: |
pytest tests/test_futures_rest.py

- name: Testing Futures websocket client
env:
FUTURES_API_KEY: ${{ secrets.FUTURES_API_KEY }}
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
run: |
pytest tests/test_futures_websocket.py

codecov:
name: Coverage
needs: [test]
Expand Down Expand Up @@ -132,6 +147,8 @@ jobs:
SPOT_SECRET_KEY: ${{ secrets.SPOT_SECRET_KEY }}
FUTURES_API_KEY: ${{ secrets.FUTURES_API_KEY }}
FUTURES_SECRET_KEY: ${{ secrets.FUTURES_SECRET_KEY }}
FUTURES_SANDBOX_KEY: ${{ secrets.FUTURES_SANDBOX_KEY }}
FUTURES_SANDBOX_SECRET: ${{ secrets.FUTURES_SANDBOX_SECRET }}
run: |
pip install pytest pytest-cov
pytest --cov --cov-report=xml
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: [ "master", "development" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
branches: [ "master", "development" ]
schedule:
- cron: '0 0 * * 0'

concurrency:
group: ${{ github.ref }}
group: CodeQL-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ min-public-methods=2
[EXCEPTIONS]

# Exceptions that will emit a warning when caught.
overgeneral-exceptions=BaseException,
Exception
overgeneral-exceptions=builtins.BaseException,
builtins.Exception


[FORMAT]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ copy of the Program in return for a fee.
The python-kraken-sdk serves as a collection of REST and websocket
clients to interact with the Kraken cryptocurrency exchange to
access the Spot and Futures API.
Copyright (C) 2022 Benjamin Thomas Schwertfeger
Copyright (C) 2023 Benjamin Thomas Schwertfeger

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ python3 -m pip install python-kraken-sdk

### 4. Error handling

If any unexpected behavior occurs, please check <b style="color: yellow">your API permissions</b>, <b style="color: yellow">rate limits</b>, update the python-kraken-sdk, see the [Troubleshooting](#trouble) section, and if the error persits please open an issue.
If any unexpected behaviour occurs, please check <b style="color: yellow">your API permissions</b>, <b style="color: yellow">rate limits</b>, update the python-kraken-sdk, see the [Troubleshooting](#trouble) section, and if the error persits please open an issue.

---

Expand Down
19 changes: 9 additions & 10 deletions examples/futures_examples.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
"""Module that implements some example usage for the Kraken Futures REST clients"""
import sys
import time

try:
from kraken.futures.client import Funding, Market, Trade, User
except ModuleNotFoundError:
print("USING LOCAL MODULE")
sys.path.append("/Users/benjamin/repositories/Finance/kraken/python-kraken-sdk")
from kraken.futures.client import Market, User, Trade, Funding
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfegerr
# Github: https://github.com/btschwertfeger
#

"""Module that implements some example usage for the Kraken Futures REST clients"""
import logging
import time

from dotenv import dotenv_values

from kraken.futures.client import Funding, Market, Trade, User

logging.basicConfig(
format="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
datefmt="%Y/%m/%d %H:%M:%S",
Expand Down
28 changes: 8 additions & 20 deletions examples/futures_trading_bot_template.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfegerr
# Github: https://github.com/btschwertfeger
#

"""Module that provides an example Futures trading bot data structure"""
import asyncio
import logging
Expand All @@ -9,26 +15,8 @@
import urllib3
from dotenv import dotenv_values

try:
from kraken.exceptions.exceptions import KrakenExceptions
from kraken.futures.client import (
Funding,
KrakenFuturesWSClient,
Market,
Trade,
User,
)
except ModuleNotFoundError:
print("USING LOCAL MODULE")
sys.path.append("/Users/benjamin/repositories/Trading/python-kraken-sdk")
from kraken.exceptions.exceptions import KrakenExceptions
from kraken.futures.client import (
Funding,
KrakenFuturesWSClient,
Market,
Trade,
User,
)
from kraken.exceptions.exceptions import KrakenExceptions
from kraken.futures.client import Funding, KrakenFuturesWSClient, Market, Trade, User

logging.basicConfig(
format="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
Expand Down
19 changes: 8 additions & 11 deletions examples/futures_ws_examples.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfegerr
# Github: https://github.com/btschwertfeger
#

"""Module that provides an excample usage for the Kraken Futures websocket client"""
import asyncio
import logging
import logging.config
import sys
import time

from dotenv import dotenv_values

try:
from kraken.exceptions.exceptions import KrakenExceptions
from kraken.futures.client import KrakenFuturesWSClient
except:
print("USING LOCAL MODULE")
sys.path.append("/Users/benjamin/repositories/Trading/python-kraken-sdk")
from kraken.exceptions.exceptions import KrakenExceptions
from kraken.futures.client import KrakenFuturesWSClient
from kraken.futures.client import KrakenFuturesWSClient

logging.basicConfig(
format="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
Expand Down Expand Up @@ -92,14 +90,13 @@ async def on_message(self, event) -> None:


if __name__ == "__main__":

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
asyncio.run(main())
except KeyboardInterrupt:
# the websocket client will send {'event': 'asyncio.CancelledError'} via on_message
# so you can handle the behavior/next actions individually within you bot
# so you can handle the behaviour/next actions individually within you bot
pass
finally:
loop.close()
15 changes: 7 additions & 8 deletions examples/spot_examples.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfegerr
# Github: https://github.com/btschwertfeger
#

"""Module that implements some example usage for the Kraken Futures REST clients"""
import logging
import logging.config
import time

from dotenv import dotenv_values

try:
from kraken.spot.client import Funding, Market, Staking, Trade, User
except ModuleNotFoundError:
print("USING LOCAL MODULE")
import sys

sys.path.append("/Users/benjamin/repositories/Trading/python-kraken-sdk")
from kraken.spot.client import Funding, Market, Staking, Trade, User
from kraken.spot.client import Funding, Market, Staking, Trade, User

logging.basicConfig(
format="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
Expand Down
30 changes: 8 additions & 22 deletions examples/spot_trading_bot_template.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfegerr
# Github: https://github.com/btschwertfeger
#

"""Module that provides an example Futures trading bot data structure"""
import asyncio
import logging
Expand All @@ -9,28 +15,8 @@
import urllib3
from dotenv import dotenv_values

try:
from kraken.exceptions.exceptions import KrakenExceptions
from kraken.spot.client import (
Funding,
KrakenSpotWSClient,
Market,
Staking,
Trade,
User,
)
except ModuleNotFoundError:
print("USING LOCAL MODULE")
sys.path.append("/Users/benjamin/repositories/Trading/python-kraken-sdk")
from kraken.exceptions.exceptions import KrakenExceptions
from kraken.spot.client import (
Funding,
KrakenSpotWSClient,
Market,
Staking,
Trade,
User,
)
from kraken.exceptions.exceptions import KrakenExceptions
from kraken.spot.client import Funding, KrakenSpotWSClient, Market, Staking, Trade, User

logging.basicConfig(
format="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
Expand Down
16 changes: 8 additions & 8 deletions examples/spot_ws_examples.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"""Module that provides an excample usage for the Kraken Spot websocket client"""
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfegerr
# Github: https://github.com/btschwertfeger
#

import asyncio
import logging
import logging.config
import sys
import time

from dotenv import dotenv_values

try:
from kraken.spot.client import KrakenSpotWSClient
except ModuleNotFoundError:
print("USING LOCAL MODULE")
sys.path.append("/Users/benjamin/repositories/Trading/python-kraken-sdk")
from kraken.spot.client import KrakenSpotWSClient
from kraken.spot.client import KrakenSpotWSClient

logging.basicConfig(
format="%(asctime)s %(module)s,line: %(lineno)d %(levelname)8s | %(message)s",
Expand Down Expand Up @@ -100,6 +100,6 @@ async def on_message(self, event) -> None:
except KeyboardInterrupt:
pass
# the websocket client will send {'event': 'asyncio.CancelledError'} via on_message
# so you can handle the behavior/next actions individually within you bot
# so you can handle the behaviour/next actions individually within you bot
finally:
loop.close()
3 changes: 0 additions & 3 deletions kraken/__version__.py

This file was deleted.

Loading