architect-py 3.2.2__py3-none-any.whl → 5.0.0b2__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.
- architect_py/__init__.py +15 -2
- architect_py/async_client.py +1060 -643
- architect_py/client.py +25 -26
- architect_py/client_interface.py +63 -0
- architect_py/common_types/__init__.py +6 -0
- architect_py/common_types/order_dir.py +91 -0
- architect_py/common_types/scalars.py +25 -0
- architect_py/common_types/tradable_product.py +59 -0
- architect_py/graphql_client/__init__.py +2 -0
- architect_py/graphql_client/client.py +3 -6
- architect_py/graphql_client/enums.py +5 -0
- architect_py/graphql_client/fragments.py +3 -6
- architect_py/graphql_client/get_fills_query.py +2 -1
- architect_py/graphql_client/search_symbols_query.py +2 -1
- architect_py/graphql_client/subscribe_orderflow.py +2 -1
- architect_py/graphql_client/subscribe_trades.py +2 -1
- architect_py/grpc/__init__.py +143 -0
- architect_py/grpc/client.py +94 -0
- architect_py/{grpc_client → grpc/models}/Accounts/AccountsRequest.py +6 -3
- architect_py/{grpc_client → grpc/models}/Accounts/AccountsResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Accounts/__init__.py +1 -1
- architect_py/grpc/models/Algo/AlgoOrder.py +114 -0
- architect_py/grpc/models/Algo/AlgoOrderRequest.py +46 -0
- architect_py/grpc/models/Algo/AlgoOrdersRequest.py +72 -0
- architect_py/grpc/models/Algo/AlgoOrdersResponse.py +27 -0
- architect_py/grpc/models/Algo/CreateAlgoOrderRequest.py +56 -0
- architect_py/grpc/models/Algo/PauseAlgoRequest.py +42 -0
- architect_py/grpc/models/Algo/PauseAlgoResponse.py +20 -0
- architect_py/grpc/models/Algo/StartAlgoRequest.py +42 -0
- architect_py/grpc/models/Algo/StartAlgoResponse.py +20 -0
- architect_py/grpc/models/Algo/StopAlgoRequest.py +42 -0
- architect_py/grpc/models/Algo/StopAlgoResponse.py +20 -0
- architect_py/{grpc_client → grpc/models}/Algo/__init__.py +1 -1
- architect_py/grpc/models/Auth/CreateJwtRequest.py +47 -0
- architect_py/grpc/models/Auth/CreateJwtResponse.py +23 -0
- architect_py/{grpc_client/Cpty → grpc/models/Auth}/__init__.py +1 -1
- architect_py/grpc/models/Boss/DepositsRequest.py +40 -0
- architect_py/grpc/models/Boss/DepositsResponse.py +27 -0
- architect_py/grpc/models/Boss/RqdAccountStatisticsRequest.py +42 -0
- architect_py/grpc/models/Boss/RqdAccountStatisticsResponse.py +25 -0
- architect_py/grpc/models/Boss/StatementUrlRequest.py +40 -0
- architect_py/grpc/models/Boss/StatementUrlResponse.py +23 -0
- architect_py/grpc/models/Boss/StatementsRequest.py +40 -0
- architect_py/grpc/models/Boss/StatementsResponse.py +27 -0
- architect_py/grpc/models/Boss/WithdrawalsRequest.py +40 -0
- architect_py/grpc/models/Boss/WithdrawalsResponse.py +27 -0
- architect_py/{grpc_client/Folio → grpc/models/Boss}/__init__.py +1 -1
- architect_py/grpc/models/Core/ConfigRequest.py +37 -0
- architect_py/grpc/models/Core/ConfigResponse.py +25 -0
- architect_py/grpc/models/Core/__init__.py +2 -0
- architect_py/{grpc_client → grpc/models}/Cpty/CptyRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Cpty/CptyResponse.py +3 -3
- architect_py/{grpc_client → grpc/models}/Cpty/CptyStatus.py +1 -1
- architect_py/{grpc_client → grpc/models}/Cpty/CptyStatusRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Cpty/CptysRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Cpty/CptysResponse.py +1 -1
- architect_py/grpc/models/Cpty/__init__.py +2 -0
- architect_py/{grpc_client → grpc/models}/Folio/AccountHistoryRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Folio/AccountHistoryResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Folio/AccountSummariesRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Folio/AccountSummariesResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Folio/AccountSummary.py +1 -1
- architect_py/{grpc_client → grpc/models}/Folio/AccountSummaryRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Folio/HistoricalFillsRequest.py +7 -4
- architect_py/{grpc_client → grpc/models}/Folio/HistoricalFillsResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Folio/HistoricalOrdersRequest.py +3 -3
- architect_py/{grpc_client → grpc/models}/Folio/HistoricalOrdersResponse.py +1 -1
- architect_py/grpc/models/Folio/__init__.py +2 -0
- architect_py/{grpc_client → grpc/models}/Health/HealthCheckRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Health/HealthCheckResponse.py +1 -1
- architect_py/grpc/models/Health/__init__.py +2 -0
- architect_py/{grpc_client → grpc/models}/Marketdata/Candle.py +1 -1
- architect_py/{grpc_client → grpc/models}/Marketdata/HistoricalCandlesRequest.py +11 -8
- architect_py/{grpc_client → grpc/models}/Marketdata/HistoricalCandlesResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Marketdata/L1BookSnapshot.py +52 -5
- architect_py/{grpc_client → grpc/models}/Marketdata/L1BookSnapshotRequest.py +8 -3
- architect_py/{grpc_client → grpc/models}/Marketdata/L1BookSnapshotsRequest.py +6 -3
- architect_py/{grpc_client → grpc/models}/Marketdata/L2BookSnapshot.py +1 -1
- architect_py/{grpc_client → grpc/models}/Marketdata/L2BookSnapshotRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/Liquidation.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/MarketStatus.py +1 -1
- architect_py/{grpc_client → grpc/models}/Marketdata/MarketStatusRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeCandlesRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeCurrentCandlesRequest.py +3 -4
- architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeL1BookSnapshotsRequest.py +6 -3
- architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeL2BookUpdatesRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeLiquidationsRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeManyCandlesRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeTickersRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/SubscribeTradesRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/Ticker.py +1 -1
- architect_py/{grpc_client → grpc/models}/Marketdata/TickerRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/TickersRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Marketdata/TickersResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Marketdata/Trade.py +2 -2
- architect_py/grpc/models/Marketdata/__init__.py +2 -0
- architect_py/grpc/models/Oms/Cancel.py +90 -0
- architect_py/{grpc_client → grpc/models}/Oms/CancelAllOrdersRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Oms/CancelAllOrdersResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Oms/CancelOrderRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Oms/OpenOrdersRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Oms/OpenOrdersResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Oms/Order.py +6 -13
- architect_py/{grpc_client → grpc/models}/Oms/PendingCancelsRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Oms/PendingCancelsResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Oms/PlaceOrderRequest.py +16 -23
- architect_py/grpc/models/Oms/__init__.py +2 -0
- architect_py/grpc/models/OptionsMarketdata/OptionsChain.py +30 -0
- architect_py/grpc/models/OptionsMarketdata/OptionsChainGreeks.py +30 -0
- architect_py/grpc/models/OptionsMarketdata/OptionsChainGreeksRequest.py +47 -0
- architect_py/grpc/models/OptionsMarketdata/OptionsChainRequest.py +45 -0
- architect_py/grpc/models/OptionsMarketdata/OptionsExpirations.py +29 -0
- architect_py/grpc/models/OptionsMarketdata/OptionsExpirationsRequest.py +42 -0
- architect_py/grpc/models/OptionsMarketdata/__init__.py +2 -0
- architect_py/{grpc_client → grpc/models}/Orderflow/DropcopyRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Orderflow/OrderflowRequest.py +1 -1
- architect_py/{grpc_client → grpc/models}/Orderflow/SubscribeOrderflowRequest.py +2 -2
- architect_py/grpc/models/Orderflow/__init__.py +2 -0
- architect_py/grpc/models/Symbology/DownloadProductCatalogRequest.py +42 -0
- architect_py/grpc/models/Symbology/DownloadProductCatalogResponse.py +27 -0
- architect_py/grpc/models/Symbology/ExecutionInfoRequest.py +47 -0
- architect_py/grpc/models/Symbology/ExecutionInfoResponse.py +27 -0
- architect_py/{grpc_client → grpc/models}/Symbology/PruneExpiredSymbolsRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Symbology/PruneExpiredSymbolsResponse.py +1 -1
- architect_py/{grpc_client → grpc/models}/Symbology/SubscribeSymbology.py +1 -1
- architect_py/{grpc_client → grpc/models}/Symbology/SymbologyRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Symbology/SymbologySnapshot.py +7 -2
- architect_py/{grpc_client → grpc/models}/Symbology/SymbologyUpdate.py +9 -2
- architect_py/{grpc_client → grpc/models}/Symbology/SymbolsRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Symbology/SymbolsResponse.py +1 -1
- architect_py/grpc/models/Symbology/UploadProductCatalogRequest.py +49 -0
- architect_py/grpc/models/Symbology/UploadProductCatalogResponse.py +20 -0
- architect_py/{grpc_client → grpc/models}/Symbology/UploadSymbologyRequest.py +2 -2
- architect_py/{grpc_client → grpc/models}/Symbology/UploadSymbologyResponse.py +1 -1
- architect_py/grpc/models/Symbology/__init__.py +2 -0
- architect_py/grpc/models/__init__.py +2 -0
- architect_py/{grpc_client → grpc/models}/definitions.py +690 -841
- architect_py/grpc/resolve_endpoint.py +70 -0
- architect_py/{grpc_client/grpc_server.py → grpc/server.py} +9 -6
- architect_py/grpc/utils.py +32 -0
- architect_py/internal_utils/__init__.py +0 -0
- architect_py/internal_utils/no_pandas.py +3 -0
- architect_py/tests/conftest.py +91 -87
- architect_py/tests/test_book_building.py +49 -50
- architect_py/tests/test_marketdata.py +168 -0
- architect_py/tests/test_order_entry.py +37 -0
- architect_py/tests/test_orderflow.py +41 -0
- architect_py/tests/test_portfolio_management.py +23 -0
- architect_py/tests/test_rounding.py +28 -28
- architect_py/tests/test_symbology.py +37 -30
- architect_py/utils/nearest_tick.py +2 -5
- architect_py/utils/nearest_tick_2.py +1 -2
- architect_py/utils/orderbook.py +35 -0
- architect_py/utils/pandas.py +44 -0
- architect_py/utils/price_bands.py +0 -3
- architect_py/utils/symbol_parsing.py +29 -0
- architect_py-5.0.0b2.dist-info/METADATA +123 -0
- architect_py-5.0.0b2.dist-info/RECORD +214 -0
- {architect_py-3.2.2.dist-info → architect_py-5.0.0b2.dist-info}/WHEEL +2 -1
- architect_py-5.0.0b2.dist-info/top_level.txt +4 -0
- examples/__init__.py +0 -0
- examples/book_subscription.py +52 -0
- examples/candles.py +30 -0
- examples/common.py +116 -0
- examples/external_cpty.py +77 -0
- examples/funding_rate_mean_reversion_algo.py +186 -0
- examples/order_sending.py +91 -0
- examples/stream_l1_marketdata.py +25 -0
- examples/stream_l2_marketdata.py +38 -0
- examples/trades.py +21 -0
- examples/tutorial_async.py +86 -0
- examples/tutorial_sync.py +95 -0
- scripts/generate_functions_md.py +166 -0
- scripts/generate_sync_interface.py +226 -0
- scripts/postprocess_grpc.py +604 -0
- scripts/preprocess_grpc_schema.py +708 -0
- templates/exceptions.py +83 -0
- templates/juniper_base_client.py +371 -0
- architect_py/client_protocol.py +0 -53
- architect_py/grpc_client/Algo/AlgoOrderForTwapAlgo.py +0 -61
- architect_py/grpc_client/Algo/CreateAlgoOrderRequestForTwapAlgo.py +0 -59
- architect_py/grpc_client/Algo/ModifyAlgoOrderRequestForTwapAlgo.py +0 -45
- architect_py/grpc_client/Health/__init__.py +0 -2
- architect_py/grpc_client/Marketdata/__init__.py +0 -2
- architect_py/grpc_client/Oms/Cancel.py +0 -42
- architect_py/grpc_client/Oms/__init__.py +0 -2
- architect_py/grpc_client/Orderflow/__init__.py +0 -2
- architect_py/grpc_client/Symbology/__init__.py +0 -2
- architect_py/grpc_client/__init__.py +0 -2
- architect_py/grpc_client/grpc_client.py +0 -413
- architect_py/scalars.py +0 -172
- architect_py/tests/test_accounts.py +0 -31
- architect_py/tests/test_client.py +0 -29
- architect_py/tests/test_grpc_client.py +0 -30
- architect_py/tests/test_order_sending.py +0 -65
- architect_py/tests/test_snapshots.py +0 -52
- architect_py/tests/test_subscriptions.py +0 -126
- architect_py-3.2.2.dist-info/METADATA +0 -191
- architect_py-3.2.2.dist-info/RECORD +0 -148
- /architect_py/{grpc_client → grpc/models}/Marketdata/ArrayOfL1BookSnapshot.py +0 -0
- /architect_py/{grpc_client → grpc/models}/Marketdata/L2BookUpdate.py +0 -0
- /architect_py/{grpc_client → grpc/models}/Marketdata/TickerUpdate.py +0 -0
- /architect_py/{grpc_client → grpc/models}/Orderflow/Dropcopy.py +0 -0
- /architect_py/{grpc_client → grpc/models}/Orderflow/Orderflow.py +0 -0
- {architect_py-3.2.2.dist-info → architect_py-5.0.0b2.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
|
10
|
-
from .
|
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(
|
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", "
|
37
|
+
__slots__ = ("client", "_event_loop")
|
40
38
|
client: AsyncClient
|
41
|
-
|
39
|
+
_event_loop: AbstractEventLoop
|
42
40
|
|
43
41
|
def __init__(
|
44
42
|
self,
|
45
43
|
*,
|
46
|
-
api_key: str,
|
47
|
-
api_secret: str,
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
52
|
+
if event_loop is None:
|
54
53
|
try:
|
55
|
-
|
54
|
+
event_loop = asyncio.get_running_loop()
|
56
55
|
except RuntimeError:
|
57
|
-
|
58
|
-
asyncio.set_event_loop(
|
59
|
-
super().__setattr__("
|
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 =
|
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__("
|
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
|
-
|
140
|
-
|
141
|
-
when it is used in a jupyter notebook, so unlikely
|
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[TradableProduct]], 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,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.
|
10
|
-
|
11
|
-
|
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
|
@@ -8,12 +8,9 @@ from uuid import UUID
|
|
8
8
|
|
9
9
|
from pydantic import BeforeValidator, Field
|
10
10
|
|
11
|
-
from architect_py.
|
12
|
-
|
13
|
-
|
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.
|
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.
|
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.
|
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.
|
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,143 @@
|
|
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
|
+
OrderType,
|
24
|
+
SortTickersBy,
|
25
|
+
TimeInForce,
|
26
|
+
TimeInForceEnum,
|
27
|
+
TraderIdOrEmail,
|
28
|
+
)
|
29
|
+
from .models.Folio.AccountHistoryRequest import AccountHistoryRequest
|
30
|
+
from .models.Folio.AccountHistoryResponse import AccountHistoryResponse
|
31
|
+
from .models.Folio.AccountSummariesRequest import AccountSummariesRequest
|
32
|
+
from .models.Folio.AccountSummariesResponse import AccountSummariesResponse
|
33
|
+
from .models.Folio.AccountSummary import AccountSummary
|
34
|
+
from .models.Folio.AccountSummaryRequest import AccountSummaryRequest
|
35
|
+
from .models.Folio.HistoricalFillsRequest import HistoricalFillsRequest
|
36
|
+
from .models.Folio.HistoricalFillsResponse import HistoricalFillsResponse
|
37
|
+
from .models.Folio.HistoricalOrdersRequest import HistoricalOrdersRequest
|
38
|
+
from .models.Folio.HistoricalOrdersResponse import HistoricalOrdersResponse
|
39
|
+
from .models.Marketdata.ArrayOfL1BookSnapshot import ArrayOfL1BookSnapshot
|
40
|
+
from .models.Marketdata.Candle import Candle
|
41
|
+
from .models.Marketdata.HistoricalCandlesRequest import HistoricalCandlesRequest
|
42
|
+
from .models.Marketdata.HistoricalCandlesResponse import HistoricalCandlesResponse
|
43
|
+
from .models.Marketdata.L1BookSnapshot import L1BookSnapshot
|
44
|
+
from .models.Marketdata.L1BookSnapshotRequest import L1BookSnapshotRequest
|
45
|
+
from .models.Marketdata.L1BookSnapshotsRequest import L1BookSnapshotsRequest
|
46
|
+
from .models.Marketdata.L2BookSnapshot import L2BookSnapshot
|
47
|
+
from .models.Marketdata.L2BookSnapshotRequest import L2BookSnapshotRequest
|
48
|
+
from .models.Marketdata.L2BookUpdate import L2BookUpdate
|
49
|
+
from .models.Marketdata.Liquidation import Liquidation
|
50
|
+
from .models.Marketdata.MarketStatus import MarketStatus
|
51
|
+
from .models.Marketdata.MarketStatusRequest import MarketStatusRequest
|
52
|
+
from .models.Marketdata.SubscribeCandlesRequest import SubscribeCandlesRequest
|
53
|
+
from .models.Marketdata.SubscribeCurrentCandlesRequest import (
|
54
|
+
SubscribeCurrentCandlesRequest,
|
55
|
+
)
|
56
|
+
from .models.Marketdata.SubscribeL1BookSnapshotsRequest import (
|
57
|
+
SubscribeL1BookSnapshotsRequest,
|
58
|
+
)
|
59
|
+
from .models.Marketdata.SubscribeL2BookUpdatesRequest import (
|
60
|
+
SubscribeL2BookUpdatesRequest,
|
61
|
+
)
|
62
|
+
from .models.Marketdata.SubscribeLiquidationsRequest import SubscribeLiquidationsRequest
|
63
|
+
from .models.Marketdata.SubscribeManyCandlesRequest import SubscribeManyCandlesRequest
|
64
|
+
from .models.Marketdata.SubscribeTickersRequest import SubscribeTickersRequest
|
65
|
+
from .models.Marketdata.SubscribeTradesRequest import SubscribeTradesRequest
|
66
|
+
from .models.Marketdata.Ticker import Ticker
|
67
|
+
from .models.Marketdata.TickerRequest import TickerRequest
|
68
|
+
from .models.Marketdata.TickersRequest import TickersRequest
|
69
|
+
from .models.Marketdata.TickersResponse import TickersResponse
|
70
|
+
from .models.Marketdata.TickerUpdate import TickerUpdate
|
71
|
+
from .models.Marketdata.Trade import Trade
|
72
|
+
from .models.Symbology.SymbolsRequest import SymbolsRequest
|
73
|
+
from .models.Symbology.SymbolsResponse import SymbolsResponse
|
74
|
+
from .resolve_endpoint import resolve_endpoint
|
75
|
+
|
76
|
+
__all__ = [
|
77
|
+
"Account",
|
78
|
+
"AccountHistoryRequest",
|
79
|
+
"AccountHistoryResponse",
|
80
|
+
"AccountIdOrName",
|
81
|
+
"AccountPosition",
|
82
|
+
"AccountStatistics",
|
83
|
+
"AccountsRequest",
|
84
|
+
"AccountsResponse",
|
85
|
+
"AccountSummaryRequest",
|
86
|
+
"AccountSummary",
|
87
|
+
"AccountSummariesRequest",
|
88
|
+
"AccountSummariesResponse",
|
89
|
+
"AccountWithPermissions",
|
90
|
+
"ArrayOfL1BookSnapshot",
|
91
|
+
"Candle",
|
92
|
+
"CandleWidth",
|
93
|
+
"CreateJwtRequest",
|
94
|
+
"CreateJwtResponse",
|
95
|
+
"ConfigRequest",
|
96
|
+
"ConfigResponse",
|
97
|
+
"CptyRequest",
|
98
|
+
"CptyResponse",
|
99
|
+
"CptysRequest",
|
100
|
+
"CptysResponse",
|
101
|
+
"CptyStatus",
|
102
|
+
"CptyStatusRequest",
|
103
|
+
"HistoricalFillsRequest",
|
104
|
+
"HistoricalFillsResponse",
|
105
|
+
"HistoricalOrdersRequest",
|
106
|
+
"HistoricalOrdersResponse",
|
107
|
+
"HistoricalCandlesRequest",
|
108
|
+
"HistoricalCandlesResponse",
|
109
|
+
"L1BookSnapshot",
|
110
|
+
"L1BookSnapshotRequest",
|
111
|
+
"L1BookSnapshotsRequest",
|
112
|
+
"L2BookSnapshot",
|
113
|
+
"L2BookSnapshotRequest",
|
114
|
+
"L2BookUpdate",
|
115
|
+
"L2BookDiff",
|
116
|
+
"Liquidation",
|
117
|
+
"MarketStatus",
|
118
|
+
"MarketStatusRequest",
|
119
|
+
"OrderId",
|
120
|
+
"OrderSource",
|
121
|
+
"OrderType",
|
122
|
+
"SortTickersBy",
|
123
|
+
"SubscribeCandlesRequest",
|
124
|
+
"SubscribeCurrentCandlesRequest",
|
125
|
+
"SubscribeL1BookSnapshotsRequest",
|
126
|
+
"SubscribeL2BookUpdatesRequest",
|
127
|
+
"SubscribeLiquidationsRequest",
|
128
|
+
"SubscribeManyCandlesRequest",
|
129
|
+
"SubscribeTickersRequest",
|
130
|
+
"SubscribeTradesRequest",
|
131
|
+
"Ticker",
|
132
|
+
"TickerRequest",
|
133
|
+
"TickersRequest",
|
134
|
+
"TickersResponse",
|
135
|
+
"TickerUpdate",
|
136
|
+
"TimeInForce",
|
137
|
+
"TimeInForceEnum",
|
138
|
+
"Trade",
|
139
|
+
"TraderIdOrEmail",
|
140
|
+
"resolve_endpoint",
|
141
|
+
"SymbolsRequest",
|
142
|
+
"SymbolsResponse",
|
143
|
+
]
|