@adaptic/utils 0.0.1028 → 0.0.1029
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.
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import type Alpaca from "@alpacahq/alpaca-trade-api";
|
|
21
21
|
import type { AlpacaPortfolioHistory } from "../types";
|
|
22
|
-
import type { AccountConfiguration, AlpacaAccountDetails, AlpacaOrder, PortfolioHistoryResponse } from "../types/alpaca-types";
|
|
22
|
+
import type { AccountConfiguration, AlpacaAccountDetails, AlpacaOrder, AlpacaPosition, PortfolioHistoryResponse } from "../types/alpaca-types";
|
|
23
23
|
import type { AlpacaCalendarDay, AlpacaClock } from "./trading/clock";
|
|
24
24
|
/**
|
|
25
25
|
* The portfolio-history payload as the endpoint actually returns it.
|
|
@@ -34,8 +34,23 @@ import type { AlpacaCalendarDay, AlpacaClock } from "./trading/clock";
|
|
|
34
34
|
* — an assertion the compiler rejects and which the vendor's `any` had hidden.
|
|
35
35
|
*/
|
|
36
36
|
export type SdkPortfolioHistoryResponse = PortfolioHistoryResponse & Pick<AlpacaPortfolioHistory, "timeframe">;
|
|
37
|
+
/**
|
|
38
|
+
* One entry of the multi-status body returned by `DELETE /v2/orders`.
|
|
39
|
+
*
|
|
40
|
+
* The endpoint answers 207 with a per-order outcome rather than failing as a
|
|
41
|
+
* whole, so the caller has to inspect each entry's HTTP status to learn which
|
|
42
|
+
* cancellations actually succeeded.
|
|
43
|
+
*/
|
|
44
|
+
export interface AlpacaCancelAllOrdersEntry {
|
|
45
|
+
/** Id of the order this outcome refers to. */
|
|
46
|
+
id: string;
|
|
47
|
+
/** Per-order HTTP status; values >= 400 mark a cancellation that failed. */
|
|
48
|
+
status: number;
|
|
49
|
+
/** Echoed order payload, present only on success. */
|
|
50
|
+
body?: unknown;
|
|
51
|
+
}
|
|
37
52
|
/** SDK methods whose return type this package supersedes. */
|
|
38
|
-
type SupersededSdkMethod = "getAccount" | "getAccountConfigurations" | "getPortfolioHistory" | "getClock" | "getCalendar" | "getOrder" | "getOrderByClientId" | "getOrders" | "createOrder" | "replaceOrder";
|
|
53
|
+
type SupersededSdkMethod = "getAccount" | "getAccountConfigurations" | "getPortfolioHistory" | "getClock" | "getCalendar" | "getOrder" | "getOrderByClientId" | "getOrders" | "createOrder" | "replaceOrder" | "getPositions" | "getPosition" | "closePosition" | "cancelOrder" | "cancelAllOrders" | "updateAccountConfigurations" | "sendRequest";
|
|
39
54
|
/**
|
|
40
55
|
* The Alpaca SDK as this package consumes it: the vendor surface, with the
|
|
41
56
|
* methods above re-declared to return the owned domain types.
|
|
@@ -51,6 +66,22 @@ export type AlpacaSdk = Omit<Alpaca, SupersededSdkMethod> & {
|
|
|
51
66
|
getOrders(params?: unknown): Promise<AlpacaOrder[]>;
|
|
52
67
|
createOrder(params: unknown): Promise<AlpacaOrder>;
|
|
53
68
|
replaceOrder(orderId: string, params: unknown): Promise<AlpacaOrder>;
|
|
69
|
+
getPositions(): Promise<AlpacaPosition[]>;
|
|
70
|
+
getPosition(symbol: string): Promise<AlpacaPosition>;
|
|
71
|
+
/** `DELETE /v2/positions/{symbol}` answers with the closing order. */
|
|
72
|
+
closePosition(symbol: string): Promise<AlpacaOrder>;
|
|
73
|
+
/** `DELETE /v2/orders/{id}` answers 204 with no body. */
|
|
74
|
+
cancelOrder(orderId: string): Promise<void>;
|
|
75
|
+
cancelAllOrders(): Promise<AlpacaCancelAllOrdersEntry[]>;
|
|
76
|
+
updateAccountConfigurations(config: unknown): Promise<AccountConfiguration>;
|
|
77
|
+
/**
|
|
78
|
+
* Escape hatch for endpoints the SDK exposes no method for.
|
|
79
|
+
*
|
|
80
|
+
* The response is whatever that endpoint returns, so it stays `unknown`:
|
|
81
|
+
* this is the one method whose payload cannot be named in advance, and
|
|
82
|
+
* every caller must narrow it against the endpoint it actually invoked.
|
|
83
|
+
*/
|
|
84
|
+
sendRequest(endpoint: string, queryParams?: unknown, body?: unknown, method?: string): Promise<unknown>;
|
|
54
85
|
};
|
|
55
86
|
export {};
|
|
56
87
|
//# sourceMappingURL=sdk-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../../src/alpaca/sdk-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AAErD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,GAChE,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;AAE5C,6DAA6D;AAC7D,KAAK,mBAAmB,GACpB,YAAY,GACZ,0BAA0B,GAC1B,qBAAqB,GACrB,UAAU,GACV,aAAa,GACb,UAAU,GACV,oBAAoB,GACpB,WAAW,GACX,aAAa,GACb,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../../src/alpaca/sdk-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AAErD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM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