architect-py 5.1.3__py3-none-any.whl → 5.1.4__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.
Files changed (32) hide show
  1. architect_py/__init__.py +19 -1
  2. architect_py/async_client.py +136 -49
  3. architect_py/client.py +15 -1
  4. architect_py/client.pyi +26 -8
  5. architect_py/grpc/client.py +37 -13
  6. architect_py/grpc/models/AlgoHelper/AlgoParamTypes.py +31 -0
  7. architect_py/grpc/models/AlgoHelper/__init__.py +2 -0
  8. architect_py/grpc/models/Auth/AuthInfoRequest.py +37 -0
  9. architect_py/grpc/models/Auth/AuthInfoResponse.py +30 -0
  10. architect_py/grpc/models/Folio/AccountHistoryRequest.py +35 -4
  11. architect_py/grpc/models/Marketdata/Candle.py +6 -0
  12. architect_py/grpc/models/Marketdata/L1BookSnapshot.py +17 -3
  13. architect_py/grpc/models/Marketdata/L2BookSnapshot.py +6 -0
  14. architect_py/grpc/models/Marketdata/Liquidation.py +6 -0
  15. architect_py/grpc/models/Marketdata/Ticker.py +6 -0
  16. architect_py/grpc/models/Marketdata/TickersRequest.py +4 -1
  17. architect_py/grpc/models/Marketdata/Trade.py +6 -0
  18. architect_py/grpc/models/Oms/Order.py +38 -14
  19. architect_py/grpc/models/Oms/PlaceOrderRequest.py +38 -14
  20. architect_py/grpc/models/__init__.py +4 -1
  21. architect_py/grpc/models/definitions.py +174 -0
  22. architect_py/grpc/orderflow.py +138 -0
  23. architect_py/tests/test_order_entry.py +9 -6
  24. architect_py/tests/test_orderflow.py +116 -27
  25. {architect_py-5.1.3.dist-info → architect_py-5.1.4.dist-info}/METADATA +1 -1
  26. {architect_py-5.1.3.dist-info → architect_py-5.1.4.dist-info}/RECORD +32 -27
  27. examples/funding_rate_mean_reversion_algo.py +23 -47
  28. scripts/correct_sync_interface.py +5 -2
  29. scripts/postprocess_grpc.py +17 -2
  30. {architect_py-5.1.3.dist-info → architect_py-5.1.4.dist-info}/WHEEL +0 -0
  31. {architect_py-5.1.3.dist-info → architect_py-5.1.4.dist-info}/licenses/LICENSE +0 -0
  32. {architect_py-5.1.3.dist-info → architect_py-5.1.4.dist-info}/top_level.txt +0 -0
architect_py/__init__.py CHANGED
@@ -1,12 +1,13 @@
1
1
  # ruff: noqa:I001
2
2
 
3
- __version__ = "5.1.3"
3
+ __version__ = "5.1.4"
4
4
 
5
5
  from .utils.nearest_tick import TickRoundMethod
6
6
  from .async_client import AsyncClient
7
7
  from .client import Client
8
8
  from .common_types import OrderDir, TradableProduct, TimeInForce, Venue
9
9
  from .grpc.models.definitions import (
10
+ AccountHistoryGranularity,
10
11
  AccountIdOrName,
11
12
  AccountPosition,
12
13
  AccountStatistics,
@@ -32,12 +33,14 @@ from .grpc.models.definitions import (
32
33
  SortTickersBy,
33
34
  Statement,
34
35
  TraderIdOrEmail,
36
+ TriggerLimitOrderType,
35
37
  UserId,
36
38
  Withdrawal,
37
39
  AccountPermissions,
38
40
  AliasKind,
39
41
  DerivativeKind,
40
42
  FillKind,
43
+ HumanDuration,
41
44
  Unit,
42
45
  MinOrderQuantityUnit,
43
46
  OptionsExerciseType,
@@ -55,6 +58,7 @@ from .grpc.models.definitions import (
55
58
  SnapshotOrUpdateForStringAndProductCatalogInfo2,
56
59
  SnapshotOrUpdateForStringAndString1,
57
60
  SnapshotOrUpdateForStringAndString2,
61
+ SpreaderPhase,
58
62
  SimpleDecimal,
59
63
  Varying1,
60
64
  Varying,
@@ -82,6 +86,8 @@ from .grpc.models.definitions import (
82
86
  SnapshotOrUpdateForStringAndOptionsSeriesInfo2,
83
87
  SnapshotOrUpdateForStringAndSnapshotOrUpdateForStringAndProductCatalogInfo1,
84
88
  SnapshotOrUpdateForStringAndSnapshotOrUpdateForStringAndProductCatalogInfo2,
89
+ SpreaderParams,
90
+ SpreaderStatus,
85
91
  Account,
86
92
  FutureSpread,
87
93
  Option,
@@ -110,6 +116,9 @@ from .grpc.models.Algo.StartAlgoRequest import StartAlgoRequest
110
116
  from .grpc.models.Algo.StartAlgoResponse import StartAlgoResponse
111
117
  from .grpc.models.Algo.StopAlgoRequest import StopAlgoRequest
112
118
  from .grpc.models.Algo.StopAlgoResponse import StopAlgoResponse
119
+ from .grpc.models.AlgoHelper.AlgoParamTypes import AlgoParamTypes
120
+ from .grpc.models.Auth.AuthInfoRequest import AuthInfoRequest
121
+ from .grpc.models.Auth.AuthInfoResponse import AuthInfoResponse
113
122
  from .grpc.models.Auth.CreateJwtRequest import CreateJwtRequest
114
123
  from .grpc.models.Auth.CreateJwtResponse import CreateJwtResponse
115
124
  from .grpc.models.Boss.DepositsRequest import DepositsRequest
@@ -236,6 +245,7 @@ from .grpc.models.Symbology.UploadSymbologyResponse import UploadSymbologyRespon
236
245
  __all__ = [
237
246
  "AberrantFill",
238
247
  "Account",
248
+ "AccountHistoryGranularity",
239
249
  "AccountHistoryRequest",
240
250
  "AccountHistoryResponse",
241
251
  "AccountIdOrName",
@@ -255,9 +265,12 @@ __all__ = [
255
265
  "AlgoOrderStatus",
256
266
  "AlgoOrdersRequest",
257
267
  "AlgoOrdersResponse",
268
+ "AlgoParamTypes",
258
269
  "AliasKind",
259
270
  "ArrayOfL1BookSnapshot",
260
271
  "AsyncClient",
272
+ "AuthInfoRequest",
273
+ "AuthInfoResponse",
261
274
  "Cancel",
262
275
  "CancelAllOrdersRequest",
263
276
  "CancelAllOrdersResponse",
@@ -315,6 +328,7 @@ __all__ = [
315
328
  "HistoricalFillsResponse",
316
329
  "HistoricalOrdersRequest",
317
330
  "HistoricalOrdersResponse",
331
+ "HumanDuration",
318
332
  "Index",
319
333
  "L1BookSnapshot",
320
334
  "L1BookSnapshotRequest",
@@ -394,6 +408,9 @@ __all__ = [
394
408
  "SnapshotOrUpdateForStringAndString2",
395
409
  "SortTickersBy",
396
410
  "SpreadLeg",
411
+ "SpreaderParams",
412
+ "SpreaderPhase",
413
+ "SpreaderStatus",
397
414
  "StartAlgoRequest",
398
415
  "StartAlgoResponse",
399
416
  "Statement",
@@ -428,6 +445,7 @@ __all__ = [
428
445
  "TradableProduct",
429
446
  "Trade",
430
447
  "TraderIdOrEmail",
448
+ "TriggerLimitOrderType",
431
449
  "Unit",
432
450
  "Unknown",
433
451
  "UploadProductCatalogRequest",
@@ -6,16 +6,15 @@ from decimal import Decimal
6
6
  from typing import (
7
7
  Any,
8
8
  AsyncGenerator,
9
- AsyncIterator,
10
9
  List,
11
10
  Literal,
12
11
  Optional,
13
12
  Sequence,
13
+ Tuple,
14
14
  Union,
15
15
  overload,
16
16
  )
17
17
 
18
- import grpc
19
18
  import pandas as pd
20
19
 
21
20
  # cannot do architect_py import * due to circular import
@@ -37,12 +36,11 @@ from architect_py.grpc.models.definitions import (
37
36
  OrderSource,
38
37
  OrderType,
39
38
  SortTickersBy,
39
+ SpreaderParams,
40
40
  TraderIdOrEmail,
41
+ TriggerLimitOrderType,
41
42
  )
42
- from architect_py.grpc.models.Orderflow.OrderflowRequest import (
43
- OrderflowRequest_route,
44
- OrderflowRequestUnannotatedResponseType,
45
- )
43
+ from architect_py.grpc.orderflow import OrderflowChannel
46
44
  from architect_py.grpc.resolve_endpoint import PAPER_GRPC_PORT, resolve_endpoint
47
45
  from architect_py.utils.nearest_tick import TickRoundMethod
48
46
  from architect_py.utils.orderbook import update_orderbook_side
@@ -55,7 +53,10 @@ class AsyncClient:
55
53
  api_key: Optional[str] = None
56
54
  api_secret: Optional[str] = None
57
55
  paper_trading: bool
56
+ as_user: Optional[str] = None
57
+ as_role: Optional[str] = None
58
58
  graphql_client: GraphQLClient
59
+ grpc_options: Sequence[Tuple[str, Any]] | None = None
59
60
  grpc_core: Optional[GrpcClient] = None
60
61
  grpc_marketdata: dict[Venue, GrpcClient] = {}
61
62
  grpc_hmart: Optional[GrpcClient] = None
@@ -77,14 +78,24 @@ class AsyncClient:
77
78
  paper_trading: bool,
78
79
  endpoint: str = "https://app.architect.co",
79
80
  graphql_port: Optional[int] = None,
81
+ grpc_options: Sequence[Tuple[str, Any]] | None = None,
82
+ as_user: Optional[str] = None,
83
+ as_role: Optional[str] = None,
80
84
  **kwargs: Any,
81
85
  ) -> "AsyncClient":
82
86
  """
83
87
  Connect to an Architect installation.
84
88
 
85
- An `api_key` and `api_secret` can be created at https://app.architect.co/api-keys
89
+ An `api_key` and `api_secret` can be created at https://app.architect.co/api-keys.
86
90
 
87
91
  Raises ValueError if the API key and secret are not the correct length or contain invalid characters.
92
+
93
+ ## Advanced configuration
94
+
95
+ ### gRPC channel options
96
+
97
+ Use `grpc_options` to configure gRPC channels created by this client.
98
+ See https://grpc.github.io/grpc/python/glossary.html#term-channel_arguments for reference.
88
99
  """
89
100
  if paper_trading:
90
101
  COLOR = "\033[30;43m"
@@ -121,8 +132,11 @@ class AsyncClient:
121
132
  api_key=api_key,
122
133
  api_secret=api_secret,
123
134
  paper_trading=paper_trading,
135
+ as_user=as_user,
136
+ as_role=as_role,
124
137
  grpc_host=grpc_host,
125
138
  grpc_port=grpc_port,
139
+ grpc_options=grpc_options,
126
140
  graphql_port=graphql_port,
127
141
  use_ssl=use_ssl,
128
142
  _i_know_what_i_am_doing=True,
@@ -142,8 +156,11 @@ class AsyncClient:
142
156
  api_key: Optional[str] = None,
143
157
  api_secret: Optional[str] = None,
144
158
  paper_trading: bool,
159
+ as_user: Optional[str] = None,
160
+ as_role: Optional[str] = None,
145
161
  grpc_host: str = "app.architect.co",
146
162
  grpc_port: int,
163
+ grpc_options: Sequence[Tuple[str, Any]] | None = None,
147
164
  graphql_port: Optional[int] = None,
148
165
  use_ssl: bool = True,
149
166
  _i_know_what_i_am_doing: bool = False,
@@ -172,6 +189,8 @@ class AsyncClient:
172
189
  self.api_key = api_key
173
190
  self.api_secret = api_secret
174
191
  self.paper_trading = paper_trading
192
+ self.as_user = as_user
193
+ self.as_role = as_role
175
194
  self.graphql_client = GraphQLClient(
176
195
  host=grpc_host,
177
196
  port=graphql_port,
@@ -179,7 +198,15 @@ class AsyncClient:
179
198
  api_key=api_key,
180
199
  api_secret=api_secret,
181
200
  )
182
- self.grpc_core = GrpcClient(host=grpc_host, port=grpc_port, use_ssl=use_ssl)
201
+ self.grpc_options = grpc_options
202
+ self.grpc_core = GrpcClient(
203
+ host=grpc_host,
204
+ port=grpc_port,
205
+ use_ssl=use_ssl,
206
+ options=grpc_options,
207
+ as_user=as_user,
208
+ as_role=as_role,
209
+ )
183
210
 
184
211
  async def close(self):
185
212
  """
@@ -223,7 +250,9 @@ class AsyncClient:
223
250
  ):
224
251
  try:
225
252
  req = CreateJwtRequest(api_key=self.api_key, api_secret=self.api_secret)
226
- res: CreateJwtResponse = await self.grpc_core.unary_unary(req)
253
+ res: CreateJwtResponse = await self.grpc_core.unary_unary(
254
+ req, no_metadata=True
255
+ )
227
256
  self.jwt = res.jwt
228
257
  # CR alee: actually read the JWT to get the expiration time;
229
258
  # for now, we just "know" that the JWTs are granted for an hour
@@ -268,7 +297,12 @@ class AsyncClient:
268
297
  use_ssl,
269
298
  )
270
299
  self.grpc_marketdata[venue] = GrpcClient(
271
- host=grpc_host, port=grpc_port, use_ssl=use_ssl
300
+ host=grpc_host,
301
+ port=grpc_port,
302
+ use_ssl=use_ssl,
303
+ options=self.grpc_options,
304
+ as_user=self.as_user,
305
+ as_role=self.as_role,
272
306
  )
273
307
  except Exception as e:
274
308
  logging.error("Failed to set marketdata endpoint: %s", e)
@@ -282,7 +316,12 @@ class AsyncClient:
282
316
  try:
283
317
  grpc_host, grpc_port, use_ssl = await resolve_endpoint(endpoint)
284
318
  self.grpc_marketdata[venue] = GrpcClient(
285
- host=grpc_host, port=grpc_port, use_ssl=use_ssl
319
+ host=grpc_host,
320
+ port=grpc_port,
321
+ use_ssl=use_ssl,
322
+ options=self.grpc_options,
323
+ as_user=self.as_user,
324
+ as_role=self.as_role,
286
325
  )
287
326
  logging.debug(
288
327
  f"Setting marketdata endpoint for {venue}: {grpc_host}:{grpc_port} use_ssl={use_ssl}"
@@ -315,7 +354,12 @@ class AsyncClient:
315
354
  use_ssl,
316
355
  )
317
356
  self.grpc_hmart = GrpcClient(
318
- host=grpc_host, port=grpc_port, use_ssl=use_ssl
357
+ host=grpc_host,
358
+ port=grpc_port,
359
+ use_ssl=use_ssl,
360
+ options=self.grpc_options,
361
+ as_user=self.as_user,
362
+ as_role=self.as_role,
319
363
  )
320
364
  except Exception as e:
321
365
  logging.error("Failed to set hmart endpoint: %s", e)
@@ -356,6 +400,12 @@ class AsyncClient:
356
400
  res = await self.graphql_client.user_id_query()
357
401
  return res.user_id, res.user_email
358
402
 
403
+ async def auth_info(self) -> AuthInfoResponse:
404
+ grpc_client = await self.core()
405
+ req = AuthInfoRequest()
406
+ res: AuthInfoResponse = await grpc_client.unary_unary(req)
407
+ return res
408
+
359
409
  def enable_orderflow(self):
360
410
  """
361
411
  @deprecated(reason="No longer needed; orderflow is enabled by default")
@@ -364,7 +414,9 @@ class AsyncClient:
364
414
  "as of v5.0.0: enable_orderflow is deprecated; orderflow is enabled by default"
365
415
  )
366
416
 
367
- async def cpty_status(self, kind: str, instance: Optional[str] = None) -> CptyStatus:
417
+ async def cpty_status(
418
+ self, kind: str, instance: Optional[str] = None
419
+ ) -> CptyStatus:
368
420
  """
369
421
  Get cpty status.
370
422
  """
@@ -839,7 +891,11 @@ class AsyncClient:
839
891
  return res
840
892
 
841
893
  async def stream_l1_book_snapshots(
842
- self, symbols: Sequence[TradableProduct | str], venue: Venue
894
+ self,
895
+ symbols: Sequence[TradableProduct | str],
896
+ venue: Venue,
897
+ *,
898
+ send_initial_snapshots: Optional[bool] = False,
843
899
  ) -> AsyncGenerator[L1BookSnapshot, None]:
844
900
  """
845
901
  Subscribe to the stream of L1BookSnapshots for a symbol.
@@ -850,7 +906,11 @@ class AsyncClient:
850
906
  venue: the venue to subscribe to
851
907
  """
852
908
  grpc_client = await self.marketdata(venue)
853
- req = SubscribeL1BookSnapshotsRequest(symbols=list(symbols), venue=venue)
909
+ req = SubscribeL1BookSnapshotsRequest(
910
+ symbols=list(symbols),
911
+ venue=venue,
912
+ send_initial_snapshots=send_initial_snapshots,
913
+ )
854
914
  async for res in grpc_client.unary_stream(req):
855
915
  yield res
856
916
 
@@ -1355,30 +1415,17 @@ class AsyncClient:
1355
1415
 
1356
1416
  async def orderflow(
1357
1417
  self,
1358
- request_iterator: AsyncIterator[OrderflowRequest],
1359
- ) -> AsyncGenerator[Orderflow, None]:
1418
+ max_queue_size: int = 1024,
1419
+ ) -> OrderflowChannel:
1360
1420
  """
1361
1421
  A two-way channel for both order entry and listening to order updates (fills, acks, outs, etc.).
1362
1422
 
1363
1423
  This is considered the most efficient way to trade in this SDK.
1364
1424
 
1365
- Example:
1366
- See test_orderflow.py for an example.
1367
-
1368
- This WILL block the event loop until the stream is closed.
1425
+ This requires advanced knowledge of the SDK and asyncio, not recommended for beginners.
1426
+ See the OrderflowManager documentation for more details.
1369
1427
  """
1370
- grpc_client = await self.core()
1371
- decoder = grpc_client.get_decoder(OrderflowRequestUnannotatedResponseType)
1372
- stub: grpc.aio.StreamStreamMultiCallable = grpc_client.channel.stream_stream(
1373
- OrderflowRequest_route,
1374
- request_serializer=grpc_client.encoder().encode,
1375
- response_deserializer=decoder.decode,
1376
- )
1377
- call: grpc.aio._base_call.StreamStreamCall[OrderflowRequest, Orderflow] = stub(
1378
- request_iterator, metadata=(("authorization", f"Bearer {grpc_client.jwt}"),)
1379
- )
1380
- async for update in call:
1381
- yield update
1428
+ return OrderflowChannel(self, max_queue_size=max_queue_size)
1382
1429
 
1383
1430
  async def stream_orderflow(
1384
1431
  self,
@@ -1412,9 +1459,27 @@ class AsyncClient:
1412
1459
  **kwargs,
1413
1460
  ) -> Order:
1414
1461
  """
1415
- @deprecated(reason="Use place_limit_order instead")
1462
+ @deprecated(reason="Use place_order instead")
1416
1463
  """
1417
- return await self.place_limit_order(*args, **kwargs)
1464
+ logging.warning(
1465
+ "send_limit_order is deprecated, use place_order instead. "
1466
+ "This will be removed in a future version."
1467
+ )
1468
+ return await self.place_order(*args, **kwargs)
1469
+
1470
+ async def place_limit_order(
1471
+ self,
1472
+ *args,
1473
+ **kwargs,
1474
+ ) -> Order:
1475
+ """
1476
+ @deprecated(reason="Use place_order instead")
1477
+ """
1478
+ logging.warning(
1479
+ "place_limit_order is deprecated, use place_order instead. "
1480
+ "This will be removed in a future version."
1481
+ )
1482
+ return await self.place_order(*args, **kwargs)
1418
1483
 
1419
1484
  async def place_orders(
1420
1485
  self, order_requests: Sequence[PlaceOrderRequest]
@@ -1458,26 +1523,28 @@ class AsyncClient:
1458
1523
 
1459
1524
  return res
1460
1525
 
1461
- async def place_limit_order(
1526
+ async def place_order(
1462
1527
  self,
1463
1528
  *,
1464
1529
  id: Optional[OrderId] = None,
1465
1530
  symbol: TradableProduct | str,
1466
1531
  execution_venue: Optional[str] = None,
1467
- dir: Optional[OrderDir] = None,
1532
+ dir: OrderDir,
1468
1533
  quantity: Decimal,
1469
- limit_price: Decimal,
1534
+ limit_price: Optional[Decimal] = None,
1470
1535
  order_type: OrderType = OrderType.LIMIT,
1471
1536
  time_in_force: TimeInForce = TimeInForce.DAY,
1472
1537
  price_round_method: Optional[TickRoundMethod] = None,
1473
1538
  account: Optional[str] = None,
1474
1539
  trader: Optional[str] = None,
1475
- post_only: bool = False,
1540
+ post_only: Optional[bool] = None,
1476
1541
  trigger_price: Optional[Decimal] = None,
1542
+ stop_loss: Optional[TriggerLimitOrderType] = None,
1543
+ take_profit_price: Optional[Decimal] = None,
1477
1544
  **kwargs: Any,
1478
1545
  ) -> Order:
1479
1546
  """
1480
- Sends a regular limit order.
1547
+ Sends a regular order.
1481
1548
 
1482
1549
  Args:
1483
1550
  id: in case user wants to generate their own order id, otherwise it will be generated automatically
@@ -1496,8 +1563,10 @@ class AsyncClient:
1496
1563
  While technically optional, for most order types, the account is required
1497
1564
  trader: the trader to send the order for, defaults to the user's trader
1498
1565
  for when sending order for another user, not relevant for vast majority of users
1499
- post_only: whether the order should be post only, not supported by all exchanges
1566
+ post_only: whether the order should be post only, NOT SUPPORTED BY ALL EXCHANGES (e.g. CME)
1500
1567
  trigger_price: the trigger price for the order, only relevant for stop / take_profit orders
1568
+ stop_loss_price: the stop loss price for a bracket order.
1569
+ profit_price: the take profit price for a bracket order.
1501
1570
  Returns:
1502
1571
  the Order object for the order
1503
1572
  The order.status should be "PENDING" until the order is "OPEN" / "REJECTED" / "OUT" / "CANCELED" / "STALE"
@@ -1507,14 +1576,7 @@ class AsyncClient:
1507
1576
  grpc_client = await self.core()
1508
1577
  assert quantity > 0, "quantity must be positive"
1509
1578
 
1510
- if dir is None:
1511
- if "odir" in kwargs and isinstance(kwargs["odir"], OrderDir):
1512
- logging.warning("odir is deprecated, use dir instead")
1513
- dir = kwargs["odir"]
1514
- else:
1515
- raise ValueError("dir is required")
1516
-
1517
- if price_round_method is not None:
1579
+ if limit_price is not None and price_round_method is not None:
1518
1580
  if execution_venue is None:
1519
1581
  product_info = await self.get_product_info(symbol)
1520
1582
  if product_info is None:
@@ -1554,6 +1616,8 @@ class AsyncClient:
1554
1616
  execution_venue=execution_venue,
1555
1617
  post_only=post_only,
1556
1618
  trigger_price=trigger_price,
1619
+ stop_loss=stop_loss,
1620
+ take_profit_price=take_profit_price,
1557
1621
  )
1558
1622
  res = await grpc_client.unary_unary(req)
1559
1623
  return res
@@ -1698,3 +1762,26 @@ class AsyncClient:
1698
1762
  # )
1699
1763
  # res = await grpc_client.unary_unary(req)
1700
1764
  # return True
1765
+
1766
+ async def create_algo_order(
1767
+ self,
1768
+ *,
1769
+ params: SpreaderParams,
1770
+ id: Optional[str] = None,
1771
+ trader: Optional[str] = None,
1772
+ ):
1773
+ """
1774
+ Sends an advanced algo order such as the spreader.
1775
+ """
1776
+ grpc_client = await self.core()
1777
+
1778
+ if isinstance(params, SpreaderParams):
1779
+ algo = "SPREADER"
1780
+ else:
1781
+ raise ValueError(
1782
+ "Unsupported algo type. Only SpreaderParams is supported for now."
1783
+ )
1784
+
1785
+ req = CreateAlgoOrderRequest(algo=algo, params=params, id=id, trader=trader)
1786
+ res = await grpc_client.unary_unary(req)
1787
+ return res
architect_py/client.py CHANGED
@@ -4,7 +4,15 @@ import threading
4
4
  from asyncio import AbstractEventLoop
5
5
  from collections.abc import Callable
6
6
  from functools import partial
7
- from typing import Any, Concatenate, Coroutine, Optional, ParamSpec, TypeVar
7
+ from typing import (
8
+ Any,
9
+ Concatenate,
10
+ Coroutine,
11
+ Optional,
12
+ ParamSpec,
13
+ Sequence,
14
+ TypeVar,
15
+ )
8
16
 
9
17
  from .async_client import AsyncClient
10
18
 
@@ -48,8 +56,11 @@ class Client:
48
56
  api_key: str,
49
57
  api_secret: str,
50
58
  paper_trading: bool,
59
+ as_user: Optional[str] = None,
60
+ as_role: Optional[str] = None,
51
61
  endpoint: str = "https://app.architect.co",
52
62
  graphql_port: Optional[int] = None,
63
+ grpc_options: Sequence[tuple[str, Any]] | None = None,
53
64
  event_loop: Optional[AbstractEventLoop] = None,
54
65
  **kwargs,
55
66
  ):
@@ -76,8 +87,11 @@ class Client:
76
87
  api_key=api_key,
77
88
  api_secret=api_secret,
78
89
  paper_trading=paper_trading,
90
+ as_user=as_user,
91
+ as_role=as_role,
79
92
  endpoint=endpoint,
80
93
  graphql_port=graphql_port,
94
+ grpc_options=grpc_options,
81
95
  **kwargs,
82
96
  )
83
97
 
architect_py/client.pyi CHANGED
@@ -9,8 +9,8 @@ from architect_py.graphql_client import GraphQLClient as GraphQLClient
9
9
  from architect_py.graphql_client.exceptions import GraphQLClientGraphQLMultiError as GraphQLClientGraphQLMultiError
10
10
  from architect_py.graphql_client.fragments import ExecutionInfoFields as ExecutionInfoFields, ProductInfoFields as ProductInfoFields
11
11
  from architect_py.grpc.client import GrpcClient as GrpcClient
12
- from architect_py.grpc.models.Orderflow.OrderflowRequest import OrderflowRequestUnannotatedResponseType as OrderflowRequestUnannotatedResponseType, OrderflowRequest_route as OrderflowRequest_route
13
- from architect_py.grpc.models.definitions import AccountIdOrName as AccountIdOrName, AccountWithPermissions as AccountWithPermissions, CandleWidth as CandleWidth, L2BookDiff as L2BookDiff, OrderId as OrderId, OrderSource as OrderSource, OrderType as OrderType, SortTickersBy as SortTickersBy, TraderIdOrEmail as TraderIdOrEmail
12
+ from architect_py.grpc.models.definitions import AccountIdOrName as AccountIdOrName, AccountWithPermissions as AccountWithPermissions, CandleWidth as CandleWidth, L2BookDiff as L2BookDiff, OrderId as OrderId, OrderSource as OrderSource, OrderType as OrderType, SortTickersBy as SortTickersBy, SpreaderParams as SpreaderParams, TraderIdOrEmail as TraderIdOrEmail, TriggerLimitOrderType as TriggerLimitOrderType
13
+ from architect_py.grpc.orderflow import OrderflowChannel as OrderflowChannel
14
14
  from architect_py.grpc.resolve_endpoint import PAPER_GRPC_PORT as PAPER_GRPC_PORT, resolve_endpoint as resolve_endpoint
15
15
  from architect_py.utils.nearest_tick import TickRoundMethod as TickRoundMethod
16
16
  from architect_py.utils.orderbook import update_orderbook_side as update_orderbook_side
@@ -19,7 +19,7 @@ from architect_py.utils.price_bands import price_band_pairs as price_band_pairs
19
19
  from architect_py.utils.symbol_parsing import nominative_expiration as nominative_expiration
20
20
  from datetime import date, datetime
21
21
  from decimal import Decimal
22
- from typing import Any, AsyncGenerator, AsyncIterator, Literal, Sequence, overload
22
+ from typing import Any, AsyncGenerator, Literal, Sequence, overload
23
23
 
24
24
  class Client:
25
25
  """
@@ -37,14 +37,17 @@ class Client:
37
37
  api_key: str | None
38
38
  api_secret: str | None
39
39
  paper_trading: bool
40
+ as_user: str | None
41
+ as_role: str | None
40
42
  graphql_client: GraphQLClient
43
+ grpc_options: Sequence[tuple[str, Any]] | None
41
44
  grpc_core: GrpcClient | None
42
45
  grpc_marketdata: dict[Venue, GrpcClient]
43
46
  grpc_hmart: GrpcClient | None
44
47
  jwt: str | None
45
48
  jwt_expiration: datetime | None
46
49
  l1_books: dict[Venue, dict[TradableProduct, tuple[L1BookSnapshot, asyncio.Task]]]
47
- def __init__(self, *, api_key: str, api_secret: str, paper_trading: bool, endpoint: str = 'https://app.architect.co', graphql_port: int | None = None, event_loop: asyncio.events.AbstractEventLoop | None = None) -> None:
50
+ def __init__(self, *, api_key: str, api_secret: str, paper_trading: bool, as_user: str | None = None, as_role: str | None = None, endpoint: str = 'https://app.architect.co', graphql_port: int | None = None, grpc_options: Sequence[tuple[str, Any]] | None = None, event_loop: asyncio.events.AbstractEventLoop | None = None) -> None:
48
51
  """
49
52
  Create a new Client instance.
50
53
 
@@ -118,6 +121,11 @@ class Client:
118
121
  Returns:
119
122
  (user_id, user_email)
120
123
  """
124
+ def auth_info(self) -> AuthInfoResponse: ...
125
+ def cpty_status(self, kind: str, instance: str | None = None) -> CptyStatus:
126
+ """
127
+ Get cpty status.
128
+ """
121
129
  def list_symbols(self, *, marketdata: Venue | None = None) -> list[str]:
122
130
  """
123
131
  List all symbols.
@@ -446,7 +454,11 @@ class Client:
446
454
  '''
447
455
  def send_limit_order(self, *args, **kwargs) -> Order:
448
456
  '''
449
- @deprecated(reason="Use place_limit_order instead")
457
+ @deprecated(reason="Use place_order instead")
458
+ '''
459
+ def place_limit_order(self, *args, **kwargs) -> Order:
460
+ '''
461
+ @deprecated(reason="Use place_order instead")
450
462
  '''
451
463
  def place_orders(self, order_requests: Sequence[PlaceOrderRequest]) -> list[Order]:
452
464
  """
@@ -477,9 +489,9 @@ class Client:
477
489
  trigger_price=trigger_price,
478
490
  )
479
491
  """
480
- def place_limit_order(self, *, id: OrderId | None = None, symbol: TradableProduct | str, execution_venue: str | None = None, dir: OrderDir | None = None, quantity: Decimal, limit_price: Decimal, order_type: OrderType = ..., time_in_force: TimeInForce = ..., price_round_method: TickRoundMethod | None = None, account: str | None = None, trader: str | None = None, post_only: bool = False, trigger_price: Decimal | None = None, **kwargs: Any) -> Order:
492
+ def place_order(self, *, id: OrderId | None = None, symbol: TradableProduct | str, execution_venue: str | None = None, dir: OrderDir, quantity: Decimal, limit_price: Decimal | None = None, order_type: OrderType = ..., time_in_force: TimeInForce = ..., price_round_method: TickRoundMethod | None = None, account: str | None = None, trader: str | None = None, post_only: bool | None = None, trigger_price: Decimal | None = None, stop_loss: TriggerLimitOrderType | None = None, take_profit_price: Decimal | None = None, **kwargs: Any) -> Order:
481
493
  '''
482
- Sends a regular limit order.
494
+ Sends a regular order.
483
495
 
484
496
  Args:
485
497
  id: in case user wants to generate their own order id, otherwise it will be generated automatically
@@ -498,8 +510,10 @@ class Client:
498
510
  While technically optional, for most order types, the account is required
499
511
  trader: the trader to send the order for, defaults to the user\'s trader
500
512
  for when sending order for another user, not relevant for vast majority of users
501
- post_only: whether the order should be post only, not supported by all exchanges
513
+ post_only: whether the order should be post only, NOT SUPPORTED BY ALL EXCHANGES (e.g. CME)
502
514
  trigger_price: the trigger price for the order, only relevant for stop / take_profit orders
515
+ stop_loss_price: the stop loss price for a bracket order.
516
+ profit_price: the take profit price for a bracket order.
503
517
  Returns:
504
518
  the Order object for the order
505
519
  The order.status should be "PENDING" until the order is "OPEN" / "REJECTED" / "OUT" / "CANCELED" / "STALE"
@@ -544,3 +558,7 @@ class Client:
544
558
  True if all orders were cancelled successfully
545
559
  False if there was an error
546
560
  """
561
+ def create_algo_order(self, *, params: SpreaderParams, id: str | None = None, trader: str | None = None):
562
+ """
563
+ Sends an advanced algo order such as the spreader.
564
+ """