@clear-street/clearstreet 0.106.0 → 0.108.0

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 (53) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/resources/v1/index.d.mts +1 -1
  4. package/resources/v1/index.d.mts.map +1 -1
  5. package/resources/v1/index.d.ts +1 -1
  6. package/resources/v1/index.d.ts.map +1 -1
  7. package/resources/v1/index.js.map +1 -1
  8. package/resources/v1/index.mjs.map +1 -1
  9. package/resources/v1/instrument-data/market-data.d.mts +4 -2
  10. package/resources/v1/instrument-data/market-data.d.mts.map +1 -1
  11. package/resources/v1/instrument-data/market-data.d.ts +4 -2
  12. package/resources/v1/instrument-data/market-data.d.ts.map +1 -1
  13. package/resources/v1/instrument-data/market-data.js +4 -2
  14. package/resources/v1/instrument-data/market-data.js.map +1 -1
  15. package/resources/v1/instrument-data/market-data.mjs +4 -2
  16. package/resources/v1/instrument-data/market-data.mjs.map +1 -1
  17. package/resources/v1/instruments.d.mts +13 -9
  18. package/resources/v1/instruments.d.mts.map +1 -1
  19. package/resources/v1/instruments.d.ts +13 -9
  20. package/resources/v1/instruments.d.ts.map +1 -1
  21. package/resources/v1/locates.d.mts +0 -8
  22. package/resources/v1/locates.d.mts.map +1 -1
  23. package/resources/v1/locates.d.ts +0 -8
  24. package/resources/v1/locates.d.ts.map +1 -1
  25. package/resources/v1/locates.js +0 -8
  26. package/resources/v1/locates.js.map +1 -1
  27. package/resources/v1/locates.mjs +0 -8
  28. package/resources/v1/locates.mjs.map +1 -1
  29. package/resources/v1/orders.d.mts +246 -1
  30. package/resources/v1/orders.d.mts.map +1 -1
  31. package/resources/v1/orders.d.ts +246 -1
  32. package/resources/v1/orders.d.ts.map +1 -1
  33. package/resources/v1/orders.js +40 -0
  34. package/resources/v1/orders.js.map +1 -1
  35. package/resources/v1/orders.mjs +40 -0
  36. package/resources/v1/orders.mjs.map +1 -1
  37. package/resources/v1/v1.d.mts +2 -2
  38. package/resources/v1/v1.d.mts.map +1 -1
  39. package/resources/v1/v1.d.ts +2 -2
  40. package/resources/v1/v1.d.ts.map +1 -1
  41. package/resources/v1/v1.js.map +1 -1
  42. package/resources/v1/v1.mjs.map +1 -1
  43. package/src/resources/v1/index.ts +11 -0
  44. package/src/resources/v1/instrument-data/market-data.ts +4 -2
  45. package/src/resources/v1/instruments.ts +14 -9
  46. package/src/resources/v1/locates.ts +0 -8
  47. package/src/resources/v1/orders.ts +298 -0
  48. package/src/resources/v1/v1.ts +22 -0
  49. package/src/version.ts +1 -1
  50. package/version.d.mts +1 -1
  51. package/version.d.ts +1 -1
  52. package/version.js +1 -1
  53. package/version.mjs +1 -1
@@ -1,6 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
+ import * as OrdersAPI from './orders';
4
5
  import * as Shared from '../shared';
5
6
  import * as V1API from './v1';
6
7
  import { APIPromise } from '../../core/api-promise';
@@ -110,6 +111,51 @@ export class Orders extends APIResource {
110
111
  return this._client.get(path`/v1/accounts/${accountID}/orders`, { query, ...options });
111
112
  }
112
113
 
114
+ /**
115
+ * Preview the impact of orders without submitting them. For each order the engine
116
+ * evaluates every pre-trade risk check and projects the account's balances and
117
+ * positions as if the order were fully filled — at the limit price for limit
118
+ * orders and at the current reference price for market orders. Orders are
119
+ * evaluated independently: they do not see each other's projected fills. Nothing
120
+ * is submitted and no account state changes.
121
+ *
122
+ * The response carries one result per requested order, in request order. When the
123
+ * request contains more than one order, every order must carry a unique `id`,
124
+ * which is echoed on its result. An order that cannot be previewed gets an `error`
125
+ * on its own result without affecting the rest of the batch; the response is still
126
+ * `200 OK` — per-order outcomes live only in the rows, and non-2xx statuses are
127
+ * reserved for request-level failures (invalid batch, authorization, engine
128
+ * unavailable).
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * const response = await client.v1.orders.previewOrders(0, {
133
+ * preview: [
134
+ * {
135
+ * order_type: 'LIMIT',
136
+ * quantity: '100',
137
+ * side: 'BUY',
138
+ * time_in_force: 'DAY',
139
+ * },
140
+ * {
141
+ * order_type: 'LIMIT',
142
+ * quantity: '10',
143
+ * side: 'BUY',
144
+ * time_in_force: 'DAY',
145
+ * },
146
+ * ],
147
+ * });
148
+ * ```
149
+ */
150
+ previewOrders(
151
+ accountID: number,
152
+ params: OrderPreviewOrdersParams,
153
+ options?: RequestOptions,
154
+ ): APIPromise<OrderPreviewOrdersResponse> {
155
+ const { preview } = params;
156
+ return this._client.post(path`/v1/accounts/${accountID}/orders/preview`, { body: preview, ...options });
157
+ }
158
+
113
159
  /**
114
160
  * Replace an order with new parameters
115
161
  *
@@ -578,6 +624,239 @@ export namespace Order {
578
624
 
579
625
  export type OrderList = Array<Order>;
580
626
 
627
+ /**
628
+ * The projected impact of an order, as if it were submitted and fully filled.
629
+ */
630
+ export interface OrderPreview {
631
+ /**
632
+ * The account the order was previewed for.
633
+ */
634
+ account_id: number;
635
+
636
+ /**
637
+ * Monetary size of the previewed order.
638
+ */
639
+ amount: OrderPreviewAmount;
640
+
641
+ /**
642
+ * Buying power before and after the order.
643
+ */
644
+ buying_power: OrderPreviewDelta;
645
+
646
+ /**
647
+ * Currency for all monetary values.
648
+ */
649
+ currency: string;
650
+
651
+ /**
652
+ * Account equity before and after the order.
653
+ */
654
+ equity: OrderPreviewDelta;
655
+
656
+ /**
657
+ * Risk-check errors that would prevent the order from being accepted. Empty when
658
+ * the order would pass every pre-trade risk check.
659
+ */
660
+ errors: Array<OrderPreviewError>;
661
+
662
+ /**
663
+ * Margin requirements and excess before and after the order.
664
+ */
665
+ margin_details: OrderPreviewMarginDetails;
666
+
667
+ /**
668
+ * Positions in the traded instruments before and after the order.
669
+ */
670
+ positions: Array<OrderPreviewPosition>;
671
+ }
672
+
673
+ /**
674
+ * Monetary size of the previewed order.
675
+ */
676
+ export interface OrderPreviewAmount {
677
+ /**
678
+ * Total cash impact of the order before estimated fees and commissions.
679
+ */
680
+ gross_amount: string;
681
+
682
+ /**
683
+ * Total cash impact of the order after estimated fees and commissions.
684
+ */
685
+ net_amount: string;
686
+ }
687
+
688
+ /**
689
+ * Before/after values for one metric, as if the previewed order fully filled.
690
+ */
691
+ export interface OrderPreviewDelta {
692
+ /**
693
+ * The value with the previewed order also fully filled.
694
+ */
695
+ after: string;
696
+
697
+ /**
698
+ * The value before the order, as the risk engine evaluates it: the account's open
699
+ * orders are projected as filled.
700
+ */
701
+ before: string;
702
+
703
+ /**
704
+ * The previewed order's isolated impact: `after - before`.
705
+ */
706
+ change: string;
707
+ }
708
+
709
+ /**
710
+ * One requested order's entry in the batch response.
711
+ */
712
+ export type OrderPreviewEntry = OrderPreviewEntry.UnionMember0 | OrderPreviewEntry.UnionMember1;
713
+
714
+ export namespace OrderPreviewEntry {
715
+ /**
716
+ * The order was previewed successfully.
717
+ */
718
+ export interface UnionMember0 {
719
+ /**
720
+ * The projected impact of the order.
721
+ */
722
+ preview: OrdersAPI.OrderPreview;
723
+
724
+ /**
725
+ * The client-provided `id` of the order this entry belongs to, echoed from the
726
+ * request. Always present when the request contains more than one order, since ids
727
+ * are required there.
728
+ */
729
+ id?: string | null;
730
+ }
731
+
732
+ /**
733
+ * The order could not be previewed. Shaped exactly like the top-level `error`
734
+ * object on rejected submissions.
735
+ */
736
+ export interface UnionMember1 {
737
+ /**
738
+ * Why this order's preview failed.
739
+ */
740
+ error: Shared.APIError;
741
+
742
+ /**
743
+ * The client-provided `id` of the order this entry belongs to, echoed from the
744
+ * request. Always present when the request contains more than one order, since ids
745
+ * are required there.
746
+ */
747
+ id?: string | null;
748
+ }
749
+ }
750
+
751
+ export type OrderPreviewEntryList = Array<OrderPreviewEntry>;
752
+
753
+ /**
754
+ * One pre-trade risk-check error the order would trigger, shaped like the
755
+ * violation entries in `ApiError.details[]` on rejected submissions.
756
+ */
757
+ export interface OrderPreviewError {
758
+ /**
759
+ * Human-readable description of the error.
760
+ */
761
+ description: string;
762
+
763
+ /**
764
+ * Structured details for the error (stringified values), e.g. required and
765
+ * available amounts, and `leg_index`/`leg_symbol` for multileg leg errors.
766
+ */
767
+ metadata: { [key: string]: string };
768
+
769
+ /**
770
+ * Stable error code.
771
+ */
772
+ type: string;
773
+ }
774
+
775
+ /**
776
+ * Margin requirements and excess before and after the previewed order.
777
+ */
778
+ export interface OrderPreviewMarginDetails {
779
+ /**
780
+ * Initial margin excess.
781
+ */
782
+ initial_margin_excess: OrderPreviewDelta;
783
+
784
+ /**
785
+ * Initial margin requirement.
786
+ */
787
+ initial_margin_requirement: OrderPreviewDelta;
788
+
789
+ /**
790
+ * Maintenance margin excess.
791
+ */
792
+ maintenance_margin_excess: OrderPreviewDelta;
793
+
794
+ /**
795
+ * Maintenance margin requirement.
796
+ */
797
+ maintenance_margin_requirement: OrderPreviewDelta;
798
+
799
+ /**
800
+ * Overnight margin excess.
801
+ */
802
+ overnight_margin_excess: OrderPreviewDelta;
803
+
804
+ /**
805
+ * Overnight margin requirement.
806
+ */
807
+ overnight_margin_requirement: OrderPreviewDelta;
808
+ }
809
+
810
+ /**
811
+ * Either a successful preview or the error that prevented one, for a single order
812
+ * in the batch.
813
+ */
814
+ export type OrderPreviewOutcome = OrderPreviewOutcome.Preview | OrderPreviewOutcome.Error;
815
+
816
+ export namespace OrderPreviewOutcome {
817
+ /**
818
+ * The order was previewed successfully.
819
+ */
820
+ export interface Preview {
821
+ /**
822
+ * The projected impact of the order.
823
+ */
824
+ preview: OrdersAPI.OrderPreview;
825
+ }
826
+
827
+ /**
828
+ * The order could not be previewed. Shaped exactly like the top-level `error`
829
+ * object on rejected submissions.
830
+ */
831
+ export interface Error {
832
+ /**
833
+ * Why this order's preview failed.
834
+ */
835
+ error: Shared.APIError;
836
+ }
837
+ }
838
+
839
+ /**
840
+ * One instrument's position before and after the previewed order. Only the traded
841
+ * instruments appear; cash effects are carried by the monetary fields.
842
+ */
843
+ export interface OrderPreviewPosition {
844
+ /**
845
+ * The instrument's identifier.
846
+ */
847
+ instrument_id: string;
848
+
849
+ /**
850
+ * Net position quantity before and after the order.
851
+ */
852
+ quantity: OrderPreviewDelta;
853
+
854
+ /**
855
+ * The instrument's symbol.
856
+ */
857
+ symbol: string;
858
+ }
859
+
581
860
  /**
582
861
  * Order status
583
862
  */
@@ -822,6 +1101,10 @@ export interface OrderGetOrdersResponse extends Shared.BaseResponse {
822
1101
  data: OrderList;
823
1102
  }
824
1103
 
1104
+ export interface OrderPreviewOrdersResponse extends Shared.BaseResponse {
1105
+ data: OrderPreviewEntryList;
1106
+ }
1107
+
825
1108
  export interface OrderReplaceOrderResponse extends Shared.BaseResponse {
826
1109
  /**
827
1110
  * A trading order with its current state and execution details.
@@ -1039,6 +1322,10 @@ export namespace OrderGetOrdersParams {
1039
1322
  }
1040
1323
  }
1041
1324
 
1325
+ export interface OrderPreviewOrdersParams {
1326
+ preview: Array<NewOrderRequest>;
1327
+ }
1328
+
1042
1329
  export interface OrderReplaceOrderParams {
1043
1330
  /**
1044
1331
  * Path param: Account identifier
@@ -1088,6 +1375,15 @@ export declare namespace Orders {
1088
1375
  type NewOrderRequest as NewOrderRequest,
1089
1376
  type Order as Order,
1090
1377
  type OrderList as OrderList,
1378
+ type OrderPreview as OrderPreview,
1379
+ type OrderPreviewAmount as OrderPreviewAmount,
1380
+ type OrderPreviewDelta as OrderPreviewDelta,
1381
+ type OrderPreviewEntry as OrderPreviewEntry,
1382
+ type OrderPreviewEntryList as OrderPreviewEntryList,
1383
+ type OrderPreviewError as OrderPreviewError,
1384
+ type OrderPreviewMarginDetails as OrderPreviewMarginDetails,
1385
+ type OrderPreviewOutcome as OrderPreviewOutcome,
1386
+ type OrderPreviewPosition as OrderPreviewPosition,
1091
1387
  type OrderStatus as OrderStatus,
1092
1388
  type OrderStrategy as OrderStrategy,
1093
1389
  type OrderType as OrderType,
@@ -1104,6 +1400,7 @@ export declare namespace Orders {
1104
1400
  type OrderGetExecutionsResponse as OrderGetExecutionsResponse,
1105
1401
  type OrderGetOrderByIDResponse as OrderGetOrderByIDResponse,
1106
1402
  type OrderGetOrdersResponse as OrderGetOrdersResponse,
1403
+ type OrderPreviewOrdersResponse as OrderPreviewOrdersResponse,
1107
1404
  type OrderReplaceOrderResponse as OrderReplaceOrderResponse,
1108
1405
  type OrderSubmitOrdersResponse as OrderSubmitOrdersResponse,
1109
1406
  type OrderCancelAllOpenOrdersParams as OrderCancelAllOpenOrdersParams,
@@ -1111,6 +1408,7 @@ export declare namespace Orders {
1111
1408
  type OrderGetExecutionsParams as OrderGetExecutionsParams,
1112
1409
  type OrderGetOrderByIDParams as OrderGetOrderByIDParams,
1113
1410
  type OrderGetOrdersParams as OrderGetOrdersParams,
1411
+ type OrderPreviewOrdersParams as OrderPreviewOrdersParams,
1114
1412
  type OrderReplaceOrderParams as OrderReplaceOrderParams,
1115
1413
  type OrderSubmitOrdersParams as OrderSubmitOrdersParams,
1116
1414
  };
@@ -128,6 +128,17 @@ import {
128
128
  OrderGetOrdersParams,
129
129
  OrderGetOrdersResponse,
130
130
  OrderList,
131
+ OrderPreview,
132
+ OrderPreviewAmount,
133
+ OrderPreviewDelta,
134
+ OrderPreviewEntry,
135
+ OrderPreviewEntryList,
136
+ OrderPreviewError,
137
+ OrderPreviewMarginDetails,
138
+ OrderPreviewOrdersParams,
139
+ OrderPreviewOrdersResponse,
140
+ OrderPreviewOutcome,
141
+ OrderPreviewPosition,
131
142
  OrderReplaceOrderParams,
132
143
  OrderReplaceOrderResponse,
133
144
  OrderStatus,
@@ -581,6 +592,15 @@ export declare namespace V1 {
581
592
  type NewOrderRequest as NewOrderRequest,
582
593
  type Order as Order,
583
594
  type OrderList as OrderList,
595
+ type OrderPreview as OrderPreview,
596
+ type OrderPreviewAmount as OrderPreviewAmount,
597
+ type OrderPreviewDelta as OrderPreviewDelta,
598
+ type OrderPreviewEntry as OrderPreviewEntry,
599
+ type OrderPreviewEntryList as OrderPreviewEntryList,
600
+ type OrderPreviewError as OrderPreviewError,
601
+ type OrderPreviewMarginDetails as OrderPreviewMarginDetails,
602
+ type OrderPreviewOutcome as OrderPreviewOutcome,
603
+ type OrderPreviewPosition as OrderPreviewPosition,
584
604
  type OrderStatus as OrderStatus,
585
605
  type OrderStrategy as OrderStrategy,
586
606
  type OrderType as OrderType,
@@ -597,6 +617,7 @@ export declare namespace V1 {
597
617
  type OrderGetExecutionsResponse as OrderGetExecutionsResponse,
598
618
  type OrderGetOrderByIDResponse as OrderGetOrderByIDResponse,
599
619
  type OrderGetOrdersResponse as OrderGetOrdersResponse,
620
+ type OrderPreviewOrdersResponse as OrderPreviewOrdersResponse,
600
621
  type OrderReplaceOrderResponse as OrderReplaceOrderResponse,
601
622
  type OrderSubmitOrdersResponse as OrderSubmitOrdersResponse,
602
623
  type OrderCancelAllOpenOrdersParams as OrderCancelAllOpenOrdersParams,
@@ -604,6 +625,7 @@ export declare namespace V1 {
604
625
  type OrderGetExecutionsParams as OrderGetExecutionsParams,
605
626
  type OrderGetOrderByIDParams as OrderGetOrderByIDParams,
606
627
  type OrderGetOrdersParams as OrderGetOrdersParams,
628
+ type OrderPreviewOrdersParams as OrderPreviewOrdersParams,
607
629
  type OrderReplaceOrderParams as OrderReplaceOrderParams,
608
630
  type OrderSubmitOrdersParams as OrderSubmitOrdersParams,
609
631
  };
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.106.0'; // x-release-please-version
1
+ export const VERSION = '0.108.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.106.0";
1
+ export declare const VERSION = "0.108.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.106.0";
1
+ export declare const VERSION = "0.108.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.106.0'; // x-release-please-version
4
+ exports.VERSION = '0.108.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.106.0'; // x-release-please-version
1
+ export const VERSION = '0.108.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map