From 6cd891d78b081480e3f641131731bd6ed0c3c489 Mon Sep 17 00:00:00 2001 From: Tyler Patterson Date: Mon, 9 Oct 2023 12:07:23 +0200 Subject: [PATCH] initial commit --- poetry.lock | 20 ++++++++++---------- pyproject.toml | 2 +- ts/client/asynchronous.py | 5 +++++ ts/client/base.py | 8 ++++---- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/poetry.lock b/poetry.lock index 1e77594..960af48 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.0 and should not be changed by hand. [[package]] name = "anyio" @@ -356,13 +356,13 @@ socks = ["socksio (==1.*)"] [[package]] name = "identify" -version = "2.5.29" +version = "2.5.30" description = "File identification library for Python" optional = false python-versions = ">=3.8" files = [ - {file = "identify-2.5.29-py2.py3-none-any.whl", hash = "sha256:24437fbf6f4d3fe6efd0eb9d67e24dd9106db99af5ceb27996a5f7895f24bf1b"}, - {file = "identify-2.5.29.tar.gz", hash = "sha256:d43d52b86b15918c137e3a74fff5224f60385cd0e9c38e99d07c257f02f151a5"}, + {file = "identify-2.5.30-py2.py3-none-any.whl", hash = "sha256:afe67f26ae29bab007ec21b03d4114f41316ab9dd15aa8736a167481e108da54"}, + {file = "identify-2.5.30.tar.gz", hash = "sha256:f302a4256a15c849b91cfcdcec052a8ce914634b2f77ae87dad29cd749f2d88d"}, ] [package.extras] @@ -520,13 +520,13 @@ files = [ [[package]] name = "platformdirs" -version = "3.10.0" +version = "3.11.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." optional = false python-versions = ">=3.7" files = [ - {file = "platformdirs-3.10.0-py3-none-any.whl", hash = "sha256:d7c24979f292f916dc9cbf8648319032f551ea8c49a4c9bf2fb556a02070ec1d"}, - {file = "platformdirs-3.10.0.tar.gz", hash = "sha256:b45696dab2d7cc691a3226759c0d3b00c47c8b6e293d96f6436f733303f77f6d"}, + {file = "platformdirs-3.11.0-py3-none-any.whl", hash = "sha256:e9d171d00af68be50e9202731309c4e658fd8bc76f55c11c7dd760d023bda68e"}, + {file = "platformdirs-3.11.0.tar.gz", hash = "sha256:cf8ee52a3afdb965072dcc652433e0c7e3e40cf5ea1477cd4b3b1d2eb75495b3"}, ] [package.extras] @@ -655,13 +655,13 @@ files = [ [[package]] name = "rich" -version = "13.5.3" +version = "13.6.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.7.0" files = [ - {file = "rich-13.5.3-py3-none-any.whl", hash = "sha256:9257b468badc3d347e146a4faa268ff229039d4c2d176ab0cffb4c4fbc73d5d9"}, - {file = "rich-13.5.3.tar.gz", hash = "sha256:87b43e0543149efa1253f485cd845bb7ee54df16c9617b8a893650ab84b4acb6"}, + {file = "rich-13.6.0-py3-none-any.whl", hash = "sha256:2b38e2fe9ca72c9a00170a1a2d20c63c790d0e10ef1fe35eba76e1e7b1d7d245"}, + {file = "rich-13.6.0.tar.gz", hash = "sha256:5c14d22737e6d5084ef4771b62d5d4363165b403455a30a1c8ca39dc7b644bef"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index e88a2c7..83959bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ts-api" -version = "0.2.0" +version = "0.2.3" description = "An unofficial wrapper for the TradeStation API." authors = ["Tyler Patterson "] readme = "README.md" diff --git a/ts/client/asynchronous.py b/ts/client/asynchronous.py index 79caa47..e0f636d 100644 --- a/ts/client/asynchronous.py +++ b/ts/client/asynchronous.py @@ -70,3 +70,8 @@ async def _put_request( response = await client.put(url, headers=headers, params=params, data=data) return response + + async def get_accounts(self, user_id: str) -> httpx.Response: + url, params = self._get_accounts(user_id) + + return await self._get_request(url, params) diff --git a/ts/client/base.py b/ts/client/base.py index 47a5516..9ffb968 100644 --- a/ts/client/base.py +++ b/ts/client/base.py @@ -5,7 +5,7 @@ from abc import ABC, abstractmethod from dataclasses import dataclass, field from datetime import date, datetime, timedelta -from typing import Any, Awaitable, Callable, Coroutine, Mapping, Optional, Union +from typing import Any, Awaitable, Callable, Coroutine, Mapping, Optional, Tuple, Union from httpx import Client, Response @@ -274,7 +274,7 @@ def _token_validation(self, nseconds: int = 5) -> None: # Brokerage # ############# - def get_accounts(self, user_id: str) -> Response | Awaitable[Response]: + def _get_accounts(self, user_id: str) -> Tuple[str, dict]: """Grabs all the accounts associated with the User. Arguments: @@ -285,7 +285,7 @@ def get_accounts(self, user_id: str) -> Response | Awaitable[Response]: ---- (dict): All the user accounts. """ - # validate the token. + # validate the token.[] self._token_validation() # define the endpoint. @@ -294,7 +294,7 @@ def get_accounts(self, user_id: str) -> Response | Awaitable[Response]: # define the arguments params = {"access_token": self._access_token} - return self._get_request(url=url_endpoint, params=params) + return url_endpoint, params def get_wallets(self, account_id: str) -> Response | Awaitable[Response]: """Grabs a A valid crypto Account ID for the authenticated user.