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.
Files changed (75) hide show
  1. architect_py/__init__.py +432 -5
  2. architect_py/async_client.py +77 -43
  3. architect_py/client.py +11 -4
  4. architect_py/client.pyi +504 -0
  5. architect_py/common_types/__init__.py +2 -1
  6. architect_py/common_types/time_in_force.py +94 -0
  7. architect_py/common_types/tradable_product.py +9 -0
  8. architect_py/graphql_client/__init__.py +1 -216
  9. architect_py/graphql_client/client.py +2 -1043
  10. architect_py/graphql_client/enums.py +0 -72
  11. architect_py/graphql_client/fragments.py +4 -152
  12. architect_py/grpc/__init__.py +0 -143
  13. architect_py/grpc/client.py +6 -1
  14. architect_py/grpc/models/Core/RestartCptyRequest.py +40 -0
  15. architect_py/grpc/models/Core/RestartCptyResponse.py +20 -0
  16. architect_py/grpc/models/Marketdata/Liquidation.py +0 -1
  17. architect_py/grpc/models/Marketdata/Ticker.py +14 -1
  18. architect_py/grpc/models/Marketdata/TickersRequest.py +38 -12
  19. architect_py/grpc/models/Marketdata/Trade.py +0 -1
  20. architect_py/grpc/models/Oms/Order.py +33 -24
  21. architect_py/grpc/models/Oms/PlaceOrderRequest.py +33 -24
  22. architect_py/grpc/models/__init__.py +113 -2
  23. architect_py/grpc/models/definitions.py +2 -32
  24. architect_py/grpc/utils.py +1 -4
  25. architect_py/tests/test_order_entry.py +2 -3
  26. architect_py/tests/test_orderflow.py +1 -1
  27. architect_py/utils/pandas.py +4 -3
  28. architect_py-5.1.0.dist-info/METADATA +66 -0
  29. {architect_py-5.0.0b3.dist-info → architect_py-5.1.0.dist-info}/RECORD +48 -67
  30. {architect_py-5.0.0b3.dist-info → architect_py-5.1.0.dist-info}/WHEEL +1 -1
  31. examples/book_subscription.py +1 -2
  32. examples/candles.py +1 -3
  33. examples/common.py +1 -2
  34. examples/external_cpty.py +2 -2
  35. examples/funding_rate_mean_reversion_algo.py +9 -6
  36. examples/order_sending.py +29 -9
  37. examples/stream_l1_marketdata.py +1 -2
  38. examples/stream_l2_marketdata.py +1 -2
  39. examples/trades.py +1 -2
  40. examples/tutorial_async.py +6 -8
  41. examples/tutorial_sync.py +6 -7
  42. scripts/add_imports_to_inits.py +146 -0
  43. scripts/correct_sync_interface.py +143 -0
  44. scripts/postprocess_grpc.py +57 -11
  45. scripts/preprocess_grpc_schema.py +2 -0
  46. scripts/prune_graphql_schema.py +187 -0
  47. architect_py/client_interface.py +0 -63
  48. architect_py/common_types/scalars.py +0 -25
  49. architect_py/graphql_client/cancel_all_orders_mutation.py +0 -17
  50. architect_py/graphql_client/cancel_order_mutation.py +0 -23
  51. architect_py/graphql_client/create_jwt.py +0 -17
  52. architect_py/graphql_client/get_account_history_query.py +0 -27
  53. architect_py/graphql_client/get_account_query.py +0 -23
  54. architect_py/graphql_client/get_account_summaries_query.py +0 -27
  55. architect_py/graphql_client/get_account_summary_query.py +0 -25
  56. architect_py/graphql_client/get_candle_snapshot_query.py +0 -27
  57. architect_py/graphql_client/get_fills_query.py +0 -69
  58. architect_py/graphql_client/get_historical_orders_query.py +0 -27
  59. architect_py/graphql_client/get_l_1_book_snapshot_query.py +0 -21
  60. architect_py/graphql_client/get_l_1_book_snapshots_query.py +0 -23
  61. architect_py/graphql_client/get_l_2_book_snapshot_query.py +0 -25
  62. architect_py/graphql_client/get_market_status_query.py +0 -25
  63. architect_py/graphql_client/get_open_orders_query.py +0 -25
  64. architect_py/graphql_client/list_accounts_query.py +0 -23
  65. architect_py/graphql_client/place_order_mutation.py +0 -23
  66. architect_py/graphql_client/subscribe_candles.py +0 -16
  67. architect_py/graphql_client/subscribe_orderflow.py +0 -100
  68. architect_py/graphql_client/subscribe_trades.py +0 -27
  69. architect_py/graphql_client/user_email_query.py +0 -17
  70. architect_py/internal_utils/__init__.py +0 -0
  71. architect_py/internal_utils/no_pandas.py +0 -3
  72. architect_py-5.0.0b3.dist-info/METADATA +0 -123
  73. scripts/generate_sync_interface.py +0 -226
  74. {architect_py-5.0.0b3.dist-info → architect_py-5.1.0.dist-info}/licenses/LICENSE +0 -0
  75. {architect_py-5.0.0b3.dist-info → architect_py-5.1.0.dist-info}/top_level.txt +0 -0
@@ -1,60 +1,22 @@
1
1
  # Generated by ariadne-codegen
2
2
  # Source: queries.graphql
3
3
 
4
- from datetime import datetime
5
- from decimal import Decimal
6
- from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, List, Optional, Union
7
- from uuid import UUID
4
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
8
5
 
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
6
+ from architect_py.common_types import TradableProduct
12
7
 
13
8
  from .base_model import UNSET
14
9
  from .juniper_base_client import JuniperBaseClient
15
10
 
16
11
  if TYPE_CHECKING:
17
12
  from .base_model import UnsetType
18
- from .cancel_all_orders_mutation import CancelAllOrdersMutationOms
19
- from .cancel_order_mutation import CancelOrderMutationOms
20
- from .create_jwt import CreateJwtUser
21
- from .enums import CandleWidth, OrderType, TimeInForce
22
- from .get_account_history_query import GetAccountHistoryQueryFolio
23
- from .get_account_query import GetAccountQueryUser
24
- from .get_account_summaries_query import GetAccountSummariesQueryFolio
25
- from .get_account_summary_query import GetAccountSummaryQueryFolio
26
- from .get_candle_snapshot_query import GetCandleSnapshotQueryMarketdata
27
13
  from .get_execution_info_query import GetExecutionInfoQuerySymbology
28
14
  from .get_execution_infos_query import GetExecutionInfosQuerySymbology
29
- from .get_fills_query import GetFillsQueryFolio
30
15
  from .get_first_notice_date_query import GetFirstNoticeDateQuerySymbology
31
16
  from .get_future_series_query import GetFutureSeriesQuerySymbology
32
- from .get_historical_orders_query import GetHistoricalOrdersQueryFolio
33
- from .get_l_1_book_snapshot_query import GetL1BookSnapshotQueryMarketdata
34
- from .get_l_1_book_snapshots_query import GetL1BookSnapshotsQueryMarketdata
35
- from .get_l_2_book_snapshot_query import GetL2BookSnapshotQueryMarketdata
36
- from .get_market_status_query import GetMarketStatusQueryMarketdata
37
- from .get_open_orders_query import GetOpenOrdersQueryOms
38
17
  from .get_product_info_query import GetProductInfoQuerySymbology
39
18
  from .get_product_infos_query import GetProductInfosQuerySymbology
40
- from .list_accounts_query import ListAccountsQueryUser
41
- from .place_order_mutation import PlaceOrderMutationOms
42
19
  from .search_symbols_query import SearchSymbolsQuerySymbology
43
- from .subscribe_candles import SubscribeCandlesCandles
44
- from .subscribe_orderflow import (
45
- SubscribeOrderflowOrderflowAberrantFill,
46
- SubscribeOrderflowOrderflowCancel,
47
- SubscribeOrderflowOrderflowCancelReject,
48
- SubscribeOrderflowOrderflowFill,
49
- SubscribeOrderflowOrderflowGqlOrderReject,
50
- SubscribeOrderflowOrderflowOrder,
51
- SubscribeOrderflowOrderflowOrderAck,
52
- SubscribeOrderflowOrderflowOrderCanceled,
53
- SubscribeOrderflowOrderflowOrderCanceling,
54
- SubscribeOrderflowOrderflowOrderOut,
55
- SubscribeOrderflowOrderflowOrderStale,
56
- )
57
- from .subscribe_trades import SubscribeTradesTrades
58
20
  from .user_id_query import UserIdQueryUser
59
21
 
60
22
 
@@ -348,1006 +310,3 @@ class GraphQLClient(JuniperBaseClient):
348
310
  )
349
311
  data = self.get_data(response)
350
312
  return GetExecutionInfosQuery.model_validate(data).symbology
351
-
352
- async def get_candle_snapshot_query(
353
- self,
354
- venue: str,
355
- symbol: str,
356
- candle_width: "CandleWidth",
357
- start: datetime,
358
- end: datetime,
359
- **kwargs: Any
360
- ) -> "GetCandleSnapshotQueryMarketdata":
361
- from .get_candle_snapshot_query import GetCandleSnapshotQuery
362
-
363
- query = gql(
364
- """
365
- query GetCandleSnapshotQuery($venue: MarketdataVenue!, $symbol: String!, $candleWidth: CandleWidth!, $start: DateTime!, $end: DateTime!) {
366
- marketdata {
367
- historicalCandles(
368
- venue: $venue
369
- symbol: $symbol
370
- candleWidth: $candleWidth
371
- start: $start
372
- end: $end
373
- ) {
374
- ...CandleFields
375
- }
376
- }
377
- }
378
-
379
- fragment CandleFields on Candle {
380
- timestamp
381
- width
382
- open
383
- high
384
- low
385
- close
386
- volume
387
- }
388
- """
389
- )
390
- variables: Dict[str, object] = {
391
- "venue": venue,
392
- "symbol": symbol,
393
- "candleWidth": candle_width,
394
- "start": convert_datetime_to_utc_str(start),
395
- "end": convert_datetime_to_utc_str(end),
396
- }
397
- response = await self.execute(
398
- query=query,
399
- operation_name="GetCandleSnapshotQuery",
400
- variables=variables,
401
- **kwargs
402
- )
403
- data = self.get_data(response)
404
- return GetCandleSnapshotQuery.model_validate(data).marketdata
405
-
406
- async def get_l_2_book_snapshot_query(
407
- self,
408
- symbol: str,
409
- venue: Union[Optional[str], "UnsetType"] = UNSET,
410
- **kwargs: Any
411
- ) -> "GetL2BookSnapshotQueryMarketdata":
412
- from .get_l_2_book_snapshot_query import GetL2BookSnapshotQuery
413
-
414
- query = gql(
415
- """
416
- query GetL2BookSnapshotQuery($venue: MarketdataVenue, $symbol: String!) {
417
- marketdata {
418
- l2BookSnapshot(venue: $venue, symbol: $symbol) {
419
- ...L2BookFields
420
- }
421
- }
422
- }
423
-
424
- fragment L2BookFields on L2Book {
425
- timestamp
426
- bids {
427
- ...L2BookLevelFields
428
- }
429
- asks {
430
- ...L2BookLevelFields
431
- }
432
- }
433
-
434
- fragment L2BookLevelFields on L2BookLevel {
435
- price
436
- size
437
- }
438
- """
439
- )
440
- variables: Dict[str, object] = {"venue": venue, "symbol": symbol}
441
- response = await self.execute(
442
- query=query,
443
- operation_name="GetL2BookSnapshotQuery",
444
- variables=variables,
445
- **kwargs
446
- )
447
- data = self.get_data(response)
448
- return GetL2BookSnapshotQuery.model_validate(data).marketdata
449
-
450
- async def get_l_1_book_snapshot_query(
451
- self,
452
- symbol: str,
453
- venue: Union[Optional[str], "UnsetType"] = UNSET,
454
- **kwargs: Any
455
- ) -> "GetL1BookSnapshotQueryMarketdata":
456
- from .get_l_1_book_snapshot_query import GetL1BookSnapshotQuery
457
-
458
- query = gql(
459
- """
460
- query GetL1BookSnapshotQuery($venue: MarketdataVenue, $symbol: String!) {
461
- marketdata {
462
- ticker(venue: $venue, symbol: $symbol) {
463
- ...MarketTickerFields
464
- }
465
- }
466
- }
467
-
468
- fragment MarketTickerFields on Ticker {
469
- symbol
470
- timestamp
471
- bidPrice
472
- bidSize
473
- askPrice
474
- askSize
475
- lastPrice
476
- lastSize
477
- }
478
- """
479
- )
480
- variables: Dict[str, object] = {"venue": venue, "symbol": symbol}
481
- response = await self.execute(
482
- query=query,
483
- operation_name="GetL1BookSnapshotQuery",
484
- variables=variables,
485
- **kwargs
486
- )
487
- data = self.get_data(response)
488
- return GetL1BookSnapshotQuery.model_validate(data).marketdata
489
-
490
- async def get_l_1_book_snapshots_query(
491
- self,
492
- venue: str,
493
- symbols: Union[Optional[List[str]], "UnsetType"] = UNSET,
494
- **kwargs: Any
495
- ) -> "GetL1BookSnapshotsQueryMarketdata":
496
- from .get_l_1_book_snapshots_query import GetL1BookSnapshotsQuery
497
-
498
- query = gql(
499
- """
500
- query GetL1BookSnapshotsQuery($venue: MarketdataVenue!, $symbols: [String!]) {
501
- marketdata {
502
- tickers(venue: $venue, symbols: $symbols) {
503
- ...MarketTickerFields
504
- }
505
- }
506
- }
507
-
508
- fragment MarketTickerFields on Ticker {
509
- symbol
510
- timestamp
511
- bidPrice
512
- bidSize
513
- askPrice
514
- askSize
515
- lastPrice
516
- lastSize
517
- }
518
- """
519
- )
520
- variables: Dict[str, object] = {"venue": venue, "symbols": symbols}
521
- response = await self.execute(
522
- query=query,
523
- operation_name="GetL1BookSnapshotsQuery",
524
- variables=variables,
525
- **kwargs
526
- )
527
- data = self.get_data(response)
528
- return GetL1BookSnapshotsQuery.model_validate(data).marketdata
529
-
530
- async def get_market_status_query(
531
- self,
532
- symbol: str,
533
- venue: Union[Optional[str], "UnsetType"] = UNSET,
534
- **kwargs: Any
535
- ) -> "GetMarketStatusQueryMarketdata":
536
- from .get_market_status_query import GetMarketStatusQuery
537
-
538
- query = gql(
539
- """
540
- query GetMarketStatusQuery($venue: MarketdataVenue, $symbol: String!) {
541
- marketdata {
542
- marketStatus(venue: $venue, symbol: $symbol) {
543
- ...MarketStatusFields
544
- }
545
- }
546
- }
547
-
548
- fragment MarketStatusFields on MarketStatus {
549
- symbol
550
- isTrading
551
- isQuoting
552
- }
553
- """
554
- )
555
- variables: Dict[str, object] = {"venue": venue, "symbol": symbol}
556
- response = await self.execute(
557
- query=query,
558
- operation_name="GetMarketStatusQuery",
559
- variables=variables,
560
- **kwargs
561
- )
562
- data = self.get_data(response)
563
- return GetMarketStatusQuery.model_validate(data).marketdata
564
-
565
- async def get_account_query(
566
- self,
567
- id: Union[Optional[UUID], "UnsetType"] = UNSET,
568
- name: Union[Optional[str], "UnsetType"] = UNSET,
569
- **kwargs: Any
570
- ) -> "GetAccountQueryUser":
571
- from .get_account_query import GetAccountQuery
572
-
573
- query = gql(
574
- """
575
- query GetAccountQuery($id: Uuid, $name: AccountName) {
576
- user {
577
- account(id: $id, name: $name) {
578
- ...AccountWithPermissionsFields
579
- }
580
- }
581
- }
582
-
583
- fragment AccountWithPermissionsFields on AccountWithPermissions {
584
- account {
585
- id
586
- name
587
- }
588
- trader
589
- permissions {
590
- list
591
- view
592
- trade
593
- reduceOrClose
594
- setLimits
595
- }
596
- }
597
- """
598
- )
599
- variables: Dict[str, object] = {"id": id, "name": name}
600
- response = await self.execute(
601
- query=query, operation_name="GetAccountQuery", variables=variables, **kwargs
602
- )
603
- data = self.get_data(response)
604
- return GetAccountQuery.model_validate(data).user
605
-
606
- async def list_accounts_query(self, **kwargs: Any) -> "ListAccountsQueryUser":
607
- from .list_accounts_query import ListAccountsQuery
608
-
609
- query = gql(
610
- """
611
- query ListAccountsQuery {
612
- user {
613
- accounts {
614
- ...AccountWithPermissionsFields
615
- }
616
- }
617
- }
618
-
619
- fragment AccountWithPermissionsFields on AccountWithPermissions {
620
- account {
621
- id
622
- name
623
- }
624
- trader
625
- permissions {
626
- list
627
- view
628
- trade
629
- reduceOrClose
630
- setLimits
631
- }
632
- }
633
- """
634
- )
635
- variables: Dict[str, object] = {}
636
- response = await self.execute(
637
- query=query,
638
- operation_name="ListAccountsQuery",
639
- variables=variables,
640
- **kwargs
641
- )
642
- data = self.get_data(response)
643
- return ListAccountsQuery.model_validate(data).user
644
-
645
- async def get_account_summary_query(
646
- self, account: str, **kwargs: Any
647
- ) -> "GetAccountSummaryQueryFolio":
648
- from .get_account_summary_query import GetAccountSummaryQuery
649
-
650
- query = gql(
651
- """
652
- query GetAccountSummaryQuery($account: String!) {
653
- folio {
654
- accountSummary(account: $account) {
655
- ...AccountSummaryFields
656
- }
657
- }
658
- }
659
-
660
- fragment AccountSummaryFields on AccountSummary {
661
- account
662
- timestamp
663
- balances {
664
- product
665
- balance
666
- }
667
- positions {
668
- symbol
669
- quantity
670
- tradeTime
671
- costBasis
672
- breakEvenPrice
673
- liquidationPrice
674
- }
675
- unrealizedPnl
676
- realizedPnl
677
- equity
678
- yesterdayEquity
679
- cashExcess
680
- purchasingPower
681
- totalMargin
682
- positionMargin
683
- }
684
- """
685
- )
686
- variables: Dict[str, object] = {"account": account}
687
- response = await self.execute(
688
- query=query,
689
- operation_name="GetAccountSummaryQuery",
690
- variables=variables,
691
- **kwargs
692
- )
693
- data = self.get_data(response)
694
- return GetAccountSummaryQuery.model_validate(data).folio
695
-
696
- async def get_account_summaries_query(
697
- self,
698
- trader: Union[Optional[str], "UnsetType"] = UNSET,
699
- accounts: Union[Optional[List[str]], "UnsetType"] = UNSET,
700
- **kwargs: Any
701
- ) -> "GetAccountSummariesQueryFolio":
702
- from .get_account_summaries_query import GetAccountSummariesQuery
703
-
704
- query = gql(
705
- """
706
- query GetAccountSummariesQuery($trader: String, $accounts: [String!]) {
707
- folio {
708
- accountSummaries(trader: $trader, accounts: $accounts) {
709
- ...AccountSummaryFields
710
- }
711
- }
712
- }
713
-
714
- fragment AccountSummaryFields on AccountSummary {
715
- account
716
- timestamp
717
- balances {
718
- product
719
- balance
720
- }
721
- positions {
722
- symbol
723
- quantity
724
- tradeTime
725
- costBasis
726
- breakEvenPrice
727
- liquidationPrice
728
- }
729
- unrealizedPnl
730
- realizedPnl
731
- equity
732
- yesterdayEquity
733
- cashExcess
734
- purchasingPower
735
- totalMargin
736
- positionMargin
737
- }
738
- """
739
- )
740
- variables: Dict[str, object] = {"trader": trader, "accounts": accounts}
741
- response = await self.execute(
742
- query=query,
743
- operation_name="GetAccountSummariesQuery",
744
- variables=variables,
745
- **kwargs
746
- )
747
- data = self.get_data(response)
748
- return GetAccountSummariesQuery.model_validate(data).folio
749
-
750
- async def get_account_history_query(
751
- self,
752
- account: str,
753
- from_inclusive: Union[Optional[datetime], "UnsetType"] = UNSET,
754
- to_exclusive: Union[Optional[datetime], "UnsetType"] = UNSET,
755
- **kwargs: Any
756
- ) -> "GetAccountHistoryQueryFolio":
757
- from .get_account_history_query import GetAccountHistoryQuery
758
-
759
- query = gql(
760
- """
761
- query GetAccountHistoryQuery($account: String!, $fromInclusive: DateTime, $toExclusive: DateTime) {
762
- folio {
763
- accountHistory(
764
- account: $account
765
- fromInclusive: $fromInclusive
766
- toExclusive: $toExclusive
767
- ) {
768
- ...AccountSummaryFields
769
- }
770
- }
771
- }
772
-
773
- fragment AccountSummaryFields on AccountSummary {
774
- account
775
- timestamp
776
- balances {
777
- product
778
- balance
779
- }
780
- positions {
781
- symbol
782
- quantity
783
- tradeTime
784
- costBasis
785
- breakEvenPrice
786
- liquidationPrice
787
- }
788
- unrealizedPnl
789
- realizedPnl
790
- equity
791
- yesterdayEquity
792
- cashExcess
793
- purchasingPower
794
- totalMargin
795
- positionMargin
796
- }
797
- """
798
- )
799
- variables: Dict[str, object] = {
800
- "account": account,
801
- "fromInclusive": convert_datetime_to_utc_str(from_inclusive),
802
- "toExclusive": convert_datetime_to_utc_str(to_exclusive),
803
- }
804
- response = await self.execute(
805
- query=query,
806
- operation_name="GetAccountHistoryQuery",
807
- variables=variables,
808
- **kwargs
809
- )
810
- data = self.get_data(response)
811
- return GetAccountHistoryQuery.model_validate(data).folio
812
-
813
- async def get_open_orders_query(
814
- self,
815
- venue: Union[Optional[str], "UnsetType"] = UNSET,
816
- account: Union[Optional[str], "UnsetType"] = UNSET,
817
- trader: Union[Optional[str], "UnsetType"] = UNSET,
818
- symbol: Union[Optional[str], "UnsetType"] = UNSET,
819
- parent_order_id: Union[Optional[str], "UnsetType"] = UNSET,
820
- order_ids: Union[Optional[List[str]], "UnsetType"] = UNSET,
821
- **kwargs: Any
822
- ) -> "GetOpenOrdersQueryOms":
823
- from .get_open_orders_query import GetOpenOrdersQuery
824
-
825
- query = gql(
826
- """
827
- query GetOpenOrdersQuery($venue: ExecutionVenue, $account: String, $trader: String, $symbol: String, $parentOrderId: OrderId, $orderIds: [OrderId!]) {
828
- oms {
829
- openOrders(
830
- venue: $venue
831
- account: $account
832
- trader: $trader
833
- symbol: $symbol
834
- parentOrderId: $parentOrderId
835
- orderIds: $orderIds
836
- ) {
837
- ...OrderFields
838
- }
839
- }
840
- }
841
-
842
- fragment OrderFields on Order {
843
- id
844
- parentId
845
- recvTime
846
- status
847
- rejectReason
848
- rejectMessage
849
- symbol
850
- trader
851
- account
852
- dir
853
- quantity
854
- filledQuantity
855
- averageFillPrice
856
- orderType
857
- limitPrice
858
- postOnly
859
- triggerPrice
860
- timeInForce
861
- goodTilDate
862
- source
863
- executionVenue
864
- }
865
- """
866
- )
867
- variables: Dict[str, object] = {
868
- "venue": venue,
869
- "account": account,
870
- "trader": trader,
871
- "symbol": symbol,
872
- "parentOrderId": parent_order_id,
873
- "orderIds": order_ids,
874
- }
875
- response = await self.execute(
876
- query=query,
877
- operation_name="GetOpenOrdersQuery",
878
- variables=variables,
879
- **kwargs
880
- )
881
- data = self.get_data(response)
882
- return GetOpenOrdersQuery.model_validate(data).oms
883
-
884
- async def get_historical_orders_query(
885
- self,
886
- order_ids: Union[Optional[List[str]], "UnsetType"] = UNSET,
887
- venue: Union[Optional[str], "UnsetType"] = UNSET,
888
- account: Union[Optional[str], "UnsetType"] = UNSET,
889
- parent_order_id: Union[Optional[str], "UnsetType"] = UNSET,
890
- from_inclusive: Union[Optional[datetime], "UnsetType"] = UNSET,
891
- to_exclusive: Union[Optional[datetime], "UnsetType"] = UNSET,
892
- **kwargs: Any
893
- ) -> "GetHistoricalOrdersQueryFolio":
894
- from .get_historical_orders_query import GetHistoricalOrdersQuery
895
-
896
- query = gql(
897
- """
898
- query GetHistoricalOrdersQuery($orderIds: [OrderId!], $venue: ExecutionVenue, $account: String, $parentOrderId: OrderId, $fromInclusive: DateTime, $toExclusive: DateTime) {
899
- folio {
900
- historicalOrders(
901
- orderIds: $orderIds
902
- venue: $venue
903
- account: $account
904
- parentOrderId: $parentOrderId
905
- fromInclusive: $fromInclusive
906
- toExclusive: $toExclusive
907
- ) {
908
- ...OrderFields
909
- }
910
- }
911
- }
912
-
913
- fragment OrderFields on Order {
914
- id
915
- parentId
916
- recvTime
917
- status
918
- rejectReason
919
- rejectMessage
920
- symbol
921
- trader
922
- account
923
- dir
924
- quantity
925
- filledQuantity
926
- averageFillPrice
927
- orderType
928
- limitPrice
929
- postOnly
930
- triggerPrice
931
- timeInForce
932
- goodTilDate
933
- source
934
- executionVenue
935
- }
936
- """
937
- )
938
- variables: Dict[str, object] = {
939
- "orderIds": order_ids,
940
- "venue": venue,
941
- "account": account,
942
- "parentOrderId": parent_order_id,
943
- "fromInclusive": convert_datetime_to_utc_str(from_inclusive),
944
- "toExclusive": convert_datetime_to_utc_str(to_exclusive),
945
- }
946
- response = await self.execute(
947
- query=query,
948
- operation_name="GetHistoricalOrdersQuery",
949
- variables=variables,
950
- **kwargs
951
- )
952
- data = self.get_data(response)
953
- return GetHistoricalOrdersQuery.model_validate(data).folio
954
-
955
- async def get_fills_query(
956
- self,
957
- venue: Union[Optional[str], "UnsetType"] = UNSET,
958
- account: Union[Optional[str], "UnsetType"] = UNSET,
959
- order_id: Union[Optional[str], "UnsetType"] = UNSET,
960
- from_inclusive: Union[Optional[datetime], "UnsetType"] = UNSET,
961
- to_exclusive: Union[Optional[datetime], "UnsetType"] = UNSET,
962
- **kwargs: Any
963
- ) -> "GetFillsQueryFolio":
964
- from .get_fills_query import GetFillsQuery
965
-
966
- query = gql(
967
- """
968
- query GetFillsQuery($venue: ExecutionVenue, $account: String, $orderId: OrderId, $fromInclusive: DateTime, $toExclusive: DateTime) {
969
- folio {
970
- historicalFills(
971
- venue: $venue
972
- account: $account
973
- orderId: $orderId
974
- fromInclusive: $fromInclusive
975
- toExclusive: $toExclusive
976
- ) {
977
- fills {
978
- fillId
979
- fillKind
980
- executionVenue
981
- exchangeFillId
982
- orderId
983
- trader
984
- account
985
- symbol
986
- dir
987
- quantity
988
- price
989
- recvTime
990
- tradeTime
991
- }
992
- aberrantFills {
993
- fillId
994
- fillKind
995
- executionVenue
996
- exchangeFillId
997
- orderId
998
- trader
999
- account
1000
- symbol
1001
- dir
1002
- quantity
1003
- price
1004
- recvTime
1005
- tradeTime
1006
- }
1007
- }
1008
- }
1009
- }
1010
- """
1011
- )
1012
- variables: Dict[str, object] = {
1013
- "venue": venue,
1014
- "account": account,
1015
- "orderId": order_id,
1016
- "fromInclusive": convert_datetime_to_utc_str(from_inclusive),
1017
- "toExclusive": convert_datetime_to_utc_str(to_exclusive),
1018
- }
1019
- response = await self.execute(
1020
- query=query, operation_name="GetFillsQuery", variables=variables, **kwargs
1021
- )
1022
- data = self.get_data(response)
1023
- return GetFillsQuery.model_validate(data).folio
1024
-
1025
- async def subscribe_trades(
1026
- self, venue: str, symbol: str, **kwargs: Any
1027
- ) -> AsyncIterator["SubscribeTradesTrades"]:
1028
- from .subscribe_trades import SubscribeTrades
1029
-
1030
- query = gql(
1031
- """
1032
- subscription SubscribeTrades($venue: MarketdataVenue!, $symbol: String!) {
1033
- trades(venue: $venue, symbol: $symbol) {
1034
- timestamp
1035
- direction
1036
- price
1037
- size
1038
- }
1039
- }
1040
- """
1041
- )
1042
- variables: Dict[str, object] = {"venue": venue, "symbol": symbol}
1043
- async for data in self.execute_ws(
1044
- query=query, operation_name="SubscribeTrades", variables=variables, **kwargs
1045
- ):
1046
- yield SubscribeTrades.model_validate(data).trades
1047
-
1048
- async def subscribe_candles(
1049
- self,
1050
- venue: str,
1051
- symbol: str,
1052
- widths: Union[Optional[List["CandleWidth"]], "UnsetType"] = UNSET,
1053
- **kwargs: Any
1054
- ) -> AsyncIterator["SubscribeCandlesCandles"]:
1055
- from .subscribe_candles import SubscribeCandles
1056
-
1057
- query = gql(
1058
- """
1059
- subscription SubscribeCandles($venue: MarketdataVenue!, $symbol: String!, $widths: [CandleWidth!]) {
1060
- candles(venue: $venue, symbol: $symbol, candleWidths: $widths) {
1061
- ...CandleFields
1062
- }
1063
- }
1064
-
1065
- fragment CandleFields on Candle {
1066
- timestamp
1067
- width
1068
- open
1069
- high
1070
- low
1071
- close
1072
- volume
1073
- }
1074
- """
1075
- )
1076
- variables: Dict[str, object] = {
1077
- "venue": venue,
1078
- "symbol": symbol,
1079
- "widths": widths,
1080
- }
1081
- async for data in self.execute_ws(
1082
- query=query,
1083
- operation_name="SubscribeCandles",
1084
- variables=variables,
1085
- **kwargs
1086
- ):
1087
- yield SubscribeCandles.model_validate(data).candles
1088
-
1089
- async def cancel_order_mutation(
1090
- self, order_id: str, **kwargs: Any
1091
- ) -> "CancelOrderMutationOms":
1092
- from .cancel_order_mutation import CancelOrderMutation
1093
-
1094
- query = gql(
1095
- """
1096
- mutation CancelOrderMutation($orderId: OrderId!) {
1097
- oms {
1098
- cancelOrder(orderId: $orderId) {
1099
- ...CancelFields
1100
- }
1101
- }
1102
- }
1103
-
1104
- fragment CancelFields on Cancel {
1105
- cancelId
1106
- orderId
1107
- recvTime
1108
- status
1109
- rejectReason
1110
- }
1111
- """
1112
- )
1113
- variables: Dict[str, object] = {"orderId": order_id}
1114
- response = await self.execute(
1115
- query=query,
1116
- operation_name="CancelOrderMutation",
1117
- variables=variables,
1118
- **kwargs
1119
- )
1120
- data = self.get_data(response)
1121
- return CancelOrderMutation.model_validate(data).oms
1122
-
1123
- async def cancel_all_orders_mutation(
1124
- self, **kwargs: Any
1125
- ) -> "CancelAllOrdersMutationOms":
1126
- from .cancel_all_orders_mutation import CancelAllOrdersMutation
1127
-
1128
- query = gql(
1129
- """
1130
- mutation CancelAllOrdersMutation {
1131
- oms {
1132
- cancelAllOrders
1133
- }
1134
- }
1135
- """
1136
- )
1137
- variables: Dict[str, object] = {}
1138
- response = await self.execute(
1139
- query=query,
1140
- operation_name="CancelAllOrdersMutation",
1141
- variables=variables,
1142
- **kwargs
1143
- )
1144
- data = self.get_data(response)
1145
- return CancelAllOrdersMutation.model_validate(data).oms
1146
-
1147
- async def place_order_mutation(
1148
- self,
1149
- symbol: str,
1150
- dir: OrderDir,
1151
- quantity: Decimal,
1152
- order_type: "OrderType",
1153
- time_in_force: "TimeInForce",
1154
- id: Union[Optional[str], "UnsetType"] = UNSET,
1155
- trader: Union[Optional[str], "UnsetType"] = UNSET,
1156
- account: Union[Optional[str], "UnsetType"] = UNSET,
1157
- limit_price: Union[Optional[Decimal], "UnsetType"] = UNSET,
1158
- post_only: Union[Optional[bool], "UnsetType"] = UNSET,
1159
- trigger_price: Union[Optional[Decimal], "UnsetType"] = UNSET,
1160
- good_til_date: Union[Optional[datetime], "UnsetType"] = UNSET,
1161
- execution_venue: Union[Optional[str], "UnsetType"] = UNSET,
1162
- **kwargs: Any
1163
- ) -> "PlaceOrderMutationOms":
1164
- from .place_order_mutation import PlaceOrderMutation
1165
-
1166
- query = gql(
1167
- """
1168
- mutation PlaceOrderMutation($id: OrderId, $symbol: String!, $dir: Dir!, $quantity: Decimal!, $trader: String, $account: String, $orderType: OrderType!, $limitPrice: Decimal, $postOnly: Boolean, $triggerPrice: Decimal, $timeInForce: TimeInForce!, $goodTilDate: DateTime, $executionVenue: ExecutionVenue) {
1169
- oms {
1170
- placeOrder(
1171
- id: $id
1172
- symbol: $symbol
1173
- dir: $dir
1174
- quantity: $quantity
1175
- trader: $trader
1176
- account: $account
1177
- orderType: $orderType
1178
- limitPrice: $limitPrice
1179
- postOnly: $postOnly
1180
- triggerPrice: $triggerPrice
1181
- timeInForce: $timeInForce
1182
- goodTilDate: $goodTilDate
1183
- executionVenue: $executionVenue
1184
- ) {
1185
- ...OrderFields
1186
- }
1187
- }
1188
- }
1189
-
1190
- fragment OrderFields on Order {
1191
- id
1192
- parentId
1193
- recvTime
1194
- status
1195
- rejectReason
1196
- rejectMessage
1197
- symbol
1198
- trader
1199
- account
1200
- dir
1201
- quantity
1202
- filledQuantity
1203
- averageFillPrice
1204
- orderType
1205
- limitPrice
1206
- postOnly
1207
- triggerPrice
1208
- timeInForce
1209
- goodTilDate
1210
- source
1211
- executionVenue
1212
- }
1213
- """
1214
- )
1215
- variables: Dict[str, object] = {
1216
- "id": id,
1217
- "symbol": symbol,
1218
- "dir": graphql_serialize_order_dir(dir),
1219
- "quantity": quantity,
1220
- "trader": trader,
1221
- "account": account,
1222
- "orderType": order_type,
1223
- "limitPrice": limit_price,
1224
- "postOnly": post_only,
1225
- "triggerPrice": trigger_price,
1226
- "timeInForce": time_in_force,
1227
- "goodTilDate": convert_datetime_to_utc_str(good_til_date),
1228
- "executionVenue": execution_venue,
1229
- }
1230
- response = await self.execute(
1231
- query=query,
1232
- operation_name="PlaceOrderMutation",
1233
- variables=variables,
1234
- **kwargs
1235
- )
1236
- data = self.get_data(response)
1237
- return PlaceOrderMutation.model_validate(data).oms
1238
-
1239
- async def subscribe_orderflow(self, **kwargs: Any) -> AsyncIterator[
1240
- Union[
1241
- "SubscribeOrderflowOrderflowOrder",
1242
- "SubscribeOrderflowOrderflowOrderAck",
1243
- "SubscribeOrderflowOrderflowGqlOrderReject",
1244
- "SubscribeOrderflowOrderflowOrderOut",
1245
- "SubscribeOrderflowOrderflowOrderStale",
1246
- "SubscribeOrderflowOrderflowCancel",
1247
- "SubscribeOrderflowOrderflowCancelReject",
1248
- "SubscribeOrderflowOrderflowOrderCanceling",
1249
- "SubscribeOrderflowOrderflowOrderCanceled",
1250
- "SubscribeOrderflowOrderflowFill",
1251
- "SubscribeOrderflowOrderflowAberrantFill",
1252
- ]
1253
- ]:
1254
- from .subscribe_orderflow import SubscribeOrderflow
1255
-
1256
- query = gql(
1257
- """
1258
- subscription SubscribeOrderflow {
1259
- orderflow {
1260
- __typename
1261
- ... on Order {
1262
- ...OrderFields
1263
- }
1264
- ... on OrderAck {
1265
- orderId
1266
- }
1267
- ... on OrderCanceled {
1268
- orderId
1269
- cancelId
1270
- }
1271
- ... on GqlOrderReject {
1272
- orderId
1273
- reason
1274
- message
1275
- }
1276
- ... on CancelReject {
1277
- orderId
1278
- message
1279
- }
1280
- ... on Fill {
1281
- fillOrderId: orderId
1282
- fillId
1283
- fillKind
1284
- executionVenue
1285
- exchangeFillId
1286
- symbol
1287
- dir
1288
- quantity
1289
- price
1290
- recvTime
1291
- tradeTime
1292
- }
1293
- ... on OrderOut {
1294
- orderId
1295
- }
1296
- ... on OrderStale {
1297
- orderId
1298
- }
1299
- }
1300
- }
1301
-
1302
- fragment OrderFields on Order {
1303
- id
1304
- parentId
1305
- recvTime
1306
- status
1307
- rejectReason
1308
- rejectMessage
1309
- symbol
1310
- trader
1311
- account
1312
- dir
1313
- quantity
1314
- filledQuantity
1315
- averageFillPrice
1316
- orderType
1317
- limitPrice
1318
- postOnly
1319
- triggerPrice
1320
- timeInForce
1321
- goodTilDate
1322
- source
1323
- executionVenue
1324
- }
1325
- """
1326
- )
1327
- variables: Dict[str, object] = {}
1328
- async for data in self.execute_ws(
1329
- query=query,
1330
- operation_name="SubscribeOrderflow",
1331
- variables=variables,
1332
- **kwargs
1333
- ):
1334
- yield SubscribeOrderflow.model_validate(data).orderflow
1335
-
1336
- async def create_jwt(self, **kwargs: Any) -> "CreateJwtUser":
1337
- from .create_jwt import CreateJwt
1338
-
1339
- query = gql(
1340
- """
1341
- mutation CreateJwt {
1342
- user {
1343
- createJwt
1344
- }
1345
- }
1346
- """
1347
- )
1348
- variables: Dict[str, object] = {}
1349
- response = await self.execute(
1350
- query=query, operation_name="CreateJwt", variables=variables, **kwargs
1351
- )
1352
- data = self.get_data(response)
1353
- return CreateJwt.model_validate(data).user