architect-py 3.2.2__py3-none-any.whl → 5.0.0__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 (205) hide show
  1. architect_py/__init__.py +18 -2
  2. architect_py/async_client.py +1069 -647
  3. architect_py/client.py +25 -26
  4. architect_py/client_interface.py +63 -0
  5. architect_py/common_types/__init__.py +6 -0
  6. architect_py/common_types/order_dir.py +91 -0
  7. architect_py/common_types/scalars.py +25 -0
  8. architect_py/common_types/tradable_product.py +59 -0
  9. architect_py/graphql_client/__init__.py +2 -0
  10. architect_py/graphql_client/client.py +3 -6
  11. architect_py/graphql_client/enums.py +5 -0
  12. architect_py/graphql_client/fragments.py +3 -6
  13. architect_py/graphql_client/get_fills_query.py +2 -1
  14. architect_py/graphql_client/search_symbols_query.py +2 -1
  15. architect_py/graphql_client/subscribe_orderflow.py +2 -1
  16. architect_py/graphql_client/subscribe_trades.py +2 -1
  17. architect_py/grpc/__init__.py +145 -0
  18. architect_py/grpc/client.py +94 -0
  19. architect_py/{grpc_client → grpc/models}/Accounts/AccountsRequest.py +6 -3
  20. architect_py/{grpc_client → grpc/models}/Accounts/AccountsResponse.py +1 -1
  21. architect_py/{grpc_client → grpc/models}/Accounts/__init__.py +1 -1
  22. architect_py/grpc/models/Algo/AlgoOrder.py +114 -0
  23. architect_py/grpc/models/Algo/AlgoOrderRequest.py +46 -0
  24. architect_py/grpc/models/Algo/AlgoOrdersRequest.py +72 -0
  25. architect_py/grpc/models/Algo/AlgoOrdersResponse.py +27 -0
  26. architect_py/grpc/models/Algo/CreateAlgoOrderRequest.py +56 -0
  27. architect_py/grpc/models/Algo/PauseAlgoRequest.py +42 -0
  28. architect_py/grpc/models/Algo/PauseAlgoResponse.py +20 -0
  29. architect_py/grpc/models/Algo/StartAlgoRequest.py +42 -0
  30. architect_py/grpc/models/Algo/StartAlgoResponse.py +20 -0
  31. architect_py/grpc/models/Algo/StopAlgoRequest.py +42 -0
  32. architect_py/grpc/models/Algo/StopAlgoResponse.py +20 -0
  33. architect_py/{grpc_client → grpc/models}/Algo/__init__.py +1 -1
  34. architect_py/grpc/models/Auth/CreateJwtRequest.py +47 -0
  35. architect_py/grpc/models/Auth/CreateJwtResponse.py +23 -0
  36. architect_py/{grpc_client/Cpty → grpc/models/Auth}/__init__.py +1 -1
  37. architect_py/grpc/models/Boss/DepositsRequest.py +40 -0
  38. architect_py/grpc/models/Boss/DepositsResponse.py +27 -0
  39. architect_py/grpc/models/Boss/RqdAccountStatisticsRequest.py +42 -0
  40. architect_py/grpc/models/Boss/RqdAccountStatisticsResponse.py +25 -0
  41. architect_py/grpc/models/Boss/StatementUrlRequest.py +40 -0
  42. architect_py/grpc/models/Boss/StatementUrlResponse.py +23 -0
  43. architect_py/grpc/models/Boss/StatementsRequest.py +40 -0
  44. architect_py/grpc/models/Boss/StatementsResponse.py +27 -0
  45. architect_py/grpc/models/Boss/WithdrawalsRequest.py +40 -0
  46. architect_py/grpc/models/Boss/WithdrawalsResponse.py +27 -0
  47. architect_py/{grpc_client/Folio → grpc/models/Boss}/__init__.py +1 -1
  48. architect_py/grpc/models/Core/ConfigRequest.py +37 -0
  49. architect_py/grpc/models/Core/ConfigResponse.py +25 -0
  50. architect_py/grpc/models/Core/__init__.py +2 -0
  51. architect_py/{grpc_client → grpc/models}/Cpty/CptyRequest.py +2 -2
  52. architect_py/{grpc_client → grpc/models}/Cpty/CptyResponse.py +3 -3
  53. architect_py/{grpc_client → grpc/models}/Cpty/CptyStatus.py +1 -1
  54. architect_py/{grpc_client → grpc/models}/Cpty/CptyStatusRequest.py +2 -2
  55. architect_py/{grpc_client → grpc/models}/Cpty/CptysRequest.py +2 -2
  56. architect_py/{grpc_client → grpc/models}/Cpty/CptysResponse.py +1 -1
  57. architect_py/grpc/models/Cpty/__init__.py +2 -0
  58. architect_py/{grpc_client → grpc/models}/Folio/AccountHistoryRequest.py +2 -2
  59. architect_py/{grpc_client → grpc/models}/Folio/AccountHistoryResponse.py +1 -1
  60. architect_py/{grpc_client → grpc/models}/Folio/AccountSummariesRequest.py +2 -2
  61. architect_py/{grpc_client → grpc/models}/Folio/AccountSummariesResponse.py +1 -1
  62. architect_py/{grpc_client → grpc/models}/Folio/AccountSummary.py +1 -1
  63. architect_py/{grpc_client → grpc/models}/Folio/AccountSummaryRequest.py +2 -2
  64. architect_py/{grpc_client → grpc/models}/Folio/HistoricalFillsRequest.py +7 -4
  65. architect_py/{grpc_client → grpc/models}/Folio/HistoricalFillsResponse.py +1 -1
  66. architect_py/{grpc_client → grpc/models}/Folio/HistoricalOrdersRequest.py +3 -3
  67. architect_py/{grpc_client → grpc/models}/Folio/HistoricalOrdersResponse.py +1 -1
  68. architect_py/grpc/models/Folio/__init__.py +2 -0
  69. architect_py/{grpc_client → grpc/models}/Health/HealthCheckRequest.py +2 -2
  70. architect_py/{grpc_client → grpc/models}/Health/HealthCheckResponse.py +1 -1
  71. architect_py/grpc/models/Health/__init__.py +2 -0
  72. architect_py/{grpc_client → grpc/models}/Marketdata/Candle.py +1 -1
  73. architect_py/{grpc_client → grpc/models}/Marketdata/HistoricalCandlesRequest.py +11 -8
  74. architect_py/{grpc_client → grpc/models}/Marketdata/HistoricalCandlesResponse.py +1 -1
  75. architect_py/{grpc_client → grpc/models}/Marketdata/L1BookSnapshot.py +52 -5
  76. architect_py/{grpc_client → grpc/models}/Marketdata/L1BookSnapshotRequest.py +8 -3
  77. architect_py/{grpc_client → grpc/models}/Marketdata/L1BookSnapshotsRequest.py +6 -3
  78. architect_py/{grpc_client → grpc/models}/Marketdata/L2BookSnapshot.py +1 -1
  79. architect_py/{grpc_client → grpc/models}/Marketdata/L2BookSnapshotRequest.py +2 -2
  80. architect_py/{grpc_client → grpc/models}/Marketdata/Liquidation.py +2 -2
  81. architect_py/{grpc_client → grpc/models}/Marketdata/MarketStatus.py +1 -1
  82. architect_py/{grpc_client → grpc/models}/Marketdata/MarketStatusRequest.py +2 -2
  83. architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeCandlesRequest.py +2 -2
  84. architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeCurrentCandlesRequest.py +3 -4
  85. architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeL1BookSnapshotsRequest.py +6 -3
  86. architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeL2BookUpdatesRequest.py +2 -2
  87. architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeLiquidationsRequest.py +2 -2
  88. architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeManyCandlesRequest.py +2 -2
  89. architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeTickersRequest.py +2 -2
  90. architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeTradesRequest.py +2 -2
  91. architect_py/{grpc_client → grpc/models}/Marketdata/Ticker.py +1 -1
  92. architect_py/{grpc_client → grpc/models}/Marketdata/TickerRequest.py +2 -2
  93. architect_py/{grpc_client → grpc/models}/Marketdata/TickersRequest.py +2 -2
  94. architect_py/{grpc_client → grpc/models}/Marketdata/TickersResponse.py +1 -1
  95. architect_py/{grpc_client → grpc/models}/Marketdata/Trade.py +2 -2
  96. architect_py/grpc/models/Marketdata/__init__.py +2 -0
  97. architect_py/grpc/models/Oms/Cancel.py +90 -0
  98. architect_py/{grpc_client → grpc/models}/Oms/CancelAllOrdersRequest.py +2 -2
  99. architect_py/{grpc_client → grpc/models}/Oms/CancelAllOrdersResponse.py +1 -1
  100. architect_py/{grpc_client → grpc/models}/Oms/CancelOrderRequest.py +2 -2
  101. architect_py/{grpc_client → grpc/models}/Oms/OpenOrdersRequest.py +2 -2
  102. architect_py/{grpc_client → grpc/models}/Oms/OpenOrdersResponse.py +1 -1
  103. architect_py/{grpc_client → grpc/models}/Oms/Order.py +6 -13
  104. architect_py/{grpc_client → grpc/models}/Oms/PendingCancelsRequest.py +2 -2
  105. architect_py/{grpc_client → grpc/models}/Oms/PendingCancelsResponse.py +1 -1
  106. architect_py/{grpc_client → grpc/models}/Oms/PlaceOrderRequest.py +16 -23
  107. architect_py/grpc/models/Oms/__init__.py +2 -0
  108. architect_py/grpc/models/OptionsMarketdata/OptionsChain.py +30 -0
  109. architect_py/grpc/models/OptionsMarketdata/OptionsChainGreeks.py +30 -0
  110. architect_py/grpc/models/OptionsMarketdata/OptionsChainGreeksRequest.py +47 -0
  111. architect_py/grpc/models/OptionsMarketdata/OptionsChainRequest.py +45 -0
  112. architect_py/grpc/models/OptionsMarketdata/OptionsExpirations.py +29 -0
  113. architect_py/grpc/models/OptionsMarketdata/OptionsExpirationsRequest.py +42 -0
  114. architect_py/grpc/models/OptionsMarketdata/__init__.py +2 -0
  115. architect_py/{grpc_client → grpc/models}/Orderflow/DropcopyRequest.py +2 -2
  116. architect_py/{grpc_client → grpc/models}/Orderflow/OrderflowRequest.py +1 -1
  117. architect_py/{grpc_client → grpc/models}/Orderflow/SubscribeOrderflowRequest.py +2 -2
  118. architect_py/grpc/models/Orderflow/__init__.py +2 -0
  119. architect_py/grpc/models/Symbology/DownloadProductCatalogRequest.py +42 -0
  120. architect_py/grpc/models/Symbology/DownloadProductCatalogResponse.py +27 -0
  121. architect_py/grpc/models/Symbology/ExecutionInfoRequest.py +47 -0
  122. architect_py/grpc/models/Symbology/ExecutionInfoResponse.py +27 -0
  123. architect_py/{grpc_client → grpc/models}/Symbology/PruneExpiredSymbolsRequest.py +2 -2
  124. architect_py/{grpc_client → grpc/models}/Symbology/PruneExpiredSymbolsResponse.py +1 -1
  125. architect_py/{grpc_client → grpc/models}/Symbology/SubscribeSymbology.py +1 -1
  126. architect_py/{grpc_client → grpc/models}/Symbology/SymbologyRequest.py +2 -2
  127. architect_py/{grpc_client → grpc/models}/Symbology/SymbologySnapshot.py +7 -2
  128. architect_py/{grpc_client → grpc/models}/Symbology/SymbologyUpdate.py +9 -2
  129. architect_py/{grpc_client → grpc/models}/Symbology/SymbolsRequest.py +2 -2
  130. architect_py/{grpc_client → grpc/models}/Symbology/SymbolsResponse.py +1 -1
  131. architect_py/grpc/models/Symbology/UploadProductCatalogRequest.py +49 -0
  132. architect_py/grpc/models/Symbology/UploadProductCatalogResponse.py +20 -0
  133. architect_py/{grpc_client → grpc/models}/Symbology/UploadSymbologyRequest.py +2 -2
  134. architect_py/{grpc_client → grpc/models}/Symbology/UploadSymbologyResponse.py +1 -1
  135. architect_py/grpc/models/Symbology/__init__.py +2 -0
  136. architect_py/grpc/models/__init__.py +2 -0
  137. architect_py/{grpc_client → grpc/models}/definitions.py +690 -841
  138. architect_py/grpc/resolve_endpoint.py +70 -0
  139. architect_py/{grpc_client/grpc_server.py → grpc/server.py} +9 -6
  140. architect_py/grpc/utils.py +32 -0
  141. architect_py/internal_utils/__init__.py +0 -0
  142. architect_py/internal_utils/no_pandas.py +3 -0
  143. architect_py/tests/conftest.py +91 -87
  144. architect_py/tests/test_book_building.py +49 -50
  145. architect_py/tests/test_marketdata.py +168 -0
  146. architect_py/tests/test_order_entry.py +37 -0
  147. architect_py/tests/test_orderflow.py +41 -0
  148. architect_py/tests/test_portfolio_management.py +23 -0
  149. architect_py/tests/test_rounding.py +28 -28
  150. architect_py/tests/test_symbology.py +37 -30
  151. architect_py/utils/nearest_tick.py +2 -5
  152. architect_py/utils/nearest_tick_2.py +1 -2
  153. architect_py/utils/orderbook.py +35 -0
  154. architect_py/utils/pandas.py +44 -0
  155. architect_py/utils/price_bands.py +0 -3
  156. architect_py/utils/symbol_parsing.py +29 -0
  157. architect_py-5.0.0.dist-info/METADATA +54 -0
  158. architect_py-5.0.0.dist-info/RECORD +214 -0
  159. {architect_py-3.2.2.dist-info → architect_py-5.0.0.dist-info}/WHEEL +2 -1
  160. architect_py-5.0.0.dist-info/top_level.txt +4 -0
  161. examples/__init__.py +0 -0
  162. examples/book_subscription.py +52 -0
  163. examples/candles.py +30 -0
  164. examples/common.py +116 -0
  165. examples/external_cpty.py +77 -0
  166. examples/funding_rate_mean_reversion_algo.py +186 -0
  167. examples/order_sending.py +91 -0
  168. examples/stream_l1_marketdata.py +25 -0
  169. examples/stream_l2_marketdata.py +38 -0
  170. examples/trades.py +21 -0
  171. examples/tutorial_async.py +86 -0
  172. examples/tutorial_sync.py +95 -0
  173. scripts/generate_functions_md.py +166 -0
  174. scripts/generate_sync_interface.py +226 -0
  175. scripts/postprocess_grpc.py +604 -0
  176. scripts/preprocess_grpc_schema.py +708 -0
  177. templates/exceptions.py +83 -0
  178. templates/juniper_base_client.py +371 -0
  179. architect_py/client_protocol.py +0 -53
  180. architect_py/grpc_client/Algo/AlgoOrderForTwapAlgo.py +0 -61
  181. architect_py/grpc_client/Algo/CreateAlgoOrderRequestForTwapAlgo.py +0 -59
  182. architect_py/grpc_client/Algo/ModifyAlgoOrderRequestForTwapAlgo.py +0 -45
  183. architect_py/grpc_client/Health/__init__.py +0 -2
  184. architect_py/grpc_client/Marketdata/__init__.py +0 -2
  185. architect_py/grpc_client/Oms/Cancel.py +0 -42
  186. architect_py/grpc_client/Oms/__init__.py +0 -2
  187. architect_py/grpc_client/Orderflow/__init__.py +0 -2
  188. architect_py/grpc_client/Symbology/__init__.py +0 -2
  189. architect_py/grpc_client/__init__.py +0 -2
  190. architect_py/grpc_client/grpc_client.py +0 -413
  191. architect_py/scalars.py +0 -172
  192. architect_py/tests/test_accounts.py +0 -31
  193. architect_py/tests/test_client.py +0 -29
  194. architect_py/tests/test_grpc_client.py +0 -30
  195. architect_py/tests/test_order_sending.py +0 -65
  196. architect_py/tests/test_snapshots.py +0 -52
  197. architect_py/tests/test_subscriptions.py +0 -126
  198. architect_py-3.2.2.dist-info/METADATA +0 -191
  199. architect_py-3.2.2.dist-info/RECORD +0 -148
  200. /architect_py/{grpc_client → grpc/models}/Marketdata/ArrayOfL1BookSnapshot.py +0 -0
  201. /architect_py/{grpc_client → grpc/models}/Marketdata/L2BookUpdate.py +0 -0
  202. /architect_py/{grpc_client → grpc/models}/Marketdata/TickerUpdate.py +0 -0
  203. /architect_py/{grpc_client → grpc/models}/Orderflow/Dropcopy.py +0 -0
  204. /architect_py/{grpc_client → grpc/models}/Orderflow/Orderflow.py +0 -0
  205. {architect_py-3.2.2.dist-info → architect_py-5.0.0.dist-info/licenses}/LICENSE +0 -0
architect_py/client.py CHANGED
@@ -1,14 +1,12 @@
1
1
  import asyncio
2
-
3
2
  import sys
4
3
  import threading
5
4
  from asyncio import AbstractEventLoop
6
5
  from functools import partial
7
6
  from typing import Any, Awaitable, Callable, Coroutine, Optional, TypeVar
8
7
 
9
- from architect_py.async_client import AsyncClient
10
- from .client_protocol import AsyncClientProtocol
11
-
8
+ from .async_client import AsyncClient
9
+ from .client_interface import ClientProtocol
12
10
 
13
11
  T = TypeVar("T")
14
12
 
@@ -19,7 +17,7 @@ def is_async_function(obj):
19
17
  return callable(obj) and hasattr(obj, "__code__") and obj.__code__.co_flags & 0x80
20
18
 
21
19
 
22
- class Client(AsyncClientProtocol):
20
+ class Client(ClientProtocol):
23
21
  """
24
22
  This class is a wrapper around the AsyncClient class that allows you to call async methods synchronously.
25
23
  This does not work for subscription based methods.
@@ -36,34 +34,36 @@ class Client(AsyncClientProtocol):
36
34
  Instead, add them to the AsyncClient class.
37
35
  """
38
36
 
39
- __slots__ = ("client", "_loop")
37
+ __slots__ = ("client", "_event_loop")
40
38
  client: AsyncClient
41
- _loop: AbstractEventLoop
39
+ _event_loop: AbstractEventLoop
42
40
 
43
41
  def __init__(
44
42
  self,
45
43
  *,
46
- api_key: str,
47
- api_secret: str,
48
- host: str = "app.architect.co",
49
- paper_trading: bool = True,
50
- loop: Optional[AbstractEventLoop] = None,
44
+ api_key: Optional[str] = None,
45
+ api_secret: Optional[str] = None,
46
+ paper_trading: bool,
47
+ endpoint: str = "https://app.architect.co",
48
+ graphql_port: Optional[int] = None,
49
+ event_loop: Optional[AbstractEventLoop] = None,
51
50
  **kwargs,
52
51
  ):
53
- if loop is None:
52
+ if event_loop is None:
54
53
  try:
55
- loop = asyncio.get_running_loop()
54
+ event_loop = asyncio.get_running_loop()
56
55
  except RuntimeError:
57
- loop = asyncio.new_event_loop()
58
- asyncio.set_event_loop(loop)
59
- super().__setattr__("_loop", loop)
56
+ event_loop = asyncio.new_event_loop()
57
+ asyncio.set_event_loop(event_loop)
58
+ super().__setattr__("_event_loop", event_loop)
60
59
 
61
- async_client = loop.run_until_complete(
60
+ async_client = self._event_loop.run_until_complete(
62
61
  AsyncClient.connect(
63
62
  api_key=api_key,
64
63
  api_secret=api_secret,
65
- host=host,
66
64
  paper_trading=paper_trading,
65
+ endpoint=endpoint,
66
+ graphql_port=graphql_port,
67
67
  **kwargs,
68
68
  )
69
69
  )
@@ -128,19 +128,18 @@ class Client(AsyncClientProtocol):
128
128
  ) -> T:
129
129
  return (
130
130
  super()
131
- .__getattribute__("_loop")
131
+ .__getattribute__("_event_loop")
132
132
  .run_until_complete(async_method(*args, **kwargs))
133
133
  )
134
134
 
135
135
 
136
136
  class AsyncExecutor:
137
137
  def __init__(self):
138
- """
139
- one consideration is to enforce this class to be a singleton
140
- however, this is not necessary as the class is only used in the Client class
141
- when it is used in a jupyter notebook, so unlikely to be a problem
142
- """
143
-
138
+ # NB: one consideration is to enforce this class to be a singleton.
139
+ #
140
+ # However, this is not necessary as the class is only used in the
141
+ # Client class when it is used in a jupyter notebook, so its unlikely
142
+ # to be a problem.
144
143
  self.loop = asyncio.new_event_loop()
145
144
  self.thread = threading.Thread(target=self._run_loop, daemon=True)
146
145
  self.thread.start()
@@ -0,0 +1,63 @@
1
+ # fmt: off
2
+
3
+ # mypy: ignore-errors
4
+
5
+ # Autogenerated from generate_sync_interface.py
6
+
7
+ # If you are here for function definitions, please refer to architect_py/async_client.py
8
+ # This file is so that the sync client has good type hinting
9
+ # It is not used for anything else
10
+ # For maintainers: ensure that the types in this file are correct for correct type hinting
11
+
12
+
13
+ from typing import Any, Union
14
+ from .graphql_client import *
15
+ from .async_client import *
16
+ from .grpc.models.definitions import *
17
+ class ClientProtocol:
18
+ def cancel_all_orders(self, account: Optional[str] = None, execution_venue: Optional[str] = None, trader: Optional[str] = None) -> bool: ...
19
+ def cancel_order(self, order_id: str) -> Cancel: ...
20
+ def core(self) -> GrpcClient: ...
21
+ def discover_marketdata(self) -> Any: ...
22
+ def enable_orderflow(self) -> Any: ...
23
+ def get_account_history(self, account: str, from_inclusive: Optional[datetime] = None, to_exclusive: Optional[datetime] = None) -> list[AccountSummary]: ...
24
+ def get_account_summaries(self, accounts: Optional[list[str]] = None, trader: Optional[str] = None) -> list[AccountSummary]: ...
25
+ def get_account_summary(self, account: str) -> AccountSummary: ...
26
+ def get_all_open_orders(self) -> list[Order]: ...
27
+ def get_cme_first_notice_date(self, symbol: str) -> Optional[date]: ...
28
+ def get_cme_future_from_root_month_year(self, root: str, month: int, year: int) -> str: ...
29
+ def get_cme_futures_series(self, series: str) -> list[tuple[date, str]]: ...
30
+ def get_execution_info(self, symbol: Union[TradableProduct, str], execution_venue: str) -> Optional[ExecutionInfoFields]: ...
31
+ def get_execution_infos(self, symbols: Optional[list[Union[TradableProduct, str]]], execution_venue: Optional[str] = None) -> Sequence[ExecutionInfoFields]: ...
32
+ @staticmethod
33
+ def get_expiration_from_CME_name(name: str) -> Optional[date]: ...
34
+ def get_fills(self, from_inclusive: Optional[datetime] = None, to_exclusive: Optional[datetime] = None, venue: Optional[str] = None, account: Optional[str] = None, order_id: Optional[str] = None, limit: Optional[int] = None) -> HistoricalFillsResponse: ...
35
+ def get_future_series(self, series_symbol: str) -> list[str]: ...
36
+ def get_futures_series(self, series_symbol: str) -> list[str]: ...
37
+ def get_historical_candles(self, symbol: Union[TradableProduct, str], venue: str, candle_width: CandleWidth, start: datetime, end: datetime, *, as_dataframe: bool = False) -> Union[list[Candle], pd.DataFrame]: ...
38
+ def get_historical_orders(self, order_ids: Optional[list[str]] = None, from_inclusive: Optional[datetime] = None, to_exclusive: Optional[datetime] = None, venue: Optional[str] = None, account: Optional[str] = None, parent_order_id: Optional[str] = None) -> list[Order]: ...
39
+ def get_l1_book_snapshot(self, symbol: Union[TradableProduct, str], venue: str) -> L1BookSnapshot: ...
40
+ def get_l1_book_snapshots(self, symbols: list[Union[TradableProduct, str]], venue: str) -> Sequence[L1BookSnapshot]: ...
41
+ def get_l2_book_snapshot(self, symbol: Union[TradableProduct, str], venue: str) -> L2BookSnapshot: ...
42
+ def get_market_snapshot(self, symbol: Union[TradableProduct, str], venue: str) -> L1BookSnapshot: ...
43
+ def get_market_snapshots(self, symbols: list[Union[TradableProduct, str]], venue: str) -> Sequence[L1BookSnapshot]: ...
44
+ def get_market_status(self, symbol: Union[TradableProduct, str], venue: str) -> MarketStatus: ...
45
+ def get_open_orders(self, order_ids: Optional[list[str]] = None, venue: Optional[str] = None, account: Optional[str] = None, trader: Optional[str] = None, symbol: Optional[str] = None, parent_order_id: Optional[str] = None) -> list[Order]: ...
46
+ def get_order(self, order_id: str) -> Optional[Order]: ...
47
+ def get_orders(self, order_ids: list[str]) -> list[Optional[Order]]: ...
48
+ def get_product_info(self, symbol: str) -> Optional[ProductInfoFields]: ...
49
+ def get_product_infos(self, symbols: Optional[list[str]]) -> Sequence[ProductInfoFields]: ...
50
+ def get_ticker(self, symbol: Union[TradableProduct, str], venue: str) -> Ticker: ...
51
+ def hmart(self) -> GrpcClient: ...
52
+ def list_accounts(self) -> list[AccountWithPermissions]: ...
53
+ def list_symbols(self, *, marketdata: Optional[str] = None) -> list[str]: ...
54
+ def marketdata(self, venue: str) -> GrpcClient: ...
55
+ def place_limit_order(self, *, id: Optional[str] = None, symbol: Union[TradableProduct, str], execution_venue: Optional[str] = None, dir: Optional[OrderDir] = None, quantity: Decimal, limit_price: Decimal, order_type: OrderType = OrderType.LIMIT, time_in_force: Union[GoodTilDate, TimeInForceEnum] = TimeInForceEnum.DAY, price_round_method: Optional[TickRoundMethod] = None, account: Optional[str] = None, trader: Optional[str] = None, post_only: bool = False, trigger_price: Optional[Decimal] = None, **kwargs: Any) -> Order: ...
56
+ def refresh_jwt(self, force: bool = False) -> Any: ...
57
+ def search_symbols(self, search_string: Optional[str] = None, execution_venue: Optional[str] = None, offset: int = 0, limit: int = 20) -> list[TradableProduct]: ...
58
+ def send_limit_order(self, *args: Any, **kwargs: Any) -> Order: ...
59
+ def send_market_pro_order(self, *, id: Optional[str] = None, symbol: Union[TradableProduct, str], execution_venue: str, odir: OrderDir, quantity: Decimal, time_in_force: Union[GoodTilDate, TimeInForceEnum] = TimeInForceEnum.DAY, account: Optional[str] = None, fraction_through_market: Decimal = Decimal('0.001')) -> Order: ...
60
+ def set_hmart(self, endpoint: str) -> Any: ...
61
+ def set_jwt(self, jwt: Optional[str], jwt_expiration: Optional[datetime] = None) -> Any: ...
62
+ def set_marketdata(self, venue: str, endpoint: str) -> Any: ...
63
+ def who_am_i(self) -> tuple[str, str]: ...
@@ -0,0 +1,6 @@
1
+ from .order_dir import OrderDir
2
+ from .tradable_product import TradableProduct
3
+
4
+ Venue = str
5
+
6
+ __all__ = ["OrderDir", "TradableProduct", "Venue"]
@@ -0,0 +1,91 @@
1
+ from enum import Enum
2
+ from typing import Literal
3
+
4
+
5
+ class OrderDir(str, Enum):
6
+ BUY = "BUY"
7
+ SELL = "SELL"
8
+
9
+ def flip(self) -> "OrderDir":
10
+ """
11
+ Returns the opposite direction.
12
+ """
13
+ if self == OrderDir.BUY:
14
+ return OrderDir.SELL
15
+ elif self == OrderDir.SELL:
16
+ return OrderDir.BUY
17
+ else:
18
+ raise ValueError(f"Unknown Dir: {self}")
19
+
20
+ def get_opposite(self) -> "OrderDir":
21
+ """
22
+ @deprecated(reason="Use flip instead")
23
+ """
24
+ return self.flip()
25
+
26
+ def __int__(self):
27
+ if self == OrderDir.BUY:
28
+ return 1
29
+ elif self == OrderDir.SELL:
30
+ return -1
31
+ else:
32
+ raise ValueError(f"Unknown Dir: {self}")
33
+
34
+ def __str__(self) -> str:
35
+ return self.value
36
+
37
+ def lower(self) -> str:
38
+ return self.value.lower()
39
+
40
+ @classmethod
41
+ def from_string(cls, value: str) -> "OrderDir":
42
+ lower = value.lower()
43
+ if lower == "buy":
44
+ return cls.BUY
45
+ elif lower == "sell":
46
+ return cls.SELL
47
+ elif lower == "bid":
48
+ return cls.BUY
49
+ elif lower == "ask":
50
+ return cls.SELL
51
+ elif lower == "b":
52
+ return cls.BUY
53
+ elif lower == "a" or lower == "s":
54
+ return cls.SELL
55
+ else:
56
+ raise ValueError(f"Unknown Dir: {value}")
57
+
58
+ @classmethod
59
+ def from_unit(cls, value: Literal[1, -1]) -> "OrderDir":
60
+ if value == 1:
61
+ return cls.BUY
62
+ elif value == -1:
63
+ return cls.SELL
64
+ else:
65
+ raise ValueError(f"Unknown Dir: {value}")
66
+
67
+ @classmethod
68
+ def from_sign(cls, value: int) -> "OrderDir":
69
+ if value > 0:
70
+ return cls.BUY
71
+ elif value < 0:
72
+ return cls.SELL
73
+ else:
74
+ raise ValueError(f"Unknown Dir: {value}")
75
+
76
+
77
+ def graphql_serialize_order_dir(value: OrderDir) -> str:
78
+ """
79
+ For ariadne-codegen
80
+ """
81
+ return value.lower()
82
+
83
+
84
+ def graphql_parse_order_dir(value: str) -> OrderDir:
85
+ """
86
+ For ariadne-codegen
87
+ """
88
+ if value == "buy":
89
+ return OrderDir.BUY
90
+ else:
91
+ return OrderDir.SELL
@@ -0,0 +1,25 @@
1
+ from datetime import datetime, timezone
2
+ from typing import TYPE_CHECKING, Optional
3
+
4
+ if TYPE_CHECKING:
5
+ from architect_py.graphql_client.base_model import UnsetType
6
+
7
+
8
+ def convert_datetime_to_utc_str(dt: "Optional[datetime] | UnsetType") -> Optional[str]:
9
+ if not isinstance(dt, datetime):
10
+ return None
11
+
12
+ if dt.tzinfo is None:
13
+ raise ValueError(
14
+ "in a datetime sent to the backend, the good_til_date must be timezone-aware. Try \n"
15
+ "from zoneinfo import ZoneInfo\n"
16
+ "datetime(..., tzinfo={your_local_timezone}) or "
17
+ "datetime.now(tz=ZoneInfo('UTC'))\n"
18
+ "# examples of local timezones:\n"
19
+ "ZoneInfo('America/New_York'), "
20
+ "ZoneInfo('America/Los_Angeles'), ZoneInfo('America/Chicago')"
21
+ )
22
+ utc_str = dt.astimezone(timezone.utc).isoformat()[:-6]
23
+ # [:-6] removes the utc offset
24
+
25
+ return f"{utc_str}Z"
@@ -0,0 +1,59 @@
1
+ from typing import Optional
2
+
3
+
4
+ class TradableProduct(str):
5
+ """
6
+ Example instantiations:
7
+ TradableProduct("ES 20250321 CME Future", "USD")
8
+ TradableProduct("ES 20250321 CME Future/USD")
9
+ (these are equivalent)
10
+
11
+ This type exists to enforce the
12
+ {base}/{quote} format for strings
13
+
14
+ A base is the product that is being priced in terms of the quote.
15
+ For example,
16
+ "ES 20250321 CME Future/USD" means that the ES 20250321 CME Future is priced in USD.
17
+ "ES 20250321 CME Future/EUR" means that the ES 20250321 CME Future is priced in EUR.
18
+ "ES 20250321 CME Future/BTC" means that the ES 20250321 CME Future is priced in BTC
19
+ (such a product does not exist on any exchange though).
20
+
21
+ For example in a currency pair, the base is the first currency and the quote is the second currency.
22
+ In the currency pair USD/EUR, USD is the base and EUR is the quote.
23
+ USD/EUR = 1.1234 means that 1 USD = 1.1234 EUR
24
+ EUR/USD = 0.8901 means that 1 EUR = 0.8901 USD
25
+ """
26
+
27
+ def __new__(
28
+ cls, base_or_value: str, quote: Optional[str] = None
29
+ ) -> "TradableProduct":
30
+ """
31
+ These are equivalent:
32
+ TradableProduct("ES 20250321 CME Future", "USD")
33
+ TradableProduct("ES 20250321 CME Future/USD")
34
+ """
35
+ if quote is None:
36
+ value = base_or_value
37
+ else:
38
+ value = f"{base_or_value}/{quote}"
39
+
40
+ assert "/" in value, (
41
+ f"TradableProduct must be in the form of 'base/quote'. Got: {base_or_value}"
42
+ )
43
+ return super().__new__(cls, value)
44
+
45
+ def base_quote(self) -> list[str]:
46
+ return self.split("/")
47
+
48
+ def base(self) -> str:
49
+ return self.split("/", 1)[0]
50
+
51
+ def quote(self) -> str:
52
+ return self.split("/", 1)[1]
53
+
54
+
55
+ def parse_tradable_product(value: str) -> TradableProduct:
56
+ """
57
+ For ariadne-codegen
58
+ """
59
+ return TradableProduct(value)
@@ -20,6 +20,7 @@ from .enums import (
20
20
  OrderSource,
21
21
  OrderStatus,
22
22
  OrderType,
23
+ PutOrCall,
23
24
  SortTickersBy,
24
25
  TimeInForce,
25
26
  )
@@ -259,6 +260,7 @@ __all__ = [
259
260
  "PlaceOrderMutationOmsPlaceOrder",
260
261
  "ProductInfoFields",
261
262
  "ProductInfoFieldsSpreadLegs",
263
+ "PutOrCall",
262
264
  "SearchSymbolsQuery",
263
265
  "SearchSymbolsQuerySymbology",
264
266
  "SortTickersBy",
@@ -6,12 +6,9 @@ from decimal import Decimal
6
6
  from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, List, Optional, Union
7
7
  from uuid import UUID
8
8
 
9
- from architect_py.scalars import (
10
- OrderDir,
11
- TradableProduct,
12
- convert_datetime_to_utc_str,
13
- graphql_serialize_order_dir,
14
- )
9
+ from architect_py.common_types import OrderDir, TradableProduct
10
+ from architect_py.common_types.order_dir import graphql_serialize_order_dir
11
+ from architect_py.common_types.scalars import convert_datetime_to_utc_str
15
12
 
16
13
  from .base_model import UNSET
17
14
  from .juniper_base_client import JuniperBaseClient
@@ -59,6 +59,11 @@ class OrderType(str, Enum):
59
59
  TAKE_PROFIT_LIMIT = "TAKE_PROFIT_LIMIT"
60
60
 
61
61
 
62
+ class PutOrCall(str, Enum):
63
+ PUT = "PUT"
64
+ CALL = "CALL"
65
+
66
+
62
67
  class SortTickersBy(str, Enum):
63
68
  VOLUME_DESC = "VOLUME_DESC"
64
69
  CHANGE_ASC = "CHANGE_ASC"
@@ -8,12 +8,9 @@ from uuid import UUID
8
8
 
9
9
  from pydantic import BeforeValidator, Field
10
10
 
11
- from architect_py.scalars import (
12
- OrderDir,
13
- TradableProduct,
14
- graphql_parse_order_dir,
15
- parse_tradable_product,
16
- )
11
+ from architect_py.common_types import OrderDir, TradableProduct
12
+ from architect_py.common_types.order_dir import graphql_parse_order_dir
13
+ from architect_py.common_types.tradable_product import parse_tradable_product
17
14
 
18
15
  from .base_model import BaseModel
19
16
  from .enums import (
@@ -8,7 +8,8 @@ from uuid import UUID
8
8
 
9
9
  from pydantic import BeforeValidator, Field
10
10
 
11
- from architect_py.scalars import OrderDir, graphql_parse_order_dir
11
+ from architect_py.common_types import OrderDir
12
+ from architect_py.common_types.order_dir import graphql_parse_order_dir
12
13
 
13
14
  from .base_model import BaseModel
14
15
  from .enums import FillKind
@@ -5,7 +5,8 @@ from typing import Annotated, List
5
5
 
6
6
  from pydantic import BeforeValidator, Field
7
7
 
8
- from architect_py.scalars import TradableProduct, parse_tradable_product
8
+ from architect_py.common_types import TradableProduct
9
+ from architect_py.common_types.tradable_product import parse_tradable_product
9
10
 
10
11
  from .base_model import BaseModel
11
12
 
@@ -8,7 +8,8 @@ from uuid import UUID
8
8
 
9
9
  from pydantic import BeforeValidator, Field
10
10
 
11
- from architect_py.scalars import OrderDir, graphql_parse_order_dir
11
+ from architect_py.common_types import OrderDir
12
+ from architect_py.common_types.order_dir import graphql_parse_order_dir
12
13
 
13
14
  from .base_model import BaseModel
14
15
  from .enums import FillKind
@@ -7,7 +7,8 @@ from typing import Annotated, Optional
7
7
 
8
8
  from pydantic import BeforeValidator
9
9
 
10
- from architect_py.scalars import OrderDir, graphql_parse_order_dir
10
+ from architect_py.common_types import OrderDir
11
+ from architect_py.common_types.order_dir import graphql_parse_order_dir
11
12
 
12
13
  from .base_model import BaseModel
13
14
 
@@ -0,0 +1,145 @@
1
+ from .models.Accounts.AccountsRequest import AccountsRequest
2
+ from .models.Accounts.AccountsResponse import AccountsResponse
3
+ from .models.Auth.CreateJwtRequest import CreateJwtRequest
4
+ from .models.Auth.CreateJwtResponse import CreateJwtResponse
5
+ from .models.Core.ConfigRequest import ConfigRequest
6
+ from .models.Core.ConfigResponse import ConfigResponse
7
+ from .models.Cpty.CptyRequest import CptyRequest
8
+ from .models.Cpty.CptyResponse import CptyResponse
9
+ from .models.Cpty.CptysRequest import CptysRequest
10
+ from .models.Cpty.CptysResponse import CptysResponse
11
+ from .models.Cpty.CptyStatus import CptyStatus
12
+ from .models.Cpty.CptyStatusRequest import CptyStatusRequest
13
+ from .models.definitions import (
14
+ Account,
15
+ AccountIdOrName,
16
+ AccountPosition,
17
+ AccountStatistics,
18
+ AccountWithPermissions,
19
+ CandleWidth,
20
+ L2BookDiff,
21
+ OrderId,
22
+ OrderSource,
23
+ OrderStatus,
24
+ OrderType,
25
+ SortTickersBy,
26
+ TimeInForce,
27
+ TimeInForceEnum,
28
+ TraderIdOrEmail,
29
+ )
30
+ from .models.Folio.AccountHistoryRequest import AccountHistoryRequest
31
+ from .models.Folio.AccountHistoryResponse import AccountHistoryResponse
32
+ from .models.Folio.AccountSummariesRequest import AccountSummariesRequest
33
+ from .models.Folio.AccountSummariesResponse import AccountSummariesResponse
34
+ from .models.Folio.AccountSummary import AccountSummary
35
+ from .models.Folio.AccountSummaryRequest import AccountSummaryRequest
36
+ from .models.Folio.HistoricalFillsRequest import HistoricalFillsRequest
37
+ from .models.Folio.HistoricalFillsResponse import HistoricalFillsResponse
38
+ from .models.Folio.HistoricalOrdersRequest import HistoricalOrdersRequest
39
+ from .models.Folio.HistoricalOrdersResponse import HistoricalOrdersResponse
40
+ from .models.Marketdata.ArrayOfL1BookSnapshot import ArrayOfL1BookSnapshot
41
+ from .models.Marketdata.Candle import Candle
42
+ from .models.Marketdata.HistoricalCandlesRequest import HistoricalCandlesRequest
43
+ from .models.Marketdata.HistoricalCandlesResponse import HistoricalCandlesResponse
44
+ from .models.Marketdata.L1BookSnapshot import L1BookSnapshot
45
+ from .models.Marketdata.L1BookSnapshotRequest import L1BookSnapshotRequest
46
+ from .models.Marketdata.L1BookSnapshotsRequest import L1BookSnapshotsRequest
47
+ from .models.Marketdata.L2BookSnapshot import L2BookSnapshot
48
+ from .models.Marketdata.L2BookSnapshotRequest import L2BookSnapshotRequest
49
+ from .models.Marketdata.L2BookUpdate import L2BookUpdate
50
+ from .models.Marketdata.Liquidation import Liquidation
51
+ from .models.Marketdata.MarketStatus import MarketStatus
52
+ from .models.Marketdata.MarketStatusRequest import MarketStatusRequest
53
+ from .models.Marketdata.SubscribeCandlesRequest import SubscribeCandlesRequest
54
+ from .models.Marketdata.SubscribeCurrentCandlesRequest import (
55
+ SubscribeCurrentCandlesRequest,
56
+ )
57
+ from .models.Marketdata.SubscribeL1BookSnapshotsRequest import (
58
+ SubscribeL1BookSnapshotsRequest,
59
+ )
60
+ from .models.Marketdata.SubscribeL2BookUpdatesRequest import (
61
+ SubscribeL2BookUpdatesRequest,
62
+ )
63
+ from .models.Marketdata.SubscribeLiquidationsRequest import SubscribeLiquidationsRequest
64
+ from .models.Marketdata.SubscribeManyCandlesRequest import SubscribeManyCandlesRequest
65
+ from .models.Marketdata.SubscribeTickersRequest import SubscribeTickersRequest
66
+ from .models.Marketdata.SubscribeTradesRequest import SubscribeTradesRequest
67
+ from .models.Marketdata.Ticker import Ticker
68
+ from .models.Marketdata.TickerRequest import TickerRequest
69
+ from .models.Marketdata.TickersRequest import TickersRequest
70
+ from .models.Marketdata.TickersResponse import TickersResponse
71
+ from .models.Marketdata.TickerUpdate import TickerUpdate
72
+ from .models.Marketdata.Trade import Trade
73
+ from .models.Symbology.SymbolsRequest import SymbolsRequest
74
+ from .models.Symbology.SymbolsResponse import SymbolsResponse
75
+ from .resolve_endpoint import resolve_endpoint
76
+
77
+ __all__ = [
78
+ "Account",
79
+ "AccountHistoryRequest",
80
+ "AccountHistoryResponse",
81
+ "AccountIdOrName",
82
+ "AccountPosition",
83
+ "AccountStatistics",
84
+ "AccountsRequest",
85
+ "AccountsResponse",
86
+ "AccountSummaryRequest",
87
+ "AccountSummary",
88
+ "AccountSummariesRequest",
89
+ "AccountSummariesResponse",
90
+ "AccountWithPermissions",
91
+ "ArrayOfL1BookSnapshot",
92
+ "Candle",
93
+ "CandleWidth",
94
+ "CreateJwtRequest",
95
+ "CreateJwtResponse",
96
+ "ConfigRequest",
97
+ "ConfigResponse",
98
+ "CptyRequest",
99
+ "CptyResponse",
100
+ "CptysRequest",
101
+ "CptysResponse",
102
+ "CptyStatus",
103
+ "CptyStatusRequest",
104
+ "HistoricalFillsRequest",
105
+ "HistoricalFillsResponse",
106
+ "HistoricalOrdersRequest",
107
+ "HistoricalOrdersResponse",
108
+ "HistoricalCandlesRequest",
109
+ "HistoricalCandlesResponse",
110
+ "L1BookSnapshot",
111
+ "L1BookSnapshotRequest",
112
+ "L1BookSnapshotsRequest",
113
+ "L2BookSnapshot",
114
+ "L2BookSnapshotRequest",
115
+ "L2BookUpdate",
116
+ "L2BookDiff",
117
+ "Liquidation",
118
+ "MarketStatus",
119
+ "MarketStatusRequest",
120
+ "OrderId",
121
+ "OrderSource",
122
+ "OrderStatus",
123
+ "OrderType",
124
+ "SortTickersBy",
125
+ "SubscribeCandlesRequest",
126
+ "SubscribeCurrentCandlesRequest",
127
+ "SubscribeL1BookSnapshotsRequest",
128
+ "SubscribeL2BookUpdatesRequest",
129
+ "SubscribeLiquidationsRequest",
130
+ "SubscribeManyCandlesRequest",
131
+ "SubscribeTickersRequest",
132
+ "SubscribeTradesRequest",
133
+ "Ticker",
134
+ "TickerRequest",
135
+ "TickersRequest",
136
+ "TickersResponse",
137
+ "TickerUpdate",
138
+ "TimeInForce",
139
+ "TimeInForceEnum",
140
+ "Trade",
141
+ "TraderIdOrEmail",
142
+ "resolve_endpoint",
143
+ "SymbolsRequest",
144
+ "SymbolsResponse",
145
+ ]