architect-py 5.0.0b3__py3-none-any.whl → 5.1.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.
- architect_py/__init__.py +432 -5
- architect_py/async_client.py +77 -43
- architect_py/client.py +11 -4
- architect_py/client.pyi +504 -0
- architect_py/common_types/__init__.py +2 -1
- architect_py/common_types/time_in_force.py +94 -0
- architect_py/common_types/tradable_product.py +9 -0
- architect_py/graphql_client/__init__.py +1 -216
- architect_py/graphql_client/client.py +2 -1043
- architect_py/graphql_client/enums.py +0 -72
- architect_py/graphql_client/fragments.py +4 -152
- architect_py/grpc/__init__.py +0 -143
- architect_py/grpc/client.py +6 -1
- architect_py/grpc/models/Core/RestartCptyRequest.py +40 -0
- architect_py/grpc/models/Core/RestartCptyResponse.py +20 -0
- architect_py/grpc/models/Marketdata/Liquidation.py +0 -1
- architect_py/grpc/models/Marketdata/Ticker.py +14 -1
- architect_py/grpc/models/Marketdata/TickersRequest.py +38 -12
- architect_py/grpc/models/Marketdata/Trade.py +0 -1
- architect_py/grpc/models/Oms/Order.py +33 -24
- architect_py/grpc/models/Oms/PlaceOrderRequest.py +33 -24
- architect_py/grpc/models/__init__.py +113 -2
- architect_py/grpc/models/definitions.py +2 -32
- architect_py/grpc/utils.py +1 -4
- architect_py/tests/test_order_entry.py +2 -3
- architect_py/tests/test_orderflow.py +1 -1
- architect_py/utils/pandas.py +4 -3
- architect_py-5.1.0.dist-info/METADATA +66 -0
- {architect_py-5.0.0b3.dist-info → architect_py-5.1.0.dist-info}/RECORD +48 -67
- {architect_py-5.0.0b3.dist-info → architect_py-5.1.0.dist-info}/WHEEL +1 -1
- examples/book_subscription.py +1 -2
- examples/candles.py +1 -3
- examples/common.py +1 -2
- examples/external_cpty.py +2 -2
- examples/funding_rate_mean_reversion_algo.py +9 -6
- examples/order_sending.py +29 -9
- examples/stream_l1_marketdata.py +1 -2
- examples/stream_l2_marketdata.py +1 -2
- examples/trades.py +1 -2
- examples/tutorial_async.py +6 -8
- examples/tutorial_sync.py +6 -7
- scripts/add_imports_to_inits.py +146 -0
- scripts/correct_sync_interface.py +143 -0
- scripts/postprocess_grpc.py +57 -11
- scripts/preprocess_grpc_schema.py +2 -0
- scripts/prune_graphql_schema.py +187 -0
- architect_py/client_interface.py +0 -63
- architect_py/common_types/scalars.py +0 -25
- architect_py/graphql_client/cancel_all_orders_mutation.py +0 -17
- architect_py/graphql_client/cancel_order_mutation.py +0 -23
- architect_py/graphql_client/create_jwt.py +0 -17
- architect_py/graphql_client/get_account_history_query.py +0 -27
- architect_py/graphql_client/get_account_query.py +0 -23
- architect_py/graphql_client/get_account_summaries_query.py +0 -27
- architect_py/graphql_client/get_account_summary_query.py +0 -25
- architect_py/graphql_client/get_candle_snapshot_query.py +0 -27
- architect_py/graphql_client/get_fills_query.py +0 -69
- architect_py/graphql_client/get_historical_orders_query.py +0 -27
- architect_py/graphql_client/get_l_1_book_snapshot_query.py +0 -21
- architect_py/graphql_client/get_l_1_book_snapshots_query.py +0 -23
- architect_py/graphql_client/get_l_2_book_snapshot_query.py +0 -25
- architect_py/graphql_client/get_market_status_query.py +0 -25
- architect_py/graphql_client/get_open_orders_query.py +0 -25
- architect_py/graphql_client/list_accounts_query.py +0 -23
- architect_py/graphql_client/place_order_mutation.py +0 -23
- architect_py/graphql_client/subscribe_candles.py +0 -16
- architect_py/graphql_client/subscribe_orderflow.py +0 -100
- architect_py/graphql_client/subscribe_trades.py +0 -27
- architect_py/graphql_client/user_email_query.py +0 -17
- architect_py/internal_utils/__init__.py +0 -0
- architect_py/internal_utils/no_pandas.py +0 -3
- architect_py-5.0.0b3.dist-info/METADATA +0 -123
- scripts/generate_sync_interface.py +0 -226
- {architect_py-5.0.0b3.dist-info → architect_py-5.1.0.dist-info}/licenses/LICENSE +0 -0
- {architect_py-5.0.0b3.dist-info → architect_py-5.1.0.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@
|
|
2
2
|
# filename: Oms/Order.json
|
3
3
|
|
4
4
|
from __future__ import annotations
|
5
|
-
from architect_py.common_types import OrderDir
|
5
|
+
from architect_py.common_types import OrderDir, TimeInForce
|
6
6
|
|
7
7
|
from decimal import Decimal
|
8
8
|
from typing import Annotated, Optional
|
@@ -20,13 +20,12 @@ class Order(Struct, omit_defaults=True):
|
|
20
20
|
q: Annotated[Decimal, Meta(title="quantity")]
|
21
21
|
s: Annotated[str, Meta(title="symbol")]
|
22
22
|
src: Annotated[definitions.OrderSource, Meta(title="source")]
|
23
|
-
tif: Annotated[
|
23
|
+
tif: Annotated[TimeInForce, Meta(title="time_in_force")]
|
24
24
|
tn: Annotated[int, Meta(ge=0, title="recv_time_ns")]
|
25
25
|
ts: Annotated[int, Meta(title="recv_time")]
|
26
26
|
u: Annotated[definitions.UserId, Meta(title="trader")]
|
27
27
|
ve: Annotated[str, Meta(title="execution_venue")]
|
28
28
|
xq: Annotated[Decimal, Meta(title="filled_quantity")]
|
29
|
-
p: Annotated[Decimal, Meta(title="limit_price")]
|
30
29
|
k: Annotated[definitions.OrderType, Meta(title="order_type")]
|
31
30
|
eid: Optional[Annotated[Optional[str], Meta(title="exchange_order_id")]] = None
|
32
31
|
pid: Optional[Annotated[Optional[definitions.OrderId], Meta(title="parent_id")]] = (
|
@@ -38,6 +37,7 @@ class Order(Struct, omit_defaults=True):
|
|
38
37
|
rm: Optional[Annotated[Optional[str], Meta(title="reject_message")]] = None
|
39
38
|
ss: Optional[Annotated[Optional[bool], Meta(title="is_short_sale")]] = None
|
40
39
|
xp: Optional[Annotated[Optional[Decimal], Meta(title="average_fill_price")]] = None
|
40
|
+
p: Optional[Annotated[Decimal, Meta(title="limit_price")]] = None
|
41
41
|
po: Optional[Annotated[bool, Meta(title="post_only")]] = None
|
42
42
|
tp: Optional[Annotated[Decimal, Meta(title="trigger_price")]] = None
|
43
43
|
|
@@ -52,13 +52,12 @@ class Order(Struct, omit_defaults=True):
|
|
52
52
|
quantity: Decimal,
|
53
53
|
symbol: str,
|
54
54
|
source: definitions.OrderSource,
|
55
|
-
time_in_force:
|
55
|
+
time_in_force: TimeInForce,
|
56
56
|
recv_time_ns: int,
|
57
57
|
recv_time: int,
|
58
58
|
trader: definitions.UserId,
|
59
59
|
execution_venue: str,
|
60
60
|
filled_quantity: Decimal,
|
61
|
-
limit_price: Decimal,
|
62
61
|
order_type: definitions.OrderType,
|
63
62
|
exchange_order_id: Optional[str] = None,
|
64
63
|
parent_id: Optional[definitions.OrderId] = None,
|
@@ -66,6 +65,7 @@ class Order(Struct, omit_defaults=True):
|
|
66
65
|
reject_message: Optional[str] = None,
|
67
66
|
is_short_sale: Optional[bool] = None,
|
68
67
|
average_fill_price: Optional[Decimal] = None,
|
68
|
+
limit_price: Optional[Decimal] = None,
|
69
69
|
post_only: Optional[bool] = None,
|
70
70
|
trigger_price: Optional[Decimal] = None,
|
71
71
|
):
|
@@ -83,7 +83,6 @@ class Order(Struct, omit_defaults=True):
|
|
83
83
|
trader,
|
84
84
|
execution_venue,
|
85
85
|
filled_quantity,
|
86
|
-
limit_price,
|
87
86
|
order_type,
|
88
87
|
exchange_order_id,
|
89
88
|
parent_id,
|
@@ -91,12 +90,13 @@ class Order(Struct, omit_defaults=True):
|
|
91
90
|
reject_message,
|
92
91
|
is_short_sale,
|
93
92
|
average_fill_price,
|
93
|
+
limit_price,
|
94
94
|
post_only,
|
95
95
|
trigger_price,
|
96
96
|
)
|
97
97
|
|
98
98
|
def __str__(self) -> str:
|
99
|
-
return f"Order(account={self.a},dir={self.d},id={self.id},status={self.o},quantity={self.q},symbol={self.s},source={self.src},time_in_force={self.tif},recv_time_ns={self.tn},recv_time={self.ts},trader={self.u},execution_venue={self.ve},filled_quantity={self.xq},
|
99
|
+
return f"Order(account={self.a},dir={self.d},id={self.id},status={self.o},quantity={self.q},symbol={self.s},source={self.src},time_in_force={self.tif},recv_time_ns={self.tn},recv_time={self.ts},trader={self.u},execution_venue={self.ve},filled_quantity={self.xq},order_type={self.k},exchange_order_id={self.eid},parent_id={self.pid},reject_reason={self.r},reject_message={self.rm},is_short_sale={self.ss},average_fill_price={self.xp},limit_price={self.p},post_only={self.po},trigger_price={self.tp})"
|
100
100
|
|
101
101
|
@property
|
102
102
|
def account(self) -> str:
|
@@ -147,11 +147,11 @@ class Order(Struct, omit_defaults=True):
|
|
147
147
|
self.src = value
|
148
148
|
|
149
149
|
@property
|
150
|
-
def time_in_force(self) ->
|
150
|
+
def time_in_force(self) -> TimeInForce:
|
151
151
|
return self.tif
|
152
152
|
|
153
153
|
@time_in_force.setter
|
154
|
-
def time_in_force(self, value:
|
154
|
+
def time_in_force(self, value: TimeInForce) -> None:
|
155
155
|
self.tif = value
|
156
156
|
|
157
157
|
@property
|
@@ -194,14 +194,6 @@ class Order(Struct, omit_defaults=True):
|
|
194
194
|
def filled_quantity(self, value: Decimal) -> None:
|
195
195
|
self.xq = value
|
196
196
|
|
197
|
-
@property
|
198
|
-
def limit_price(self) -> Decimal:
|
199
|
-
return self.p
|
200
|
-
|
201
|
-
@limit_price.setter
|
202
|
-
def limit_price(self, value: Decimal) -> None:
|
203
|
-
self.p = value
|
204
|
-
|
205
197
|
@property
|
206
198
|
def order_type(self) -> definitions.OrderType:
|
207
199
|
return self.k
|
@@ -258,6 +250,14 @@ class Order(Struct, omit_defaults=True):
|
|
258
250
|
def average_fill_price(self, value: Optional[Decimal]) -> None:
|
259
251
|
self.xp = value
|
260
252
|
|
253
|
+
@property
|
254
|
+
def limit_price(self) -> Optional[Decimal]:
|
255
|
+
return self.p
|
256
|
+
|
257
|
+
@limit_price.setter
|
258
|
+
def limit_price(self, value: Optional[Decimal]) -> None:
|
259
|
+
self.p = value
|
260
|
+
|
261
261
|
@property
|
262
262
|
def post_only(self) -> Optional[bool]:
|
263
263
|
return self.po
|
@@ -275,28 +275,37 @@ class Order(Struct, omit_defaults=True):
|
|
275
275
|
self.tp = value
|
276
276
|
|
277
277
|
def __post_init__(self):
|
278
|
-
if self.k == "
|
279
|
-
if not all(getattr(self, key) is not None for key in [
|
278
|
+
if self.k == "MARKET":
|
279
|
+
if not all(getattr(self, key) is not None for key in []):
|
280
|
+
raise ValueError(
|
281
|
+
f"When field k (order_type) is of value MARKET, class Order requires fields []"
|
282
|
+
)
|
283
|
+
elif any(getattr(self, key) is not None for key in ["p", "po", "tp"]):
|
284
|
+
raise ValueError(
|
285
|
+
f"When field k (order_type) is of value MARKET, class Order should not have fields ['p', 'po', 'tp']"
|
286
|
+
)
|
287
|
+
elif self.k == "LIMIT":
|
288
|
+
if not all(getattr(self, key) is not None for key in ["p", "po"]):
|
280
289
|
raise ValueError(
|
281
|
-
f"When field k (order_type) is of value LIMIT, class Order requires fields ['po']"
|
290
|
+
f"When field k (order_type) is of value LIMIT, class Order requires fields ['p', 'po']"
|
282
291
|
)
|
283
292
|
elif any(getattr(self, key) is not None for key in ["tp"]):
|
284
293
|
raise ValueError(
|
285
294
|
f"When field k (order_type) is of value LIMIT, class Order should not have fields ['tp']"
|
286
295
|
)
|
287
296
|
elif self.k == "STOP_LOSS_LIMIT":
|
288
|
-
if not all(getattr(self, key) is not None for key in ["tp"]):
|
297
|
+
if not all(getattr(self, key) is not None for key in ["p", "tp"]):
|
289
298
|
raise ValueError(
|
290
|
-
f"When field k (order_type) is of value STOP_LOSS_LIMIT, class Order requires fields ['tp']"
|
299
|
+
f"When field k (order_type) is of value STOP_LOSS_LIMIT, class Order requires fields ['p', 'tp']"
|
291
300
|
)
|
292
301
|
elif any(getattr(self, key) is not None for key in ["po"]):
|
293
302
|
raise ValueError(
|
294
303
|
f"When field k (order_type) is of value STOP_LOSS_LIMIT, class Order should not have fields ['po']"
|
295
304
|
)
|
296
305
|
elif self.k == "TAKE_PROFIT_LIMIT":
|
297
|
-
if not all(getattr(self, key) is not None for key in ["tp"]):
|
306
|
+
if not all(getattr(self, key) is not None for key in ["p", "tp"]):
|
298
307
|
raise ValueError(
|
299
|
-
f"When field k (order_type) is of value TAKE_PROFIT_LIMIT, class Order requires fields ['tp']"
|
308
|
+
f"When field k (order_type) is of value TAKE_PROFIT_LIMIT, class Order requires fields ['p', 'tp']"
|
300
309
|
)
|
301
310
|
elif any(getattr(self, key) is not None for key in ["po"]):
|
302
311
|
raise ValueError(
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
from __future__ import annotations
|
5
5
|
from architect_py.grpc.models.Oms.Order import Order
|
6
|
-
from architect_py.common_types import OrderDir
|
6
|
+
from architect_py.common_types import OrderDir, TimeInForce
|
7
7
|
|
8
8
|
from decimal import Decimal
|
9
9
|
from typing import Annotated, Optional
|
@@ -17,8 +17,7 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
17
17
|
d: Annotated[OrderDir, Meta(title="dir")]
|
18
18
|
q: Annotated[Decimal, Meta(title="quantity")]
|
19
19
|
s: Annotated[str, Meta(title="symbol")]
|
20
|
-
tif: Annotated[
|
21
|
-
p: Annotated[Decimal, Meta(title="limit_price")]
|
20
|
+
tif: Annotated[TimeInForce, Meta(title="time_in_force")]
|
22
21
|
k: Annotated[definitions.OrderType, Meta(title="order_type")]
|
23
22
|
a: Optional[
|
24
23
|
Annotated[Optional[definitions.AccountIdOrName], Meta(title="account")]
|
@@ -44,6 +43,7 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
44
43
|
Annotated[Optional[definitions.TraderIdOrEmail], Meta(title="trader")]
|
45
44
|
] = None
|
46
45
|
x: Optional[Annotated[Optional[str], Meta(title="execution_venue")]] = None
|
46
|
+
p: Optional[Annotated[Decimal, Meta(title="limit_price")]] = None
|
47
47
|
po: Optional[Annotated[bool, Meta(title="post_only")]] = None
|
48
48
|
tp: Optional[Annotated[Decimal, Meta(title="trigger_price")]] = None
|
49
49
|
|
@@ -54,8 +54,7 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
54
54
|
dir: OrderDir,
|
55
55
|
quantity: Decimal,
|
56
56
|
symbol: str,
|
57
|
-
time_in_force:
|
58
|
-
limit_price: Decimal,
|
57
|
+
time_in_force: TimeInForce,
|
59
58
|
order_type: definitions.OrderType,
|
60
59
|
account: Optional[definitions.AccountIdOrName] = None,
|
61
60
|
id: Optional[definitions.OrderId] = None,
|
@@ -63,6 +62,7 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
63
62
|
source: Optional[definitions.OrderSource] = None,
|
64
63
|
trader: Optional[definitions.TraderIdOrEmail] = None,
|
65
64
|
execution_venue: Optional[str] = None,
|
65
|
+
limit_price: Optional[Decimal] = None,
|
66
66
|
post_only: Optional[bool] = None,
|
67
67
|
trigger_price: Optional[Decimal] = None,
|
68
68
|
):
|
@@ -71,7 +71,6 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
71
71
|
quantity,
|
72
72
|
symbol,
|
73
73
|
time_in_force,
|
74
|
-
limit_price,
|
75
74
|
order_type,
|
76
75
|
account,
|
77
76
|
id,
|
@@ -79,12 +78,13 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
79
78
|
source,
|
80
79
|
trader,
|
81
80
|
execution_venue,
|
81
|
+
limit_price,
|
82
82
|
post_only,
|
83
83
|
trigger_price,
|
84
84
|
)
|
85
85
|
|
86
86
|
def __str__(self) -> str:
|
87
|
-
return f"PlaceOrderRequest(dir={self.d},quantity={self.q},symbol={self.s},time_in_force={self.tif},
|
87
|
+
return f"PlaceOrderRequest(dir={self.d},quantity={self.q},symbol={self.s},time_in_force={self.tif},order_type={self.k},account={self.a},id={self.id},parent_id={self.pid},source={self.src},trader={self.u},execution_venue={self.x},limit_price={self.p},post_only={self.po},trigger_price={self.tp})"
|
88
88
|
|
89
89
|
@property
|
90
90
|
def dir(self) -> OrderDir:
|
@@ -111,21 +111,13 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
111
111
|
self.s = value
|
112
112
|
|
113
113
|
@property
|
114
|
-
def time_in_force(self) ->
|
114
|
+
def time_in_force(self) -> TimeInForce:
|
115
115
|
return self.tif
|
116
116
|
|
117
117
|
@time_in_force.setter
|
118
|
-
def time_in_force(self, value:
|
118
|
+
def time_in_force(self, value: TimeInForce) -> None:
|
119
119
|
self.tif = value
|
120
120
|
|
121
|
-
@property
|
122
|
-
def limit_price(self) -> Decimal:
|
123
|
-
return self.p
|
124
|
-
|
125
|
-
@limit_price.setter
|
126
|
-
def limit_price(self, value: Decimal) -> None:
|
127
|
-
self.p = value
|
128
|
-
|
129
121
|
@property
|
130
122
|
def order_type(self) -> definitions.OrderType:
|
131
123
|
return self.k
|
@@ -174,6 +166,14 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
174
166
|
def execution_venue(self, value: Optional[str]) -> None:
|
175
167
|
self.x = value
|
176
168
|
|
169
|
+
@property
|
170
|
+
def limit_price(self) -> Optional[Decimal]:
|
171
|
+
return self.p
|
172
|
+
|
173
|
+
@limit_price.setter
|
174
|
+
def limit_price(self, value: Optional[Decimal]) -> None:
|
175
|
+
self.p = value
|
176
|
+
|
177
177
|
@property
|
178
178
|
def post_only(self) -> Optional[bool]:
|
179
179
|
return self.po
|
@@ -207,28 +207,37 @@ class PlaceOrderRequest(Struct, omit_defaults=True):
|
|
207
207
|
return "unary"
|
208
208
|
|
209
209
|
def __post_init__(self):
|
210
|
-
if self.k == "
|
211
|
-
if not all(getattr(self, key) is not None for key in [
|
210
|
+
if self.k == "MARKET":
|
211
|
+
if not all(getattr(self, key) is not None for key in []):
|
212
|
+
raise ValueError(
|
213
|
+
f"When field k (order_type) is of value MARKET, class PlaceOrderRequest requires fields []"
|
214
|
+
)
|
215
|
+
elif any(getattr(self, key) is not None for key in ["p", "po", "tp"]):
|
216
|
+
raise ValueError(
|
217
|
+
f"When field k (order_type) is of value MARKET, class PlaceOrderRequest should not have fields ['p', 'po', 'tp']"
|
218
|
+
)
|
219
|
+
elif self.k == "LIMIT":
|
220
|
+
if not all(getattr(self, key) is not None for key in ["p", "po"]):
|
212
221
|
raise ValueError(
|
213
|
-
f"When field k (order_type) is of value LIMIT, class PlaceOrderRequest requires fields ['po']"
|
222
|
+
f"When field k (order_type) is of value LIMIT, class PlaceOrderRequest requires fields ['p', 'po']"
|
214
223
|
)
|
215
224
|
elif any(getattr(self, key) is not None for key in ["tp"]):
|
216
225
|
raise ValueError(
|
217
226
|
f"When field k (order_type) is of value LIMIT, class PlaceOrderRequest should not have fields ['tp']"
|
218
227
|
)
|
219
228
|
elif self.k == "STOP_LOSS_LIMIT":
|
220
|
-
if not all(getattr(self, key) is not None for key in ["tp"]):
|
229
|
+
if not all(getattr(self, key) is not None for key in ["p", "tp"]):
|
221
230
|
raise ValueError(
|
222
|
-
f"When field k (order_type) is of value STOP_LOSS_LIMIT, class PlaceOrderRequest requires fields ['tp']"
|
231
|
+
f"When field k (order_type) is of value STOP_LOSS_LIMIT, class PlaceOrderRequest requires fields ['p', 'tp']"
|
223
232
|
)
|
224
233
|
elif any(getattr(self, key) is not None for key in ["po"]):
|
225
234
|
raise ValueError(
|
226
235
|
f"When field k (order_type) is of value STOP_LOSS_LIMIT, class PlaceOrderRequest should not have fields ['po']"
|
227
236
|
)
|
228
237
|
elif self.k == "TAKE_PROFIT_LIMIT":
|
229
|
-
if not all(getattr(self, key) is not None for key in ["tp"]):
|
238
|
+
if not all(getattr(self, key) is not None for key in ["p", "tp"]):
|
230
239
|
raise ValueError(
|
231
|
-
f"When field k (order_type) is of value TAKE_PROFIT_LIMIT, class PlaceOrderRequest requires fields ['tp']"
|
240
|
+
f"When field k (order_type) is of value TAKE_PROFIT_LIMIT, class PlaceOrderRequest requires fields ['p', 'tp']"
|
232
241
|
)
|
233
242
|
elif any(getattr(self, key) is not None for key in ["po"]):
|
234
243
|
raise ValueError(
|
@@ -1,2 +1,113 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
from .Accounts.AccountsRequest import AccountsRequest
|
2
|
+
from .Accounts.AccountsResponse import AccountsResponse
|
3
|
+
from .Algo.AlgoOrder import AlgoOrder
|
4
|
+
from .Algo.AlgoOrderRequest import AlgoOrderRequest
|
5
|
+
from .Algo.AlgoOrdersRequest import AlgoOrdersRequest
|
6
|
+
from .Algo.AlgoOrdersResponse import AlgoOrdersResponse
|
7
|
+
from .Algo.CreateAlgoOrderRequest import CreateAlgoOrderRequest
|
8
|
+
from .Algo.PauseAlgoRequest import PauseAlgoRequest
|
9
|
+
from .Algo.PauseAlgoResponse import PauseAlgoResponse
|
10
|
+
from .Algo.StartAlgoRequest import StartAlgoRequest
|
11
|
+
from .Algo.StartAlgoResponse import StartAlgoResponse
|
12
|
+
from .Algo.StopAlgoRequest import StopAlgoRequest
|
13
|
+
from .Algo.StopAlgoResponse import StopAlgoResponse
|
14
|
+
from .Auth.CreateJwtRequest import CreateJwtRequest
|
15
|
+
from .Auth.CreateJwtResponse import CreateJwtResponse
|
16
|
+
from .Boss.DepositsRequest import DepositsRequest
|
17
|
+
from .Boss.DepositsResponse import DepositsResponse
|
18
|
+
from .Boss.RqdAccountStatisticsRequest import RqdAccountStatisticsRequest
|
19
|
+
from .Boss.RqdAccountStatisticsResponse import RqdAccountStatisticsResponse
|
20
|
+
from .Boss.StatementUrlRequest import StatementUrlRequest
|
21
|
+
from .Boss.StatementUrlResponse import StatementUrlResponse
|
22
|
+
from .Boss.StatementsRequest import StatementsRequest
|
23
|
+
from .Boss.StatementsResponse import StatementsResponse
|
24
|
+
from .Boss.WithdrawalsRequest import WithdrawalsRequest
|
25
|
+
from .Boss.WithdrawalsResponse import WithdrawalsResponse
|
26
|
+
from .Core.ConfigRequest import ConfigRequest
|
27
|
+
from .Core.ConfigResponse import ConfigResponse
|
28
|
+
from .Core.RestartCptyRequest import RestartCptyRequest
|
29
|
+
from .Core.RestartCptyResponse import RestartCptyResponse
|
30
|
+
from .Cpty.CptyRequest import CptyRequest
|
31
|
+
from .Cpty.CptyResponse import CptyResponse
|
32
|
+
from .Cpty.CptyStatus import CptyStatus
|
33
|
+
from .Cpty.CptyStatusRequest import CptyStatusRequest
|
34
|
+
from .Cpty.CptysRequest import CptysRequest
|
35
|
+
from .Cpty.CptysResponse import CptysResponse
|
36
|
+
from .Folio.AccountHistoryRequest import AccountHistoryRequest
|
37
|
+
from .Folio.AccountHistoryResponse import AccountHistoryResponse
|
38
|
+
from .Folio.AccountSummariesRequest import AccountSummariesRequest
|
39
|
+
from .Folio.AccountSummariesResponse import AccountSummariesResponse
|
40
|
+
from .Folio.AccountSummary import AccountSummary
|
41
|
+
from .Folio.AccountSummaryRequest import AccountSummaryRequest
|
42
|
+
from .Folio.HistoricalFillsRequest import HistoricalFillsRequest
|
43
|
+
from .Folio.HistoricalFillsResponse import HistoricalFillsResponse
|
44
|
+
from .Folio.HistoricalOrdersRequest import HistoricalOrdersRequest
|
45
|
+
from .Folio.HistoricalOrdersResponse import HistoricalOrdersResponse
|
46
|
+
from .Health.HealthCheckRequest import HealthCheckRequest
|
47
|
+
from .Health.HealthCheckResponse import HealthCheckResponse
|
48
|
+
from .Marketdata.ArrayOfL1BookSnapshot import ArrayOfL1BookSnapshot
|
49
|
+
from .Marketdata.Candle import Candle
|
50
|
+
from .Marketdata.HistoricalCandlesRequest import HistoricalCandlesRequest
|
51
|
+
from .Marketdata.HistoricalCandlesResponse import HistoricalCandlesResponse
|
52
|
+
from .Marketdata.L1BookSnapshot import L1BookSnapshot
|
53
|
+
from .Marketdata.L1BookSnapshotRequest import L1BookSnapshotRequest
|
54
|
+
from .Marketdata.L1BookSnapshotsRequest import L1BookSnapshotsRequest
|
55
|
+
from .Marketdata.L2BookSnapshot import L2BookSnapshot
|
56
|
+
from .Marketdata.L2BookSnapshotRequest import L2BookSnapshotRequest
|
57
|
+
from .Marketdata.L2BookUpdate import L2BookUpdate
|
58
|
+
from .Marketdata.Liquidation import Liquidation
|
59
|
+
from .Marketdata.MarketStatus import MarketStatus
|
60
|
+
from .Marketdata.MarketStatusRequest import MarketStatusRequest
|
61
|
+
from .Marketdata.SubscribeCandlesRequest import SubscribeCandlesRequest
|
62
|
+
from .Marketdata.SubscribeCurrentCandlesRequest import SubscribeCurrentCandlesRequest
|
63
|
+
from .Marketdata.SubscribeL1BookSnapshotsRequest import SubscribeL1BookSnapshotsRequest
|
64
|
+
from .Marketdata.SubscribeL2BookUpdatesRequest import SubscribeL2BookUpdatesRequest
|
65
|
+
from .Marketdata.SubscribeLiquidationsRequest import SubscribeLiquidationsRequest
|
66
|
+
from .Marketdata.SubscribeManyCandlesRequest import SubscribeManyCandlesRequest
|
67
|
+
from .Marketdata.SubscribeTickersRequest import SubscribeTickersRequest
|
68
|
+
from .Marketdata.SubscribeTradesRequest import SubscribeTradesRequest
|
69
|
+
from .Marketdata.Ticker import Ticker
|
70
|
+
from .Marketdata.TickerRequest import TickerRequest
|
71
|
+
from .Marketdata.TickerUpdate import TickerUpdate
|
72
|
+
from .Marketdata.TickersRequest import TickersRequest
|
73
|
+
from .Marketdata.TickersResponse import TickersResponse
|
74
|
+
from .Marketdata.Trade import Trade
|
75
|
+
from .Oms.Cancel import Cancel
|
76
|
+
from .Oms.CancelAllOrdersRequest import CancelAllOrdersRequest
|
77
|
+
from .Oms.CancelAllOrdersResponse import CancelAllOrdersResponse
|
78
|
+
from .Oms.CancelOrderRequest import CancelOrderRequest
|
79
|
+
from .Oms.OpenOrdersRequest import OpenOrdersRequest
|
80
|
+
from .Oms.OpenOrdersResponse import OpenOrdersResponse
|
81
|
+
from .Oms.Order import Order
|
82
|
+
from .Oms.PendingCancelsRequest import PendingCancelsRequest
|
83
|
+
from .Oms.PendingCancelsResponse import PendingCancelsResponse
|
84
|
+
from .Oms.PlaceOrderRequest import PlaceOrderRequest
|
85
|
+
from .OptionsMarketdata.OptionsChain import OptionsChain
|
86
|
+
from .OptionsMarketdata.OptionsChainGreeks import OptionsChainGreeks
|
87
|
+
from .OptionsMarketdata.OptionsChainGreeksRequest import OptionsChainGreeksRequest
|
88
|
+
from .OptionsMarketdata.OptionsChainRequest import OptionsChainRequest
|
89
|
+
from .OptionsMarketdata.OptionsExpirations import OptionsExpirations
|
90
|
+
from .OptionsMarketdata.OptionsExpirationsRequest import OptionsExpirationsRequest
|
91
|
+
from .Orderflow.Dropcopy import Dropcopy
|
92
|
+
from .Orderflow.DropcopyRequest import DropcopyRequest
|
93
|
+
from .Orderflow.Orderflow import Orderflow
|
94
|
+
from .Orderflow.OrderflowRequest import OrderflowRequest
|
95
|
+
from .Orderflow.SubscribeOrderflowRequest import SubscribeOrderflowRequest
|
96
|
+
from .Symbology.DownloadProductCatalogRequest import DownloadProductCatalogRequest
|
97
|
+
from .Symbology.DownloadProductCatalogResponse import DownloadProductCatalogResponse
|
98
|
+
from .Symbology.ExecutionInfoRequest import ExecutionInfoRequest
|
99
|
+
from .Symbology.ExecutionInfoResponse import ExecutionInfoResponse
|
100
|
+
from .Symbology.PruneExpiredSymbolsRequest import PruneExpiredSymbolsRequest
|
101
|
+
from .Symbology.PruneExpiredSymbolsResponse import PruneExpiredSymbolsResponse
|
102
|
+
from .Symbology.SubscribeSymbology import SubscribeSymbology
|
103
|
+
from .Symbology.SymbologyRequest import SymbologyRequest
|
104
|
+
from .Symbology.SymbologySnapshot import SymbologySnapshot
|
105
|
+
from .Symbology.SymbologyUpdate import SymbologyUpdate
|
106
|
+
from .Symbology.SymbolsRequest import SymbolsRequest
|
107
|
+
from .Symbology.SymbolsResponse import SymbolsResponse
|
108
|
+
from .Symbology.UploadProductCatalogRequest import UploadProductCatalogRequest
|
109
|
+
from .Symbology.UploadProductCatalogResponse import UploadProductCatalogResponse
|
110
|
+
from .Symbology.UploadSymbologyRequest import UploadSymbologyRequest
|
111
|
+
from .Symbology.UploadSymbologyResponse import UploadSymbologyResponse
|
112
|
+
|
113
|
+
__all__ = ["AccountsRequest", "AccountsResponse", "AlgoOrder", "AlgoOrderRequest", "AlgoOrdersRequest", "AlgoOrdersResponse", "CreateAlgoOrderRequest", "PauseAlgoRequest", "PauseAlgoResponse", "StartAlgoRequest", "StartAlgoResponse", "StopAlgoRequest", "StopAlgoResponse", "CreateJwtRequest", "CreateJwtResponse", "DepositsRequest", "DepositsResponse", "RqdAccountStatisticsRequest", "RqdAccountStatisticsResponse", "StatementUrlRequest", "StatementUrlResponse", "StatementsRequest", "StatementsResponse", "WithdrawalsRequest", "WithdrawalsResponse", "ConfigRequest", "ConfigResponse", "RestartCptyRequest", "RestartCptyResponse", "CptyRequest", "CptyResponse", "CptyStatus", "CptyStatusRequest", "CptysRequest", "CptysResponse", "AccountHistoryRequest", "AccountHistoryResponse", "AccountSummariesRequest", "AccountSummariesResponse", "AccountSummary", "AccountSummaryRequest", "HistoricalFillsRequest", "HistoricalFillsResponse", "HistoricalOrdersRequest", "HistoricalOrdersResponse", "HealthCheckRequest", "HealthCheckResponse", "ArrayOfL1BookSnapshot", "Candle", "HistoricalCandlesRequest", "HistoricalCandlesResponse", "L1BookSnapshot", "L1BookSnapshotRequest", "L1BookSnapshotsRequest", "L2BookSnapshot", "L2BookSnapshotRequest", "L2BookUpdate", "Liquidation", "MarketStatus", "MarketStatusRequest", "SubscribeCandlesRequest", "SubscribeCurrentCandlesRequest", "SubscribeL1BookSnapshotsRequest", "SubscribeL2BookUpdatesRequest", "SubscribeLiquidationsRequest", "SubscribeManyCandlesRequest", "SubscribeTickersRequest", "SubscribeTradesRequest", "Ticker", "TickerRequest", "TickerUpdate", "TickersRequest", "TickersResponse", "Trade", "Cancel", "CancelAllOrdersRequest", "CancelAllOrdersResponse", "CancelOrderRequest", "OpenOrdersRequest", "OpenOrdersResponse", "Order", "PendingCancelsRequest", "PendingCancelsResponse", "PlaceOrderRequest", "OptionsChain", "OptionsChainGreeks", "OptionsChainGreeksRequest", "OptionsChainRequest", "OptionsExpirations", "OptionsExpirationsRequest", "Dropcopy", "DropcopyRequest", "Orderflow", "OrderflowRequest", "SubscribeOrderflowRequest", "DownloadProductCatalogRequest", "DownloadProductCatalogResponse", "ExecutionInfoRequest", "ExecutionInfoResponse", "PruneExpiredSymbolsRequest", "PruneExpiredSymbolsResponse", "SubscribeSymbology", "SymbologyRequest", "SymbologySnapshot", "SymbologyUpdate", "SymbolsRequest", "SymbolsResponse", "UploadProductCatalogRequest", "UploadProductCatalogResponse", "UploadSymbologyRequest", "UploadSymbologyResponse"]
|
@@ -8,14 +8,12 @@ from datetime import datetime, timezone
|
|
8
8
|
from datetime import date, datetime, time
|
9
9
|
from decimal import Decimal
|
10
10
|
from enum import Enum
|
11
|
-
from typing import Annotated,
|
11
|
+
from typing import Annotated, Dict, List, Literal, Optional, Union
|
12
12
|
|
13
13
|
from msgspec import Meta, Struct
|
14
14
|
|
15
15
|
from .Marketdata.Ticker import Ticker
|
16
16
|
|
17
|
-
Model = Any
|
18
|
-
|
19
17
|
|
20
18
|
AccountIdOrName = str
|
21
19
|
|
@@ -458,6 +456,7 @@ class OrderStatus(int, Enum):
|
|
458
456
|
|
459
457
|
|
460
458
|
class OrderType(str, Enum):
|
459
|
+
MARKET = "MARKET"
|
461
460
|
LIMIT = "LIMIT"
|
462
461
|
STOP_LOSS_LIMIT = "STOP_LOSS_LIMIT"
|
463
462
|
TAKE_PROFIT_LIMIT = "TAKE_PROFIT_LIMIT"
|
@@ -746,35 +745,6 @@ class Statement(Struct, omit_defaults=True):
|
|
746
745
|
return f"Statement(account={self.account},clearing_firm={self.clearing_firm},filename={self.filename},statement_date={self.statement_date},statement_type={self.statement_type},statement_uuid={self.statement_uuid})"
|
747
746
|
|
748
747
|
|
749
|
-
class GoodTilDate(Struct, omit_defaults=True):
|
750
|
-
GTD: datetime
|
751
|
-
|
752
|
-
# Constructor that takes all field titles as arguments for convenience
|
753
|
-
@classmethod
|
754
|
-
def new(
|
755
|
-
cls,
|
756
|
-
GTD: datetime,
|
757
|
-
):
|
758
|
-
return cls(
|
759
|
-
GTD,
|
760
|
-
)
|
761
|
-
|
762
|
-
def __str__(self) -> str:
|
763
|
-
return f"GoodTilDate(GTD={self.GTD})"
|
764
|
-
|
765
|
-
|
766
|
-
class TimeInForceEnum(str, Enum):
|
767
|
-
GTC = "GTC"
|
768
|
-
DAY = "DAY"
|
769
|
-
IOC = "IOC"
|
770
|
-
FOK = "FOK"
|
771
|
-
ATO = "ATO"
|
772
|
-
ATC = "ATC"
|
773
|
-
|
774
|
-
|
775
|
-
TimeInForce = Union[GoodTilDate, TimeInForceEnum]
|
776
|
-
|
777
|
-
|
778
748
|
TraderIdOrEmail = str
|
779
749
|
|
780
750
|
|
architect_py/grpc/utils.py
CHANGED
@@ -3,12 +3,9 @@ from typing import Any, Protocol, Type, TypeVar
|
|
3
3
|
|
4
4
|
import msgspec
|
5
5
|
|
6
|
-
from architect_py.common_types import TradableProduct
|
7
|
-
|
8
6
|
|
9
7
|
def enc_hook(obj: Any) -> Any:
|
10
|
-
|
11
|
-
return str(obj)
|
8
|
+
return obj.serialize()
|
12
9
|
|
13
10
|
|
14
11
|
encoder = msgspec.json.Encoder(enc_hook=enc_hook)
|
@@ -3,8 +3,7 @@ from decimal import Decimal
|
|
3
3
|
|
4
4
|
import pytest
|
5
5
|
|
6
|
-
from architect_py import AsyncClient, OrderDir
|
7
|
-
from architect_py.utils.nearest_tick_2 import TickRoundMethod
|
6
|
+
from architect_py import AsyncClient, OrderDir, TickRoundMethod
|
8
7
|
|
9
8
|
|
10
9
|
@pytest.mark.asyncio
|
@@ -27,7 +26,7 @@ async def test_place_limit_order(async_client: AsyncClient):
|
|
27
26
|
order = await async_client.place_limit_order(
|
28
27
|
symbol=symbol,
|
29
28
|
execution_venue=venue,
|
30
|
-
|
29
|
+
dir=OrderDir.BUY,
|
31
30
|
quantity=Decimal(1),
|
32
31
|
limit_price=limit_price,
|
33
32
|
account=str(account.account.id),
|
architect_py/utils/pandas.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
from typing import List
|
1
|
+
from typing import TYPE_CHECKING, List
|
2
2
|
|
3
3
|
import msgspec
|
4
4
|
import pandas as pd
|
5
5
|
|
6
|
-
|
6
|
+
if TYPE_CHECKING:
|
7
|
+
from .. import Candle
|
7
8
|
|
8
9
|
CANDLES_FIELD_MAP = {
|
9
10
|
"av": "sell_volume",
|
@@ -30,7 +31,7 @@ CANDLES_FIELD_MAP = {
|
|
30
31
|
}
|
31
32
|
|
32
33
|
|
33
|
-
def candles_to_dataframe(candles: List[Candle]) -> pd.DataFrame:
|
34
|
+
def candles_to_dataframe(candles: List["Candle"]) -> pd.DataFrame:
|
34
35
|
records = msgspec.to_builtins(candles)
|
35
36
|
df = pd.DataFrame.from_records(records)
|
36
37
|
df.rename(columns=CANDLES_FIELD_MAP, inplace=True)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: architect-py
|
3
|
+
Version: 5.1.0
|
4
|
+
Summary: Python SDK for the Architect trading platform and brokerage.
|
5
|
+
Author-email: "Architect Financial Technologies, Inc." <hello@architect.co>
|
6
|
+
License-Expression: Apache-2.0
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
8
|
+
Classifier: Operating System :: OS Independent
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
10
|
+
Requires-Python: <4,>=3.10
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
License-File: LICENSE
|
13
|
+
Requires-Dist: asyncio>=3
|
14
|
+
Requires-Dist: dnspython>=2.0
|
15
|
+
Requires-Dist: gql[httpx]<4,>=3.5.0
|
16
|
+
Requires-Dist: grpcio>=1.66.1
|
17
|
+
Requires-Dist: msgspec<0.20,>=0.19
|
18
|
+
Requires-Dist: pandas>=2
|
19
|
+
Requires-Dist: pydantic~=2.10
|
20
|
+
Requires-Dist: websockets>=11
|
21
|
+
Dynamic: license-file
|
22
|
+
|
23
|
+
# [](https://architect.co) architect_py
|
24
|
+
[](https://pypi.org/project/architect-py/)
|
25
|
+
|
26
|
+
A fully-featured Python SDK for trading on [Architect](https://architect.co).
|
27
|
+
|
28
|
+
Just some of the features of this SDK: symbology, portfolio management, order entry, advanced algos, and marketdata subscriptions.
|
29
|
+
|
30
|
+
Also, it is compatible with Jupyter notebooks! Check the [examples for an example notebook](examples/jupyter_example.ipynb).
|
31
|
+
|
32
|
+
## Installation
|
33
|
+
|
34
|
+
- pip: `pip install architect-py`
|
35
|
+
- poetry: `poetry add architect-py`
|
36
|
+
- uv: `uv add architect-py`
|
37
|
+
|
38
|
+
## API keys for the brokerage
|
39
|
+
|
40
|
+
API keys/secrets for the brokerage can be generated on the [user account page](https://app.architect.co/user/account).
|
41
|
+
|
42
|
+
## Method catalog
|
43
|
+
|
44
|
+
Go to [FUNCTIONS.md](FUNCTIONS.md) file to see a catalog of methods.
|
45
|
+
|
46
|
+
## Examples
|
47
|
+
|
48
|
+
Go to the [Examples](./examples) to see examples of a variety of common use cases.
|
49
|
+
|
50
|
+
## Documentation
|
51
|
+
|
52
|
+
See the [Getting started with Python](https://docs.architect.co/getting-started-with-python) guide for more information.
|
53
|
+
|
54
|
+
## Imports
|
55
|
+
|
56
|
+
In general, most types in the package can be imported from the top-level; in rare cases, some types may come from GraphQL and need to be imported from `architect_py.graphql_client.fragments`.
|
57
|
+
|
58
|
+
```python
|
59
|
+
from architect_py import * # includes both AsyncClient and Client
|
60
|
+
from architect_py.graphql_client.fragments import (
|
61
|
+
ExecutionInfoFields,
|
62
|
+
ProductInfoFields,
|
63
|
+
)
|
64
|
+
```
|
65
|
+
|
66
|
+
Using an LLM or an IDE with code completion like VSCode or PyCharm can be very helpful.
|