diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bdd750..c3411c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [1.1.3] - 2024-FEB-13 + +### Added +- Full MyPy annotations with return types for function definitions + ## [1.1.2] - 2024-FEB-9 ### Added diff --git a/README.md b/README.md index 729c4a5..3ef3e23 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Welcome to the official Coinbase Advanced API Python SDK. This python project was created to allow coders to easily plug into the [Coinbase Advanced API](https://docs.cloud.coinbase.com/advanced-trade-api/docs/welcome). This SDK also supports easy connection to the [Coinbase Advanced Trade WebSocket API](https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview). -For thorough documentation of all available functions, refer to the following link: https://coinbase.github.io/coinbase-advanced-py/ +For thorough documentation of all available functions, refer to the following link: https://coinbase.github.io/coinbase-advanced-py ## Installation diff --git a/coinbase/__version__.py b/coinbase/__version__.py index 72f26f5..0b2f79d 100644 --- a/coinbase/__version__.py +++ b/coinbase/__version__.py @@ -1 +1 @@ -__version__ = "1.1.2" +__version__ = "1.1.3" diff --git a/coinbase/jwt_generator.py b/coinbase/jwt_generator.py index 0517d6f..7ede411 100644 --- a/coinbase/jwt_generator.py +++ b/coinbase/jwt_generator.py @@ -7,7 +7,7 @@ from coinbase.constants import BASE_URL, REST_SERVICE, WS_SERVICE -def build_jwt(key_var, secret_var, service, uri=None): +def build_jwt(key_var, secret_var, service, uri=None) -> str: """ :meta private: """ @@ -44,7 +44,7 @@ def build_jwt(key_var, secret_var, service, uri=None): return jwt_token -def build_rest_jwt(uri, key_var, secret_var): +def build_rest_jwt(uri, key_var, secret_var) -> str: """ **Build REST JWT** __________ @@ -64,7 +64,7 @@ def build_rest_jwt(uri, key_var, secret_var): return build_jwt(key_var, secret_var, REST_SERVICE, uri=uri) -def build_ws_jwt(key_var, secret_var): +def build_ws_jwt(key_var, secret_var) -> str: """ **Build WebSocket JWT** __________ @@ -83,7 +83,7 @@ def build_ws_jwt(key_var, secret_var): return build_jwt(key_var, secret_var, WS_SERVICE) -def format_jwt_uri(method, path): +def format_jwt_uri(method, path) -> str: """ **Format JWT URI** __________ diff --git a/coinbase/rest/accounts.py b/coinbase/rest/accounts.py index f2f1845..f6b233b 100644 --- a/coinbase/rest/accounts.py +++ b/coinbase/rest/accounts.py @@ -1,11 +1,11 @@ -from typing import Optional +from typing import Any, Dict, Optional from coinbase.constants import API_PREFIX def get_accounts( self, limit: Optional[int] = None, cursor: Optional[str] = None, **kwargs -): +) -> Dict[str, Any]: """ **List Accounts** _________________ @@ -28,7 +28,7 @@ def get_accounts( return self.get(endpoint, params=params, **kwargs) -def get_account(self, account_uuid: str, **kwargs): +def get_account(self, account_uuid: str, **kwargs) -> Dict[str, Any]: """ **Get Account** diff --git a/coinbase/rest/common.py b/coinbase/rest/common.py index 7976c64..3a4e2a7 100644 --- a/coinbase/rest/common.py +++ b/coinbase/rest/common.py @@ -1,7 +1,9 @@ +from typing import Any, Dict + from coinbase.constants import API_PREFIX -def get_unix_time(self, **kwargs): +def get_unix_time(self, **kwargs) -> Dict[str, Any]: """ **Get UNIX Time** _________________ diff --git a/coinbase/rest/convert.py b/coinbase/rest/convert.py index 581b53f..a3b3ccd 100644 --- a/coinbase/rest/convert.py +++ b/coinbase/rest/convert.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Any, Dict, Optional from coinbase.constants import API_PREFIX @@ -11,7 +11,7 @@ def create_convert_quote( user_incentive_id: Optional[str] = None, code_val: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Create Convert Quote** ________________________ @@ -54,7 +54,7 @@ def create_convert_quote( def get_convert_trade( self, trade_id: str, from_account: str, to_account: str, **kwargs -): +) -> Dict[str, Any]: """ **Get Convert Trade** _____________________ @@ -83,7 +83,7 @@ def get_convert_trade( def commit_convert_trade( self, trade_id: str, from_account: str, to_account: str, **kwargs -): +) -> Dict[str, Any]: """ **Commit Convert Trade** ________________________ diff --git a/coinbase/rest/fees.py b/coinbase/rest/fees.py index b0d3d71..5b65e00 100644 --- a/coinbase/rest/fees.py +++ b/coinbase/rest/fees.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Any, Dict, Optional from coinbase.constants import API_PREFIX @@ -8,7 +8,7 @@ def get_transaction_summary( product_type: Optional[str] = None, contract_expiry_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Get Transactions Summary** _____________________________ diff --git a/coinbase/rest/futures.py b/coinbase/rest/futures.py index 039e29a..904fa16 100644 --- a/coinbase/rest/futures.py +++ b/coinbase/rest/futures.py @@ -1,7 +1,9 @@ +from typing import Any, Dict + from coinbase.constants import API_PREFIX -def get_futures_balance_summary(self, **kwargs): +def get_futures_balance_summary(self, **kwargs) -> Dict[str, Any]: """ **Get Futures Balance Summary** _______________________________ @@ -24,7 +26,7 @@ def get_futures_balance_summary(self, **kwargs): return self.get(endpoint, **kwargs) -def list_futures_positions(self, **kwargs): +def list_futures_positions(self, **kwargs) -> Dict[str, Any]: """ **List Futures Positions** __________________________ @@ -47,7 +49,7 @@ def list_futures_positions(self, **kwargs): return self.get(endpoint, **kwargs) -def get_futures_position(self, product_id: str, **kwargs): +def get_futures_position(self, product_id: str, **kwargs) -> Dict[str, Any]: """ **Get Futures Position** _________________________ @@ -70,7 +72,7 @@ def get_futures_position(self, product_id: str, **kwargs): return self.get(endpoint, **kwargs) -def schedule_futures_sweep(self, usd_amount: str, **kwargs): +def schedule_futures_sweep(self, usd_amount: str, **kwargs) -> Dict[str, Any]: """ **Schedule Futures Sweep** __________________________ @@ -95,7 +97,7 @@ def schedule_futures_sweep(self, usd_amount: str, **kwargs): return self.post(endpoint, data=data, **kwargs) -def list_futures_sweeps(self, **kwargs): +def list_futures_sweeps(self, **kwargs) -> Dict[str, Any]: """ **List Futures Sweeps** _______________________ @@ -118,7 +120,7 @@ def list_futures_sweeps(self, **kwargs): return self.get(endpoint, **kwargs) -def cancel_pending_futures_sweep(self, **kwargs): +def cancel_pending_futures_sweep(self, **kwargs) -> Dict[str, Any]: """ **Cancel Pending Futures Sweep** ________________________________ diff --git a/coinbase/rest/market_data.py b/coinbase/rest/market_data.py index 690822f..eef5b9a 100644 --- a/coinbase/rest/market_data.py +++ b/coinbase/rest/market_data.py @@ -1,11 +1,11 @@ -from typing import Optional +from typing import Any, Dict, Optional from coinbase.constants import API_PREFIX def get_candles( self, product_id: str, start: str, end: str, granularity: str, **kwargs -): +) -> Dict[str, Any]: """ **Get Product Candles** __________ @@ -41,7 +41,7 @@ def get_market_trades( start: Optional[str] = None, end: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Get Market Trades** _____________________ diff --git a/coinbase/rest/orders.py b/coinbase/rest/orders.py index 05d969d..188f85a 100644 --- a/coinbase/rest/orders.py +++ b/coinbase/rest/orders.py @@ -1,4 +1,4 @@ -from typing import List, Optional +from typing import Any, Dict, List, Optional from coinbase.constants import API_PREFIX @@ -14,7 +14,7 @@ def create_order( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Create Order** ________________ @@ -61,7 +61,7 @@ def market_order( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Market Order** ________________ @@ -112,7 +112,7 @@ def market_order_buy( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Create Market Order Buy** ____________________ @@ -154,7 +154,7 @@ def market_order_sell( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Create Market Order Sell** _____________________ @@ -200,7 +200,7 @@ def limit_order_gtc( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Limit Order GTC** ___________________ @@ -253,7 +253,7 @@ def limit_order_gtc_buy( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Limit Order GTC Buy** _______________________ @@ -300,7 +300,7 @@ def limit_order_gtc_sell( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Limit Order GTC Sell** ________________________ @@ -350,7 +350,7 @@ def limit_order_gtd( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Limit Order GTD** ___________________ @@ -405,7 +405,7 @@ def limit_order_gtd_buy( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Limit Order GTD Buy** _______________________ @@ -454,7 +454,7 @@ def limit_order_gtd_sell( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Limit Order GTD Sell** ________________________ @@ -505,7 +505,7 @@ def stop_limit_order_gtc( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Stop-Limit Order GTC** ________________________ @@ -560,7 +560,7 @@ def stop_limit_order_gtc_buy( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Stop-Limit Order GTC Buy** ____________________________ @@ -609,7 +609,7 @@ def stop_limit_order_gtc_sell( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Stop-Limit Order GTC Sell** _____________________________ @@ -661,7 +661,7 @@ def stop_limit_order_gtd( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Stop-Limit Order GTD** ________________________ @@ -718,7 +718,7 @@ def stop_limit_order_gtd_buy( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Stop-Limit Order GTD Buy** ____________________________ @@ -769,7 +769,7 @@ def stop_limit_order_gtd_sell( margin_type: Optional[str] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Stop-Limit Order GTD Sell** _____________________________ @@ -806,7 +806,7 @@ def stop_limit_order_gtd_sell( ) -def get_order(self, order_id: str, **kwargs): +def get_order(self, order_id: str, **kwargs) -> Dict[str, Any]: """ **Get Order** _____________ @@ -845,7 +845,7 @@ def list_orders( asset_filters: Optional[List[str]] = None, retail_portfolio_id: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **List Orders** _______________ @@ -892,7 +892,7 @@ def get_fills( limit: Optional[int] = None, cursor: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **List Fills** ______________ @@ -929,7 +929,7 @@ def edit_order( size: Optional[str] = None, price: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Edit Order** ______________ @@ -963,7 +963,7 @@ def preview_edit_order( size: Optional[str] = None, price: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Edit Order** ______________________ @@ -991,7 +991,7 @@ def preview_edit_order( return self.post(endpoint, data=data, **kwargs) -def cancel_orders(self, order_ids: List[str], **kwargs): +def cancel_orders(self, order_ids: List[str], **kwargs) -> Dict[str, Any]: """ **Cancel Orders** _________________ @@ -1029,7 +1029,7 @@ def preview_order( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Order** _________________ @@ -1081,7 +1081,7 @@ def preview_market_order( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Market Order** ________________________ @@ -1133,7 +1133,7 @@ def preview_market_order_buy( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Market Buy Order** ____________________________ @@ -1177,7 +1177,7 @@ def preview_market_order_sell( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Market Sell Order** _____________________________ @@ -1225,7 +1225,7 @@ def preview_limit_order_gtc( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Limit Order GTC** ___________________________ @@ -1279,7 +1279,7 @@ def preview_limit_order_gtc_buy( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Limit Order GTC Buy** _______________________________ @@ -1327,7 +1327,7 @@ def preview_limit_order_gtc_sell( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Limit Order GTC Sell** ________________________________ @@ -1378,7 +1378,7 @@ def preview_limit_order_gtd( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Limit Order GTD** ___________________________ @@ -1434,7 +1434,7 @@ def preview_limit_order_gtd_buy( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Limit Order GTD Buy** _______________________________ @@ -1484,7 +1484,7 @@ def preview_limit_order_gtd_sell( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Limit Order GTD Sell** ________________________________ @@ -1536,7 +1536,7 @@ def preview_stop_limit_order_gtc( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Stop-Limit Order GTC** ________________________________ @@ -1592,7 +1592,7 @@ def preview_stop_limit_order_gtc_buy( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Stop-Limit Order GTC Buy** ____________________________________ @@ -1642,7 +1642,7 @@ def preview_stop_limit_order_gtc_sell( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Stop-Limit Order GTC Sell** _____________________________________ @@ -1695,7 +1695,7 @@ def preview_stop_limit_order_gtd( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Stop-Limit Order GTD** ________________________________ @@ -1753,7 +1753,7 @@ def preview_stop_limit_order_gtd_buy( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Stop-Limit Order GTD Buy** ____________________________________ @@ -1805,7 +1805,7 @@ def preview_stop_limit_order_gtd_sell( leverage: Optional[str] = None, margin_type: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **Preview Stop-Limit Order GTD Sell** _____________________________________ diff --git a/coinbase/rest/perpetuals.py b/coinbase/rest/perpetuals.py index c0be6f5..e328fea 100644 --- a/coinbase/rest/perpetuals.py +++ b/coinbase/rest/perpetuals.py @@ -1,11 +1,11 @@ -from typing import Optional +from typing import Any, Dict, Optional from coinbase.constants import API_PREFIX def allocate_portfolio( self, portfolio_uuid: str, symbol: str, amount: str, currency: str, **kwargs -): +) -> Dict[str, Any]: """ **Allocate Portfolio** ________________ @@ -36,7 +36,7 @@ def allocate_portfolio( return self.post(endpoint, data=data, **kwargs) -def get_perps_portfolio_summary(self, portfolio_uuid: str, **kwargs): +def get_perps_portfolio_summary(self, portfolio_uuid: str, **kwargs) -> Dict[str, Any]: """ **Get Perpetuals Portfolio Summary** ________________ @@ -59,7 +59,7 @@ def get_perps_portfolio_summary(self, portfolio_uuid: str, **kwargs): return self.get(endpoint, **kwargs) -def list_perps_positions(self, portfolio_uuid: str, **kwargs): +def list_perps_positions(self, portfolio_uuid: str, **kwargs) -> Dict[str, Any]: """ **List Perpetuals Positions** ________________ @@ -82,7 +82,9 @@ def list_perps_positions(self, portfolio_uuid: str, **kwargs): return self.get(endpoint, **kwargs) -def get_perps_position(self, portfolio_uuid: str, symbol: str, **kwargs): +def get_perps_position( + self, portfolio_uuid: str, symbol: str, **kwargs +) -> Dict[str, Any]: """ **Get Perpetuals Position** ________________ diff --git a/coinbase/rest/portfolios.py b/coinbase/rest/portfolios.py index ce3aa44..be13b5d 100644 --- a/coinbase/rest/portfolios.py +++ b/coinbase/rest/portfolios.py @@ -1,9 +1,11 @@ -from typing import Optional +from typing import Any, Dict, Optional from coinbase.constants import API_PREFIX -def get_portfolios(self, portfolio_type: Optional[str] = None, **kwargs): +def get_portfolios( + self, portfolio_type: Optional[str] = None, **kwargs +) -> Dict[str, Any]: """ **List Portfolios** ___________________ @@ -28,7 +30,7 @@ def get_portfolios(self, portfolio_type: Optional[str] = None, **kwargs): return self.get(endpoint, params=params, **kwargs) -def create_portfolio(self, name: str, **kwargs): +def create_portfolio(self, name: str, **kwargs) -> Dict[str, Any]: """ **Create Portfolio** ____________________ @@ -55,7 +57,7 @@ def create_portfolio(self, name: str, **kwargs): return self.post(endpoint, data=data, **kwargs) -def get_portfolio_breakdown(self, portfolio_uuid: str, **kwargs): +def get_portfolio_breakdown(self, portfolio_uuid: str, **kwargs) -> Dict[str, Any]: """ **Get Portfolio Breakdown** ___________________________ @@ -85,7 +87,7 @@ def move_portfolio_funds( source_portfolio_uuid: str, target_portfolio_uuid: str, **kwargs, -): +) -> Dict[str, Any]: """ **Move Portfolio Funds** ________________________ @@ -117,7 +119,7 @@ def move_portfolio_funds( return self.post(endpoint, data=data, **kwargs) -def edit_portfolio(self, portfolio_uuid: str, name: str, **kwargs): +def edit_portfolio(self, portfolio_uuid: str, name: str, **kwargs) -> Dict[str, Any]: """ **Edit Portfolio** __________________ @@ -144,7 +146,7 @@ def edit_portfolio(self, portfolio_uuid: str, name: str, **kwargs): return self.put(endpoint, data=data, **kwargs) -def delete_portfolio(self, portfolio_uuid: str, **kwargs): +def delete_portfolio(self, portfolio_uuid: str, **kwargs) -> Dict[str, Any]: """ **Delete Portfolio** ____________________ diff --git a/coinbase/rest/products.py b/coinbase/rest/products.py index 6a850a6..c633ed5 100644 --- a/coinbase/rest/products.py +++ b/coinbase/rest/products.py @@ -1,4 +1,4 @@ -from typing import List, Optional +from typing import Any, Dict, List, Optional from coinbase.constants import API_PREFIX @@ -12,7 +12,7 @@ def get_products( contract_expiry_type: Optional[str] = None, expiring_contract_status: Optional[str] = None, **kwargs, -): +) -> Dict[str, Any]: """ **List Products** _________________ @@ -44,7 +44,7 @@ def get_products( return self.get(endpoint, params=params, **kwargs) -def get_product(self, product_id: str, **kwargs): +def get_product(self, product_id: str, **kwargs) -> Dict[str, Any]: """ **Get Product** _______________ @@ -67,7 +67,9 @@ def get_product(self, product_id: str, **kwargs): return self.get(endpoint, **kwargs) -def get_product_book(self, product_id: str, limit: Optional[int] = None, **kwargs): +def get_product_book( + self, product_id: str, limit: Optional[int] = None, **kwargs +) -> Dict[str, Any]: """ **Get Product Book** ____________________ @@ -92,7 +94,9 @@ def get_product_book(self, product_id: str, limit: Optional[int] = None, **kwarg return self.get(endpoint, params=params, **kwargs) -def get_best_bid_ask(self, product_ids: Optional[List[str]] = None, **kwargs): +def get_best_bid_ask( + self, product_ids: Optional[List[str]] = None, **kwargs +) -> Dict[str, Any]: """ **Get Best Bid/Ask** ____________________ diff --git a/coinbase/rest/rest_base.py b/coinbase/rest/rest_base.py index 3505b69..41cf8fb 100644 --- a/coinbase/rest/rest_base.py +++ b/coinbase/rest/rest_base.py @@ -1,6 +1,6 @@ import logging import os -from typing import IO, Optional, Union +from typing import IO, Any, Dict, Optional, Union import requests from requests.exceptions import HTTPError @@ -81,7 +81,7 @@ def __init__( if verbose: logger.setLevel(logging.DEBUG) - def get(self, url_path, params: Optional[dict] = None, **kwargs): + def get(self, url_path, params: Optional[dict] = None, **kwargs) -> Dict[str, Any]: """ **Authenticated GET Request** _____________________________ @@ -109,7 +109,7 @@ def post( params: Optional[dict] = None, data: Optional[dict] = None, **kwargs, - ): + ) -> Dict[str, Any]: """ **Authenticated POST Request** ______________________________ @@ -135,7 +135,7 @@ def put( params: Optional[dict] = None, data: Optional[dict] = None, **kwargs, - ): + ) -> Dict[str, Any]: """ **Authenticated PUT Request** _____________________________ @@ -161,7 +161,7 @@ def delete( params: Optional[dict] = None, data: Optional[dict] = None, **kwargs, - ): + ) -> Dict[str, Any]: """ **Authenticated DELETE Request** ________________________________ diff --git a/coinbase/websocket/channels.py b/coinbase/websocket/channels.py index 492573b..dfebccf 100644 --- a/coinbase/websocket/channels.py +++ b/coinbase/websocket/channels.py @@ -12,7 +12,7 @@ ) -def heartbeats(self, product_ids: List[str]): +def heartbeats(self, product_ids: List[str]) -> None: """ **Heartbeats Subscribe** ________________________ @@ -31,7 +31,7 @@ def heartbeats(self, product_ids: List[str]): self.subscribe(product_ids, [HEARTBEATS]) -async def heartbeats_async(self, product_ids: List[str]): +async def heartbeats_async(self, product_ids: List[str]) -> None: """ **Heartbeats Subscribe Async** ______________________________ @@ -50,7 +50,7 @@ async def heartbeats_async(self, product_ids: List[str]): await self.subscribe_async(product_ids, [HEARTBEATS]) -def heartbeats_unsubscribe(self, product_ids: List[str]): +def heartbeats_unsubscribe(self, product_ids: List[str]) -> None: """ **Heartbeats Unsubscribe** __________________________ @@ -69,7 +69,7 @@ def heartbeats_unsubscribe(self, product_ids: List[str]): self.unsubscribe(product_ids, [HEARTBEATS]) -async def heartbeats_unsubscribe_async(self, product_ids: List[str]): +async def heartbeats_unsubscribe_async(self, product_ids: List[str]) -> None: """ **Heartbeats Unsubscribe Async** ________________________________ @@ -88,7 +88,7 @@ async def heartbeats_unsubscribe_async(self, product_ids: List[str]): await self.unsubscribe_async(product_ids, [HEARTBEATS]) -def candles(self, product_ids: List[str]): +def candles(self, product_ids: List[str]) -> None: """ **Candles Subscribe** _____________________ @@ -107,7 +107,7 @@ def candles(self, product_ids: List[str]): self.subscribe(product_ids, [CANDLES]) -async def candles_async(self, product_ids: List[str]): +async def candles_async(self, product_ids: List[str]) -> None: """ **Candles Subscribe Async** ___________________________ @@ -126,7 +126,7 @@ async def candles_async(self, product_ids: List[str]): await self.subscribe_async(product_ids, [CANDLES]) -def candles_unsubscribe(self, product_ids: List[str]): +def candles_unsubscribe(self, product_ids: List[str]) -> None: """ **Candles Unsubscribe** _______________________ @@ -145,7 +145,7 @@ def candles_unsubscribe(self, product_ids: List[str]): self.unsubscribe(product_ids, [CANDLES]) -async def candles_unsubscribe_async(self, product_ids: List[str]): +async def candles_unsubscribe_async(self, product_ids: List[str]) -> None: """ **Candles Unsubscribe Async** _____________________________ @@ -164,7 +164,7 @@ async def candles_unsubscribe_async(self, product_ids: List[str]): await self.unsubscribe_async(product_ids, [CANDLES]) -def market_trades(self, product_ids: List[str]): +def market_trades(self, product_ids: List[str]) -> None: """ **Market Trades Subscribe** ___________________________ @@ -183,7 +183,7 @@ def market_trades(self, product_ids: List[str]): self.subscribe(product_ids, [MARKET_TRADES]) -async def market_trades_async(self, product_ids: List[str]): +async def market_trades_async(self, product_ids: List[str]) -> None: """ **Market Trades Subscribe Async** _________________________________ @@ -202,7 +202,7 @@ async def market_trades_async(self, product_ids: List[str]): await self.subscribe_async(product_ids, [MARKET_TRADES]) -def market_trades_unsubscribe(self, product_ids: List[str]): +def market_trades_unsubscribe(self, product_ids: List[str]) -> None: """ **Market Trades Unsubscribe** _____________________________ @@ -221,7 +221,7 @@ def market_trades_unsubscribe(self, product_ids: List[str]): self.unsubscribe(product_ids, [MARKET_TRADES]) -async def market_trades_unsubscribe_async(self, product_ids: List[str]): +async def market_trades_unsubscribe_async(self, product_ids: List[str]) -> None: """ **Market Trades Unsubscribe Async** ___________________________________ @@ -240,7 +240,7 @@ async def market_trades_unsubscribe_async(self, product_ids: List[str]): await self.unsubscribe_async(product_ids, [MARKET_TRADES]) -def status(self, product_ids: List[str]): +def status(self, product_ids: List[str]) -> None: """ **Status Subscribe** ____________________ @@ -259,7 +259,7 @@ def status(self, product_ids: List[str]): self.subscribe(product_ids, [STATUS]) -async def status_async(self, product_ids: List[str]): +async def status_async(self, product_ids: List[str]) -> None: """ **Status Subscribe Async** __________________________ @@ -278,7 +278,7 @@ async def status_async(self, product_ids: List[str]): await self.subscribe_async(product_ids, [STATUS]) -def status_unsubscribe(self, product_ids: List[str]): +def status_unsubscribe(self, product_ids: List[str]) -> None: """ **Status Unsubscribe** ______________________ @@ -297,7 +297,7 @@ def status_unsubscribe(self, product_ids: List[str]): self.unsubscribe(product_ids, [STATUS]) -async def status_unsubscribe_async(self, product_ids: List[str]): +async def status_unsubscribe_async(self, product_ids: List[str]) -> None: """ **Status Unsubscribe Async** ____________________________ @@ -316,7 +316,7 @@ async def status_unsubscribe_async(self, product_ids: List[str]): await self.unsubscribe_async(product_ids, [STATUS]) -def ticker(self, product_ids: List[str]): +def ticker(self, product_ids: List[str]) -> None: """ **Ticker Subscribe** ____________________ @@ -335,7 +335,7 @@ def ticker(self, product_ids: List[str]): self.subscribe(product_ids, [TICKER]) -async def ticker_async(self, product_ids: List[str]): +async def ticker_async(self, product_ids: List[str]) -> None: """ **Ticker Subscribe Async** __________________________ @@ -354,7 +354,7 @@ async def ticker_async(self, product_ids: List[str]): await self.subscribe_async(product_ids, [TICKER]) -def ticker_unsubscribe(self, product_ids: List[str]): +def ticker_unsubscribe(self, product_ids: List[str]) -> None: """ **Ticker Unsubscribe** ______________________ @@ -373,7 +373,7 @@ def ticker_unsubscribe(self, product_ids: List[str]): self.unsubscribe(product_ids, [TICKER]) -async def ticker_unsubscribe_async(self, product_ids: List[str]): +async def ticker_unsubscribe_async(self, product_ids: List[str]) -> None: """ **Ticker Unsubscribe Async** ____________________________ @@ -392,7 +392,7 @@ async def ticker_unsubscribe_async(self, product_ids: List[str]): await self.unsubscribe_async(product_ids, [TICKER]) -def ticker_batch(self, product_ids: List[str]): +def ticker_batch(self, product_ids: List[str]) -> None: """ **Ticker Batch Subscribe** __________________________ @@ -411,7 +411,7 @@ def ticker_batch(self, product_ids: List[str]): self.subscribe(product_ids, [TICKER_BATCH]) -async def ticker_batch_async(self, product_ids: List[str]): +async def ticker_batch_async(self, product_ids: List[str]) -> None: """ **Ticker Batch Subscribe Async** ________________________________ @@ -430,7 +430,7 @@ async def ticker_batch_async(self, product_ids: List[str]): await self.subscribe_async(product_ids, [TICKER_BATCH]) -def ticker_batch_unsubscribe(self, product_ids: List[str]): +def ticker_batch_unsubscribe(self, product_ids: List[str]) -> None: """ **Ticker Batch Unsubscribe** ____________________________ @@ -449,7 +449,7 @@ def ticker_batch_unsubscribe(self, product_ids: List[str]): self.unsubscribe(product_ids, [TICKER_BATCH]) -async def ticker_batch_unsubscribe_async(self, product_ids: List[str]): +async def ticker_batch_unsubscribe_async(self, product_ids: List[str]) -> None: """ **Ticker Batch Unsubscribe Async** __________________________________ @@ -468,7 +468,7 @@ async def ticker_batch_unsubscribe_async(self, product_ids: List[str]): await self.unsubscribe_async(product_ids, [TICKER_BATCH]) -def level2(self, product_ids: List[str]): +def level2(self, product_ids: List[str]) -> None: """ **Level2 Subscribe** ____________________ @@ -487,7 +487,7 @@ def level2(self, product_ids: List[str]): self.subscribe(product_ids, [LEVEL2]) -async def level2_async(self, product_ids: List[str]): +async def level2_async(self, product_ids: List[str]) -> None: """ **Level2 Subscribe Async** __________________________ @@ -506,7 +506,7 @@ async def level2_async(self, product_ids: List[str]): await self.subscribe_async(product_ids, [LEVEL2]) -def level2_unsubscribe(self, product_ids: List[str]): +def level2_unsubscribe(self, product_ids: List[str]) -> None: """ **Level2 Unsubscribe** ______________________ @@ -525,7 +525,7 @@ def level2_unsubscribe(self, product_ids: List[str]): self.unsubscribe(product_ids, [LEVEL2]) -async def level2_unsubscribe_async(self, product_ids: List[str]): +async def level2_unsubscribe_async(self, product_ids: List[str]) -> None: """ **Level2 Unsubscribe Async** ____________________________ @@ -544,7 +544,7 @@ async def level2_unsubscribe_async(self, product_ids: List[str]): await self.unsubscribe_async(product_ids, [LEVEL2]) -def user(self, product_ids: List[str]): +def user(self, product_ids: List[str]) -> None: """ **User Subscribe** __________________ @@ -563,7 +563,7 @@ def user(self, product_ids: List[str]): self.subscribe(product_ids, [USER]) -async def user_async(self, product_ids: List[str]): +async def user_async(self, product_ids: List[str]) -> None: """ **User Subscribe Async** ________________________ @@ -582,7 +582,7 @@ async def user_async(self, product_ids: List[str]): await self.subscribe_async(product_ids, [USER]) -def user_unsubscribe(self, product_ids: List[str]): +def user_unsubscribe(self, product_ids: List[str]) -> None: """ **User Unsubscribe** ____________________ @@ -601,7 +601,7 @@ def user_unsubscribe(self, product_ids: List[str]): self.unsubscribe(product_ids, [USER]) -async def user_unsubscribe_async(self, product_ids: List[str]): +async def user_unsubscribe_async(self, product_ids: List[str]) -> None: """ **User Unsubscribe Async** __________________________ diff --git a/coinbase/websocket/websocket_base.py b/coinbase/websocket/websocket_base.py index db432c3..8326551 100644 --- a/coinbase/websocket/websocket_base.py +++ b/coinbase/websocket/websocket_base.py @@ -126,7 +126,7 @@ def __init__( self._background_exception = None self._retrying = False - def open(self): + def open(self) -> None: """ **Open Websocket** __________________ @@ -143,7 +143,7 @@ def open(self): self._run_coroutine_threadsafe(self.open_async()) - async def open_async(self): + async def open_async(self) -> None: """ **Open Websocket Async** ________________________ @@ -182,7 +182,7 @@ async def open_async(self): logger.error("Failed to establish WebSocket connection: %s", wse) raise WSClientException("Failed to establish WebSocket connection") from wse - def close(self): + def close(self) -> None: """ **Close Websocket** ___________________ @@ -203,7 +203,7 @@ def close(self): else: raise WSClientException("Event loop is not running.") - async def close_async(self): + async def close_async(self) -> None: """ **Close Websocket Async** _________________________ @@ -228,7 +228,7 @@ async def close_async(self): logger.error("Failed to close WebSocket connection: %s", wse) raise WSClientException("Failed to close WebSocket connection.") from wse - def subscribe(self, product_ids: List[str], channels: List[str]): + def subscribe(self, product_ids: List[str], channels: List[str]) -> None: """ **Subscribe** _____________ @@ -245,7 +245,9 @@ def subscribe(self, product_ids: List[str], channels: List[str]): else: raise WSClientException("Websocket Client is not open.") - async def subscribe_async(self, product_ids: List[str], channels: List[str]): + async def subscribe_async( + self, product_ids: List[str], channels: List[str] + ) -> None: """ **Subscribe Async** ___________________ @@ -290,7 +292,7 @@ async def subscribe_async(self, product_ids: List[str], channels: List[str]): f"Failed to subscribe to {channel} channel for product ids {product_ids}." ) from wse - def unsubscribe(self, product_ids: List[str], channels: List[str]): + def unsubscribe(self, product_ids: List[str], channels: List[str]) -> None: """ **Unsubscribe** _______________ @@ -309,7 +311,9 @@ def unsubscribe(self, product_ids: List[str], channels: List[str]): else: raise WSClientException("Websocket Client is not open.") - async def unsubscribe_async(self, product_ids: List[str], channels: List[str]): + async def unsubscribe_async( + self, product_ids: List[str], channels: List[str] + ) -> None: """ **Unsubscribe Async** _____________________ @@ -354,7 +358,7 @@ async def unsubscribe_async(self, product_ids: List[str], channels: List[str]): f"Failed to unsubscribe to {channel} channel for product ids {product_ids}." ) from wse - def unsubscribe_all(self): + def unsubscribe_all(self) -> None: """ **Unsubscribe All** ________________________ @@ -368,7 +372,7 @@ def unsubscribe_all(self): else: raise WSClientException("Websocket Client is not open.") - async def unsubscribe_all_async(self): + async def unsubscribe_all_async(self) -> None: """ **Unsubscribe All Async** _________________________ @@ -380,7 +384,7 @@ async def unsubscribe_all_async(self): for channel, product_ids in self.subscriptions.items(): await self.unsubscribe_async(list(product_ids), [channel]) - def sleep_with_exception_check(self, sleep: int): + def sleep_with_exception_check(self, sleep: int) -> None: """ **Sleep with Exception Check** ______________________________ @@ -394,7 +398,7 @@ def sleep_with_exception_check(self, sleep: int): time.sleep(sleep) self.raise_background_exception() - async def sleep_with_exception_check_async(self, sleep: int): + async def sleep_with_exception_check_async(self, sleep: int) -> None: """ **Sleep with Exception Check Async** ____________________________________ @@ -408,7 +412,7 @@ async def sleep_with_exception_check_async(self, sleep: int): await asyncio.sleep(sleep) self.raise_background_exception() - def run_forever_with_exception_check(self): + def run_forever_with_exception_check(self) -> None: """ **Run Forever with Exception Check** ____________________________________ @@ -421,7 +425,7 @@ def run_forever_with_exception_check(self): time.sleep(1) self.raise_background_exception() - async def run_forever_with_exception_check_async(self): + async def run_forever_with_exception_check_async(self) -> None: """ **Run Forever with Exception Check Async** __________________________________________ @@ -434,7 +438,7 @@ async def run_forever_with_exception_check_async(self): await asyncio.sleep(1) self.raise_background_exception() - def raise_background_exception(self): + def raise_background_exception(self) -> None: """ **Raise Background Exception** ______________________________