From 15f67bd89053a2202a3f65d6dd1dc97f4ec3aa9b Mon Sep 17 00:00:00 2001 From: Benjamin Thomas Schwertfeger Date: Mon, 13 Mar 2023 19:51:22 +0100 Subject: [PATCH] example now use os.getenv instead of python-dotenv --- examples/futures_examples.py | 7 +++---- examples/futures_trading_bot_template.py | 6 +++--- examples/futures_ws_examples.py | 7 +++---- examples/spot_examples.py | 9 ++++----- examples/spot_trading_bot_template.py | 6 +++--- examples/spot_ws_examples.py | 7 +++---- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/examples/futures_examples.py b/examples/futures_examples.py index b045e49a..8d6c58bb 100644 --- a/examples/futures_examples.py +++ b/examples/futures_examples.py @@ -6,10 +6,9 @@ """Module that implements some example usage for the Kraken Futures REST clients""" import logging +import os import time -from dotenv import dotenv_values - from kraken.futures.client import Funding, Market, Trade, User logging.basicConfig( @@ -21,8 +20,8 @@ logging.getLogger("requests").setLevel(logging.WARNING) logging.getLogger("urllib3").setLevel(logging.WARNING) -key = dotenv_values(".env")["Futures_SANDBOX_KEY"] -secret = dotenv_values(".env")["Futures_SANDBOX_SECRET"] +key = os.getenv("Futures_SANDBOX_KEY") +secret = os.getenv("Futures_SANDBOX_SECRET") # _ _ ___ _____ _____ # | \ | |/ _ \_ _| ____|_ diff --git a/examples/futures_trading_bot_template.py b/examples/futures_trading_bot_template.py index e851ee7a..09ed2443 100644 --- a/examples/futures_trading_bot_template.py +++ b/examples/futures_trading_bot_template.py @@ -8,12 +8,12 @@ import asyncio import logging import logging.config +import os import sys import traceback import requests import urllib3 -from dotenv import dotenv_values from kraken.exceptions.exceptions import KrakenExceptions from kraken.futures.client import Funding, KrakenFuturesWSClient, Market, Trade, User @@ -185,8 +185,8 @@ def save_exit(self, reason: str = "") -> None: def main() -> None: """Main""" bot_config = { - "key": dotenv_values(".env")["Futures_API_KEY"], - "secret": dotenv_values(".env")["Futures_SECRET_KEY"], + "key": os.getenv("Futures_API_KEY"), + "secret": os.getenv("Futures_SECRET_KEY"), "products": ["PI_XBTUSD", "PF_SOLUSD"], } managed_bot = ManagedBot(config=bot_config) diff --git a/examples/futures_ws_examples.py b/examples/futures_ws_examples.py index 670f5989..4d2f6fde 100644 --- a/examples/futures_ws_examples.py +++ b/examples/futures_ws_examples.py @@ -8,10 +8,9 @@ import asyncio import logging import logging.config +import os import time -from dotenv import dotenv_values - from kraken.futures.client import KrakenFuturesWSClient logging.basicConfig( @@ -27,8 +26,8 @@ async def main() -> None: """Create bot and subscribe to topics/feeds""" - key = dotenv_values(".env")["Futures_API_KEY"] - secret = dotenv_values(".env")["Futures_SECRET_KEY"] + key = os.getenv("Futures_API_KEY") + secret = os.getenv("Futures_SECRET_KEY") # ___Custom_Trading_Bot__________ class Bot(KrakenFuturesWSClient): diff --git a/examples/spot_examples.py b/examples/spot_examples.py index c4b02056..f6124e28 100644 --- a/examples/spot_examples.py +++ b/examples/spot_examples.py @@ -7,10 +7,9 @@ """Module that implements some example usage for the Kraken Futures REST clients""" import logging import logging.config +import os import time -from dotenv import dotenv_values - from kraken.spot.client import Funding, Market, Staking, Trade, User logging.basicConfig( @@ -23,8 +22,8 @@ logging.getLogger("urllib3").setLevel(logging.WARNING) -key = dotenv_values(".env")["API_KEY"] -secret = dotenv_values(".env")["SECRET_KEY"] +key = os.getenv("API_KEY") +secret = os.getenv("SECRET_KEY") # _ _ ___ _____ _____ # | \ | |/ _ \_ _| ____|_ @@ -173,7 +172,7 @@ def funding_examples() -> None: print(funding.cancel_widthdraw(asset="DOT", refid="12345")) print( funding.wallet_transfer( - asset="ETH", amount=0.100, from_="Spot Wallet", to="Futures Wallet" + asset="ETH", amount=0.100, from_="Spot Wallet", to_="Futures Wallet" ) ) diff --git a/examples/spot_trading_bot_template.py b/examples/spot_trading_bot_template.py index 9a9ec6ee..6f5a3e30 100644 --- a/examples/spot_trading_bot_template.py +++ b/examples/spot_trading_bot_template.py @@ -8,12 +8,12 @@ import asyncio import logging import logging.config +import os import sys import traceback import requests import urllib3 -from dotenv import dotenv_values from kraken.exceptions.exceptions import KrakenExceptions from kraken.spot.client import Funding, KrakenSpotWSClient, Market, Staking, Trade, User @@ -207,8 +207,8 @@ def save_exit(self, reason: str = "") -> None: def main() -> None: """Main""" bot_config = { - "key": dotenv_values(".env")["API_KEY"], - "secret": dotenv_values(".env")["SECRET_KEY"], + "key": os.getenv("API_KEY"), + "secret": os.getenv("SECRET_KEY"), "pairs": ["DOT/EUR", "XBT/USD"], } managed_bot = ManagedBot(config=bot_config) diff --git a/examples/spot_ws_examples.py b/examples/spot_ws_examples.py index e44a622d..9ce11564 100644 --- a/examples/spot_ws_examples.py +++ b/examples/spot_ws_examples.py @@ -8,10 +8,9 @@ import asyncio import logging import logging.config +import os import time -from dotenv import dotenv_values - from kraken.spot.client import KrakenSpotWSClient logging.basicConfig( @@ -27,8 +26,8 @@ async def main() -> None: """Create bot and subscribe to topics/feeds""" - key = dotenv_values(".env")["API_KEY"] - secret = dotenv_values(".env")["SECRET_KEY"] + key = os.getenv("API_KEY") + secret = os.getenv("SECRET_KEY") # ___Custom_Trading_Bot______________ class Bot(KrakenSpotWSClient):