tastytrade 11.0.4__py3-none-any.whl → 11.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tastytrade/__init__.py CHANGED
@@ -4,7 +4,7 @@ API_URL = "https://api.tastyworks.com"
4
4
  API_VERSION = "20251101"
5
5
  CERT_URL = "https://api.cert.tastyworks.com"
6
6
  VAST_URL = "https://vast.tastyworks.com"
7
- VERSION = "11.0.4"
7
+ VERSION = "11.0.5"
8
8
 
9
9
  __version__ = VERSION
10
10
  version_str: str = f"tastyware/tastytrade:v{VERSION}"
tastytrade/account.py CHANGED
@@ -546,8 +546,6 @@ class Account(TastytradeData):
546
546
  :param session: the session to use for the request.
547
547
  :param account_number: the account ID to get.
548
548
  :param include_closed: whether to include closed accounts in the results
549
-
550
- :return: an account if an ID was provided; otherwise, a single account.
551
549
  """
552
550
  if account_number:
553
551
  data = session._get(f"/customers/me/accounts/{account_number}")
@@ -41,8 +41,6 @@ class Event(BaseModel):
41
41
  a :class:`~tastyworks.streamer.DXFeedStreamer`.
42
42
 
43
43
  :param data: list of raw quote data from streamer
44
-
45
- :return: list of event objects from data
46
44
  """
47
45
  objs: list[Event] = []
48
46
  size = len(cls.model_fields)
tastytrade/instruments.py CHANGED
@@ -490,8 +490,8 @@ class Option(TradeableTastytradeData):
490
490
  stops_trading_at: datetime
491
491
  market_time_instrument_collection: str
492
492
  days_to_expiration: int
493
- expires_at: datetime
494
493
  is_closing_only: bool
494
+ expires_at: datetime | None = None
495
495
  streamer_symbol: str = ""
496
496
  listed_market: str | None = None
497
497
  halted_at: datetime | None = None
tastytrade/order.py CHANGED
@@ -133,7 +133,7 @@ class Leg(TastytradeData):
133
133
  instrument_type: InstrumentType
134
134
  symbol: str
135
135
  action: OrderAction
136
- quantity: Decimal | None = None
136
+ quantity: Decimal | int | None = None
137
137
  remaining_quantity: Decimal | None = None
138
138
  fills: list[FillInfo] | None = None
139
139
 
@@ -149,15 +149,13 @@ class TradeableTastytradeData(TastytradeData):
149
149
  instrument_type: InstrumentType
150
150
  symbol: str
151
151
 
152
- def build_leg(self, quantity: Decimal | None, action: OrderAction) -> Leg:
152
+ def build_leg(self, quantity: Decimal | int | None, action: OrderAction) -> Leg:
153
153
  """
154
154
  Builds an order :class:`Leg` from the dataclass.
155
155
 
156
156
  :param quantity:
157
157
  the quantity of the symbol to trade, set this as `None` for notional orders
158
158
  :param action: :class:`OrderAction` to perform, e.g. BUY_TO_OPEN
159
-
160
- :return: a :class:`Leg` object
161
159
  """
162
160
  return Leg(
163
161
  instrument_type=self.instrument_type,
tastytrade/session.py CHANGED
@@ -376,8 +376,6 @@ class Session:
376
376
  async def a_get_customer(self) -> Customer:
377
377
  """
378
378
  Gets the customer dict from the API.
379
-
380
- :return: a Tastytrade 'Customer' object in JSON format.
381
379
  """
382
380
  data = await self._a_get("/customers/me")
383
381
  return Customer(**data)
@@ -385,8 +383,6 @@ class Session:
385
383
  def get_customer(self) -> Customer:
386
384
  """
387
385
  Gets the customer dict from the API.
388
-
389
- :return: a Tastytrade 'Customer' object in JSON format.
390
386
  """
391
387
  data = self._get("/customers/me")
392
388
  return Customer(**data)
@@ -394,8 +390,6 @@ class Session:
394
390
  async def a_validate(self) -> bool:
395
391
  """
396
392
  Validates the current session by sending a request to the API.
397
-
398
- :return: True if the session is valid and False otherwise.
399
393
  """
400
394
  response = await self.async_client.post("/sessions/validate")
401
395
  return response.status_code // 100 == 2
@@ -403,8 +397,6 @@ class Session:
403
397
  def validate(self) -> bool:
404
398
  """
405
399
  Validates the current session by sending a request to the API.
406
-
407
- :return: True if the session is valid and False otherwise.
408
400
  """
409
401
  response = self.sync_client.post("/sessions/validate")
410
402
  return response.status_code // 100 == 2
@@ -420,6 +412,7 @@ class Session:
420
412
  del attrs["sync_client"]
421
413
  attrs["session_expiration"] = self.session_expiration.strftime(_fmt)
422
414
  attrs["streamer_expiration"] = self.streamer_expiration.strftime(_fmt)
415
+ attrs["headers"] = dict(self.sync_client.headers.copy())
423
416
  return json.dumps(attrs)
424
417
 
425
418
  @classmethod
@@ -427,17 +420,11 @@ class Session:
427
420
  """
428
421
  Create a new Session object from a serialized string.
429
422
  """
430
- deserialized = json.loads(serialized)
423
+ deserialized: dict[str, Any] = json.loads(serialized)
424
+ headers = deserialized.pop("headers")
431
425
  self = cls.__new__(cls)
432
426
  self.__dict__ = deserialized
433
427
  base_url = CERT_URL if self.is_test else API_URL
434
- headers = {
435
- "Accept": "application/json",
436
- "Content-Type": "application/json",
437
- "Authorization": self.session_token
438
- if "user" in deserialized
439
- else f"Bearer {self.session_token}",
440
- }
441
428
  self.session_expiration = datetime.strptime(
442
429
  deserialized["session_expiration"], _fmt
443
430
  )
tastytrade/utils.py CHANGED
@@ -29,8 +29,6 @@ class PriceEffect(str, Enum):
29
29
  def now_in_new_york() -> datetime:
30
30
  """
31
31
  Gets the current time in the New York timezone.
32
-
33
- :return: current time as datetime
34
32
  """
35
33
  return datetime.now(TZ)
36
34
 
@@ -38,8 +36,6 @@ def now_in_new_york() -> datetime:
38
36
  def today_in_new_york() -> date:
39
37
  """
40
38
  Gets the current date in the New York timezone.
41
-
42
- :return: current date
43
39
  """
44
40
  return now_in_new_york().date()
45
41
 
@@ -50,8 +46,6 @@ def is_market_open_on(day: date | None = None) -> bool:
50
46
  during the given day.
51
47
 
52
48
  :param day: date to check. If not provided defaults to current NY date.
53
-
54
- :return: whether the market opens on given day
55
49
  """
56
50
  day = day or today_in_new_york()
57
51
  date_range = NYSE.valid_days(day, day)
@@ -64,8 +58,6 @@ def get_third_friday(day: date | None = None) -> date:
64
58
  or the monthly expiration associated with today's month.
65
59
 
66
60
  :param day: date to check. If not provided defaults to current NY date.
67
-
68
- :return: the associated monthly
69
61
  """
70
62
  day = (day or today_in_new_york()).replace(day=1) + timedelta(weeks=2)
71
63
  while day.weekday() != 4: # Friday
@@ -76,8 +68,6 @@ def get_third_friday(day: date | None = None) -> date:
76
68
  def get_tasty_monthly() -> date:
77
69
  """
78
70
  Gets the monthly expiration closest to 45 days from the current date.
79
-
80
- :return: the closest to 45 DTE monthly expiration
81
71
  """
82
72
  day = today_in_new_york()
83
73
  exp1 = get_third_friday(day + timedelta(weeks=4))
@@ -101,8 +91,6 @@ def get_future_fx_monthly(day: date | None = None) -> date:
101
91
  Wednesday.
102
92
 
103
93
  :param day: date to check. If not provided defaults to current NY date.
104
-
105
- :return: the associated monthly
106
94
  """
107
95
  day = (day or today_in_new_york()).replace(day=1) + timedelta(weeks=1)
108
96
  while day.weekday() != 2: # Wednesday
@@ -120,8 +108,6 @@ def get_future_treasury_monthly(day: date | None = None) -> date:
120
108
  business day prior.
121
109
 
122
110
  :param day: date to check. If not provided defaults to current NY date.
123
-
124
- :return: the associated monthly
125
111
  """
126
112
  day = day or today_in_new_york()
127
113
  last_day = _get_last_day_of_month(day)
@@ -143,8 +129,6 @@ def get_future_metal_monthly(day: date | None = None) -> date:
143
129
  which case they expire on the prior business day.
144
130
 
145
131
  :param day: date to check. If not provided defaults to current NY date.
146
-
147
- :return: the associated monthly
148
132
  """
149
133
  day = day or today_in_new_york()
150
134
  last_day = _get_last_day_of_month(day)
@@ -164,8 +148,6 @@ def get_future_grain_monthly(day: date | None = None) -> date:
164
148
  least 2 business days, the last business day of the month.
165
149
 
166
150
  :param day: date to check. If not provided defaults to current NY date.
167
-
168
- :return: the associated monthly
169
151
  """
170
152
  day = day or today_in_new_york()
171
153
  last_day = _get_last_day_of_month(day)
@@ -185,8 +167,6 @@ def get_future_oil_monthly(day: date | None = None) -> date:
185
167
  they expire 7 business days prior to the 25th day of the month.
186
168
 
187
169
  :param day: date to check. If not provided defaults to current NY date.
188
-
189
- :return: the associated monthly
190
170
  """
191
171
  last_day = (day or today_in_new_york()).replace(day=25)
192
172
  first_day = last_day.replace(day=1)
@@ -201,8 +181,6 @@ def get_future_index_monthly(day: date | None = None) -> date:
201
181
  month.
202
182
 
203
183
  :param day: date to check. If not provided defaults to current NY date.
204
-
205
- :return: the associated monthly
206
184
  """
207
185
  day = day or today_in_new_york()
208
186
  last_day = _get_last_day_of_month(day)
@@ -224,8 +202,6 @@ def _dasherize(s: str) -> str:
224
202
  Converts a string from snake case to dasherized.
225
203
 
226
204
  :param s: string to convert
227
-
228
- :return: dasherized string
229
205
  """
230
206
  return s.replace("_", "-")
231
207
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tastytrade
3
- Version: 11.0.4
3
+ Version: 11.0.5
4
4
  Summary: An unofficial, sync/async SDK for Tastytrade!
5
5
  Project-URL: Homepage, https://github.com/tastyware/tastytrade
6
6
  Project-URL: Documentation, https://tastyworks-api.rtfd.io
@@ -1,19 +1,19 @@
1
- tastytrade/__init__.py,sha256=pwEAcH8BTcujK6-su08wNhuTUNsfta3vDpTSdnQaLBY,531
2
- tastytrade/account.py,sha256=EKRx2Yta4TjPB8U2DuIqiOZ_pdgBUXyeTMaGdNeVRwU,56859
3
- tastytrade/instruments.py,sha256=kH2AuAu6UaRwj7Uz1dYrLe6rFkJqEMXJ1Lg_cMyPg_E,46789
1
+ tastytrade/__init__.py,sha256=xHWei-s28krH-rZAarRbWbUNypkAe5cSh7frMFlr4mQ,531
2
+ tastytrade/account.py,sha256=Jsgq0hfkvMZlNI7c_-J-zLA3yF6KN8P7ozypckPLgPc,56778
3
+ tastytrade/instruments.py,sha256=QZHakLgxsgscZx7ouz1LgIuahlHM2n0AfY9UQBdlEoM,46803
4
4
  tastytrade/market_data.py,sha256=iyBpleKvDWfXReo6DuKbXP-gN1Yv8iyvNs9z2x5Gxig,5940
5
5
  tastytrade/market_sessions.py,sha256=r0L-4CSzjx2gC3pJS1C0ae9RiahaKWs67Ljng3DwODI,3382
6
6
  tastytrade/metrics.py,sha256=LqpUZIR4L2bQwawf_L4gJ3Pjg_S72eURrJpu4ebKtpU,7495
7
- tastytrade/order.py,sha256=ybhy3Ha2RLqqBRxt4ygpSnUVdbT5H-OOJ6QEaj0id34,15110
7
+ tastytrade/order.py,sha256=BNgiFAjKvE5jYW4IGK-T6lGjb_Tp2fg2CnV-X2Xg8rU,15082
8
8
  tastytrade/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  tastytrade/search.py,sha256=LdoVEhiYNvtolXlf_jAVZUtA2ymUWOvHMhQxJxuVt_A,1529
10
- tastytrade/session.py,sha256=scAJkldV8gWotOWWFxA4BSnuLdW2HfWt9PiQO_KDZ6g,15516
10
+ tastytrade/session.py,sha256=ZqjonG0oJRPvLYVoArBRwR3d8OK7xHEYmQ8a1eQroyY,15122
11
11
  tastytrade/streamer.py,sha256=7HISXzo3AKloOafMDp5NHSxW19cRcobfrrOUoymt-g4,32609
12
- tastytrade/utils.py,sha256=bLKzR6L3QqEQB_SMXgSCKqTELvdkeelu8ksycImIkKI,12766
12
+ tastytrade/utils.py,sha256=a4hzwlN-rc7vJ6LBDml36ys0ZPwrhfNlJeFUaORJao0,12302
13
13
  tastytrade/watchlists.py,sha256=K9jpgXi9a9dklGl-jCXzpbM0tOd836GSkXa4fySeH3Q,8657
14
14
  tastytrade/dxfeed/__init__.py,sha256=GmC0aKtiUjs7aqbX7PeqMaROxqalwzHOnJOMJn8TaZk,458
15
15
  tastytrade/dxfeed/candle.py,sha256=j9nuWftzOT_qGDTZNNfFIABZp_n_5Gi7OFm5KPK2dnc,1757
16
- tastytrade/dxfeed/event.py,sha256=KwqWUQqVEWdK22ymSbG9r4pkTuAR108EZmKUXjn4-0E,6071
16
+ tastytrade/dxfeed/event.py,sha256=C7ANFpblgk4MfNivvat25ox0jHmm6cCzQGYiXlsi81s,6021
17
17
  tastytrade/dxfeed/greeks.py,sha256=Q9cGrXswtWGrti8eN6Owhvs9vC5YcdtW5mJrN92_4eA,1071
18
18
  tastytrade/dxfeed/profile.py,sha256=sj-HCN7qrQvP61jEOzsEpwDsl5M_VMR_KekyRyjdsXY,1896
19
19
  tastytrade/dxfeed/quote.py,sha256=MLRe9NQZI1DbY5ZgYnyUh52Z9824uep9ZYgngbRhmbk,944
@@ -22,7 +22,7 @@ tastytrade/dxfeed/theoprice.py,sha256=L5aH--F_6xLZCSYZ4APpzlihbW0-cYEwRdeGVI-aNa
22
22
  tastytrade/dxfeed/timeandsale.py,sha256=QuMFoccq8x3c2y6s3DnwBNIVTrLS6OPqV6GmCNoXQEQ,1903
23
23
  tastytrade/dxfeed/trade.py,sha256=qNo4oKb7iq0Opoq3FCBEUUcGGF6udda1bD0eKQVty_0,1402
24
24
  tastytrade/dxfeed/underlying.py,sha256=YYqJNlmrlt6Kpg0F6voQ18g60obXiYTVlroXirBWPR8,1226
25
- tastytrade-11.0.4.dist-info/METADATA,sha256=XHOY6saD3h8mJWFtDbirg3lLMWoR9FqcU5O4fxcVAEM,10904
26
- tastytrade-11.0.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
27
- tastytrade-11.0.4.dist-info/licenses/LICENSE,sha256=enBkMN4OsfLt6Z_AsrGC7u5dAJkCEODnoN7BwMCzSfc,1072
28
- tastytrade-11.0.4.dist-info/RECORD,,
25
+ tastytrade-11.0.5.dist-info/METADATA,sha256=ZNfRbZ3yg5nbwV2dHXN_0I9kgcB3Uys1w297e-MGzvM,10904
26
+ tastytrade-11.0.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
27
+ tastytrade-11.0.5.dist-info/licenses/LICENSE,sha256=enBkMN4OsfLt6Z_AsrGC7u5dAJkCEODnoN7BwMCzSfc,1072
28
+ tastytrade-11.0.5.dist-info/RECORD,,