Skip to content

Commit

Permalink
remove 3.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Graeme22 committed Dec 2, 2024
1 parent db59e4e commit 202655e
Show file tree
Hide file tree
Showing 17 changed files with 175 additions and 188 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- uses: yezz123/setup-uv@v4
- name: Setup uv venv
run: |
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.8
3.9
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

install:
uv sync
uv pip install -e .

lint:
uv run ruff format tastytrade/ tests/
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
project = "tastytrade"
copyright = "2024, Graeme Holliday"
author = "Graeme Holliday"
release = "9.1"
release = "9.2"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand All @@ -23,7 +23,7 @@
"sphinx.ext.doctest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
# "sphinx.ext.intersphinx",
"sphinx_toolbox.more_autodoc.autotypeddict",
"enum_tools.autoenum",
"sphinxcontrib.autodoc_pydantic",
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "tastytrade"
version = "9.1"
version = "9.2"
description = "An unofficial, sync/async SDK for Tastytrade!"
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -29,7 +29,6 @@ dev-dependencies = [
"pytest-aio>=1.5.0",
"pytest-cov>=5.0.0",
"ruff>=0.6.9",
"types-pytz>=2024.2.0.20241003",
"pyright>=1.1.384",
]

Expand Down
2 changes: 1 addition & 1 deletion tastytrade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
BACKTEST_URL = "https://backtester.vast.tastyworks.com"
CERT_URL = "https://api.cert.tastyworks.com"
VAST_URL = "https://vast.tastyworks.com"
VERSION = "9.1"
VERSION = "9.2"

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand Down
68 changes: 34 additions & 34 deletions tastytrade/account.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import date, datetime
from decimal import Decimal
from typing import Any, Dict, List, Literal, Optional, Union
from typing import Any, Literal, Optional, Union

import httpx
from pydantic import BaseModel, model_validator
Expand Down Expand Up @@ -229,7 +229,7 @@ class MarginReportEntry(TastytradeJsonDataclass):
margin_requirement: Decimal
expected_price_range_up_percent: Optional[Decimal] = None
expected_price_range_down_percent: Optional[Decimal] = None
groups: Optional[List[Dict[str, Any]]] = None
groups: Optional[list[dict[str, Any]]] = None
initial_requirement: Optional[Decimal] = None
maintenance_requirement: Optional[Decimal] = None
point_of_no_return_percent: Optional[Decimal] = None
Expand Down Expand Up @@ -269,7 +269,7 @@ class MarginReport(TastytradeJsonDataclass):
reg_t_option_buying_power: Decimal
maintenance_excess: Decimal
last_state_timestamp: int
groups: List[Union[MarginReportEntry, EmptyDict]]
groups: list[Union[MarginReportEntry, EmptyDict]]
initial_requirement: Optional[Decimal] = None

@model_validator(mode="before")
Expand Down Expand Up @@ -430,7 +430,7 @@ class Transaction(TastytradeJsonDataclass):
other_charge_description: Optional[str] = None
reverses_id: Optional[int] = None
cost_basis_reconciliation_date: Optional[date] = None
lots: Optional[List[Lot]] = None
lots: Optional[list[Lot]] = None
agency_price: Optional[Decimal] = None
principal_price: Optional[Decimal] = None

Expand Down Expand Up @@ -484,7 +484,7 @@ class Account(TastytradeJsonDataclass):
submitting_user_id: Optional[str] = None

@classmethod
async def a_get_accounts(cls, session: Session, include_closed=False) -> List[Self]:
async def a_get_accounts(cls, session: Session, include_closed=False) -> list[Self]:
"""
Gets all trading accounts associated with the Tastytrade user.
Expand All @@ -500,7 +500,7 @@ async def a_get_accounts(cls, session: Session, include_closed=False) -> List[Se
]

@classmethod
def get_accounts(cls, session: Session, include_closed=False) -> List[Self]:
def get_accounts(cls, session: Session, include_closed=False) -> list[Self]:
"""
Gets all trading accounts associated with the Tastytrade user.
Expand Down Expand Up @@ -583,7 +583,7 @@ async def a_get_balance_snapshots(
start_date: Optional[date] = None,
snapshot_date: Optional[date] = None,
time_of_day: Literal["BOD", "EOD"] = "EOD",
) -> List[AccountBalanceSnapshot]:
) -> list[AccountBalanceSnapshot]:
"""
Returns a list of balance snapshots. This list will
just have a few snapshots if you don't pass a start
Expand Down Expand Up @@ -646,7 +646,7 @@ def get_balance_snapshots(
start_date: Optional[date] = None,
snapshot_date: Optional[date] = None,
time_of_day: Literal["BOD", "EOD"] = "EOD",
) -> List[AccountBalanceSnapshot]:
) -> list[AccountBalanceSnapshot]:
"""
Returns a list of balance snapshots. This list will
just have a few snapshots if you don't pass a start
Expand Down Expand Up @@ -702,15 +702,15 @@ def get_balance_snapshots(
async def a_get_positions(
self,
session: Session,
underlying_symbols: Optional[List[str]] = None,
underlying_symbols: Optional[list[str]] = None,
symbol: Optional[str] = None,
instrument_type: Optional[InstrumentType] = None,
include_closed: Optional[bool] = None,
underlying_product_code: Optional[str] = None,
partition_keys: Optional[List[str]] = None,
partition_keys: Optional[list[str]] = None,
net_positions: Optional[bool] = None,
include_marks: Optional[bool] = None,
) -> List[CurrentPosition]:
) -> list[CurrentPosition]:
"""
Get the current positions of the account.
Expand Down Expand Up @@ -747,15 +747,15 @@ async def a_get_positions(
def get_positions(
self,
session: Session,
underlying_symbols: Optional[List[str]] = None,
underlying_symbols: Optional[list[str]] = None,
symbol: Optional[str] = None,
instrument_type: Optional[InstrumentType] = None,
include_closed: Optional[bool] = None,
underlying_product_code: Optional[str] = None,
partition_keys: Optional[List[str]] = None,
partition_keys: Optional[list[str]] = None,
net_positions: Optional[bool] = None,
include_marks: Optional[bool] = None,
) -> List[CurrentPosition]:
) -> list[CurrentPosition]:
"""
Get the current positions of the account.
Expand Down Expand Up @@ -796,8 +796,8 @@ async def a_get_history(
page_offset: Optional[int] = None,
sort: str = "Desc",
type: Optional[str] = None,
types: Optional[List[str]] = None,
sub_types: Optional[List[str]] = None,
types: Optional[list[str]] = None,
sub_types: Optional[list[str]] = None,
start_date: Optional[date] = None,
end_date: Optional[date] = None,
instrument_type: Optional[InstrumentType] = None,
Expand All @@ -808,7 +808,7 @@ async def a_get_history(
futures_symbol: Optional[str] = None,
start_at: Optional[datetime] = None,
end_at: Optional[datetime] = None,
) -> List[Transaction]:
) -> list[Transaction]:
"""
Get transaction history of the account.
Expand Down Expand Up @@ -891,8 +891,8 @@ def get_history(
page_offset: Optional[int] = None,
sort: str = "Desc",
type: Optional[str] = None,
types: Optional[List[str]] = None,
sub_types: Optional[List[str]] = None,
types: Optional[list[str]] = None,
sub_types: Optional[list[str]] = None,
start_date: Optional[date] = None,
end_date: Optional[date] = None,
instrument_type: Optional[InstrumentType] = None,
Expand All @@ -903,7 +903,7 @@ def get_history(
futures_symbol: Optional[str] = None,
start_at: Optional[datetime] = None,
end_at: Optional[datetime] = None,
) -> List[Transaction]:
) -> list[Transaction]:
"""
Get transaction history of the account.
Expand Down Expand Up @@ -1036,7 +1036,7 @@ async def a_get_net_liquidating_value_history(
session: Session,
time_back: Optional[str] = None,
start_time: Optional[datetime] = None,
) -> List[NetLiqOhlc]:
) -> list[NetLiqOhlc]:
"""
Returns a list of account net liquidating value snapshots over the
specified time period.
Expand Down Expand Up @@ -1070,7 +1070,7 @@ def get_net_liquidating_value_history(
session: Session,
time_back: Optional[str] = None,
start_time: Optional[datetime] = None,
) -> List[NetLiqOhlc]:
) -> list[NetLiqOhlc]:
"""
Returns a list of account net liquidating value snapshots over the
specified time period.
Expand Down Expand Up @@ -1175,7 +1175,7 @@ def get_margin_requirements(self, session: Session) -> MarginReport:
data = session._get(f"/margin/accounts/{self.account_number}/requirements")
return MarginReport(**data)

async def a_get_live_orders(self, session: Session) -> List[PlacedOrder]:
async def a_get_live_orders(self, session: Session) -> list[PlacedOrder]:
"""
Get orders placed today for the account.
Expand All @@ -1184,7 +1184,7 @@ async def a_get_live_orders(self, session: Session) -> List[PlacedOrder]:
data = await session._a_get(f"/accounts/{self.account_number}/orders/live")
return [PlacedOrder(**i) for i in data["items"]]

def get_live_orders(self, session: Session) -> List[PlacedOrder]:
def get_live_orders(self, session: Session) -> list[PlacedOrder]:
"""
Get orders placed today for the account.
Expand All @@ -1195,7 +1195,7 @@ def get_live_orders(self, session: Session) -> List[PlacedOrder]:

async def a_get_live_complex_orders(
self, session: Session
) -> List[PlacedComplexOrder]:
) -> list[PlacedComplexOrder]:
"""
Get complex orders placed today for the account.
Expand All @@ -1206,7 +1206,7 @@ async def a_get_live_complex_orders(
)
return [PlacedComplexOrder(**i) for i in data["items"]]

def get_live_complex_orders(self, session: Session) -> List[PlacedComplexOrder]:
def get_live_complex_orders(self, session: Session) -> list[PlacedComplexOrder]:
"""
Get complex orders placed today for the account.
Expand Down Expand Up @@ -1309,13 +1309,13 @@ async def a_get_order_history(
start_date: Optional[date] = None,
end_date: Optional[date] = None,
underlying_symbol: Optional[str] = None,
statuses: Optional[List[OrderStatus]] = None,
statuses: Optional[list[OrderStatus]] = None,
futures_symbol: Optional[str] = None,
underlying_instrument_type: Optional[InstrumentType] = None,
sort: Optional[str] = None,
start_at: Optional[datetime] = None,
end_at: Optional[datetime] = None,
) -> List[PlacedOrder]:
) -> list[PlacedOrder]:
"""
Get order history of the account.
Expand Down Expand Up @@ -1390,13 +1390,13 @@ def get_order_history(
start_date: Optional[date] = None,
end_date: Optional[date] = None,
underlying_symbol: Optional[str] = None,
statuses: Optional[List[OrderStatus]] = None,
statuses: Optional[list[OrderStatus]] = None,
futures_symbol: Optional[str] = None,
underlying_instrument_type: Optional[InstrumentType] = None,
sort: Optional[str] = None,
start_at: Optional[datetime] = None,
end_at: Optional[datetime] = None,
) -> List[PlacedOrder]:
) -> list[PlacedOrder]:
"""
Get order history of the account.
Expand Down Expand Up @@ -1465,7 +1465,7 @@ def get_order_history(

async def a_get_complex_order_history(
self, session: Session, per_page: int = 50, page_offset: Optional[int] = None
) -> List[PlacedComplexOrder]:
) -> list[PlacedComplexOrder]:
"""
Get order history of the account.
Expand Down Expand Up @@ -1504,7 +1504,7 @@ async def a_get_complex_order_history(

def get_complex_order_history(
self, session: Session, per_page: int = 50, page_offset: Optional[int] = None
) -> List[PlacedComplexOrder]:
) -> list[PlacedComplexOrder]:
"""
Get order history of the account.
Expand Down Expand Up @@ -1653,7 +1653,7 @@ async def a_get_order_chains(
symbol: str,
start_time: datetime,
end_time: datetime,
) -> List[OrderChain]:
) -> list[OrderChain]:
"""
Get a list of order chains (open + rolls + close) for given symbol
over the given time frame, with total P/L, commissions, etc.
Expand Down Expand Up @@ -1692,7 +1692,7 @@ def get_order_chains(
symbol: str,
start_time: datetime,
end_time: datetime,
) -> List[OrderChain]:
) -> list[OrderChain]:
"""
Get a list of order chains (open + rolls + close) for given symbol
over the given time frame, with total P/L, commissions, etc.
Expand Down
8 changes: 4 additions & 4 deletions tastytrade/backtest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
from datetime import date, datetime
from decimal import Decimal
from typing import AsyncGenerator, List, Literal, Optional
from typing import AsyncGenerator, Literal, Optional

import httpx
from pydantic import BaseModel, Field
Expand Down Expand Up @@ -71,7 +71,7 @@ class Backtest(BacktestJsonDataclass):
symbol: str
entry_conditions: BacktestEntry
exit_conditions: BacktestExit
legs: List[BacktestLeg]
legs: list[BacktestLeg]
start_date: date
end_date: date = date(2024, 7, 31)
status: str = "pending"
Expand Down Expand Up @@ -138,9 +138,9 @@ class BacktestResults(BacktestJsonDataclass):
Dataclass containing partial or finished results of a backtest.
"""

snapshots: Optional[List[BacktestSnapshot]]
snapshots: Optional[list[BacktestSnapshot]]
statistics: Optional[BacktestStatistics]
trials: Optional[List[BacktestTrial]]
trials: Optional[list[BacktestTrial]]


class BacktestResponse(Backtest):
Expand Down
Loading

0 comments on commit 202655e

Please sign in to comment.