@adaptic/utils 0.1.1 → 0.1.3
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.
- package/README.md +153 -61
- package/dist/index.cjs +10383 -3818
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10309 -3819
- package/dist/index.mjs.map +1 -1
- package/dist/test.js +733 -383
- package/dist/test.js.map +1 -1
- package/dist/types/__tests__/alpaca-functions.test.d.ts +2 -0
- package/dist/types/__tests__/alpaca-functions.test.d.ts.map +1 -0
- package/dist/types/__tests__/api-endpoints.test.d.ts +2 -0
- package/dist/types/__tests__/api-endpoints.test.d.ts.map +1 -0
- package/dist/types/__tests__/asset-allocation.test.d.ts +2 -0
- package/dist/types/__tests__/asset-allocation.test.d.ts.map +1 -0
- package/dist/types/__tests__/auth-validator.test.d.ts +2 -0
- package/dist/types/__tests__/auth-validator.test.d.ts.map +1 -0
- package/dist/types/__tests__/cache.test.d.ts +2 -0
- package/dist/types/__tests__/cache.test.d.ts.map +1 -0
- package/dist/types/__tests__/errors.test.d.ts +2 -0
- package/dist/types/__tests__/errors.test.d.ts.map +1 -0
- package/dist/types/__tests__/financial-regression.test.d.ts +2 -0
- package/dist/types/__tests__/financial-regression.test.d.ts.map +1 -0
- package/dist/types/__tests__/format-tools.test.d.ts +2 -0
- package/dist/types/__tests__/format-tools.test.d.ts.map +1 -0
- package/dist/types/__tests__/http-keep-alive.test.d.ts +2 -0
- package/dist/types/__tests__/http-keep-alive.test.d.ts.map +1 -0
- package/dist/types/__tests__/http-timeout.test.d.ts +2 -0
- package/dist/types/__tests__/http-timeout.test.d.ts.map +1 -0
- package/dist/types/__tests__/logger.test.d.ts +2 -0
- package/dist/types/__tests__/logger.test.d.ts.map +1 -0
- package/dist/types/__tests__/market-time.test.d.ts +2 -0
- package/dist/types/__tests__/market-time.test.d.ts.map +1 -0
- package/dist/types/__tests__/misc-utils.test.d.ts +2 -0
- package/dist/types/__tests__/misc-utils.test.d.ts.map +1 -0
- package/dist/types/__tests__/paginator.test.d.ts +2 -0
- package/dist/types/__tests__/paginator.test.d.ts.map +1 -0
- package/dist/types/__tests__/performance-metrics.test.d.ts +2 -0
- package/dist/types/__tests__/performance-metrics.test.d.ts.map +1 -0
- package/dist/types/__tests__/polygon.test.d.ts +2 -0
- package/dist/types/__tests__/polygon.test.d.ts.map +1 -0
- package/dist/types/__tests__/price-utils.test.d.ts +2 -0
- package/dist/types/__tests__/price-utils.test.d.ts.map +1 -0
- package/dist/types/__tests__/property-based-financial.test.d.ts +2 -0
- package/dist/types/__tests__/property-based-financial.test.d.ts.map +1 -0
- package/dist/types/__tests__/rate-limiter.test.d.ts +2 -0
- package/dist/types/__tests__/rate-limiter.test.d.ts.map +1 -0
- package/dist/types/__tests__/schema-validation.test.d.ts +2 -0
- package/dist/types/__tests__/schema-validation.test.d.ts.map +1 -0
- package/dist/types/__tests__/technical-analysis.test.d.ts +2 -0
- package/dist/types/__tests__/technical-analysis.test.d.ts.map +1 -0
- package/dist/types/__tests__/time-utils.test.d.ts +2 -0
- package/dist/types/__tests__/time-utils.test.d.ts.map +1 -0
- package/dist/types/adaptic.d.ts +2 -2
- package/dist/types/adaptic.d.ts.map +1 -1
- package/dist/types/alpaca/client.d.ts +4 -4
- package/dist/types/alpaca/client.d.ts.map +1 -1
- package/dist/types/alpaca/crypto/data.d.ts +5 -5
- package/dist/types/alpaca/crypto/data.d.ts.map +1 -1
- package/dist/types/alpaca/crypto/index.d.ts +2 -2
- package/dist/types/alpaca/crypto/orders.d.ts +2 -2
- package/dist/types/alpaca/crypto/orders.d.ts.map +1 -1
- package/dist/types/alpaca/index.d.ts +36 -34
- package/dist/types/alpaca/index.d.ts.map +1 -1
- package/dist/types/alpaca/legacy/account.d.ts +34 -0
- package/dist/types/alpaca/legacy/account.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/assets.d.ts +13 -0
- package/dist/types/alpaca/legacy/assets.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/auth.d.ts +18 -0
- package/dist/types/alpaca/legacy/auth.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/index.d.ts +15 -0
- package/dist/types/alpaca/legacy/index.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/market-data.d.ts +32 -0
- package/dist/types/alpaca/legacy/market-data.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/orders.d.ts +84 -0
- package/dist/types/alpaca/legacy/orders.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/positions.d.ts +66 -0
- package/dist/types/alpaca/legacy/positions.d.ts.map +1 -0
- package/dist/types/alpaca/legacy/utils.d.ts +18 -0
- package/dist/types/alpaca/legacy/utils.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/bars.d.ts +4 -4
- package/dist/types/alpaca/market-data/bars.d.ts.map +1 -1
- package/dist/types/alpaca/market-data/index.d.ts +8 -8
- package/dist/types/alpaca/market-data/news.d.ts +3 -3
- package/dist/types/alpaca/market-data/news.d.ts.map +1 -1
- package/dist/types/alpaca/market-data/quotes.d.ts +2 -2
- package/dist/types/alpaca/market-data/quotes.d.ts.map +1 -1
- package/dist/types/alpaca/market-data/trades.d.ts +2 -2
- package/dist/types/alpaca/market-data/trades.d.ts.map +1 -1
- package/dist/types/alpaca/options/contracts.d.ts +2 -2
- package/dist/types/alpaca/options/contracts.d.ts.map +1 -1
- package/dist/types/alpaca/options/data.d.ts +5 -5
- package/dist/types/alpaca/options/data.d.ts.map +1 -1
- package/dist/types/alpaca/options/index.d.ts +12 -12
- package/dist/types/alpaca/options/index.d.ts.map +1 -1
- package/dist/types/alpaca/options/orders.d.ts +4 -4
- package/dist/types/alpaca/options/orders.d.ts.map +1 -1
- package/dist/types/alpaca/options/strategies.d.ts +9 -9
- package/dist/types/alpaca/options/strategies.d.ts.map +1 -1
- package/dist/types/alpaca/streams/base-stream.d.ts +5 -5
- package/dist/types/alpaca/streams/base-stream.d.ts.map +1 -1
- package/dist/types/alpaca/streams/crypto-stream.d.ts +5 -5
- package/dist/types/alpaca/streams/crypto-stream.d.ts.map +1 -1
- package/dist/types/alpaca/streams/index.d.ts +6 -6
- package/dist/types/alpaca/streams/option-stream.d.ts +5 -5
- package/dist/types/alpaca/streams/option-stream.d.ts.map +1 -1
- package/dist/types/alpaca/streams/stock-stream.d.ts +5 -5
- package/dist/types/alpaca/streams/stock-stream.d.ts.map +1 -1
- package/dist/types/alpaca/streams/stream-manager.d.ts +16 -16
- package/dist/types/alpaca/streams/stream-manager.d.ts.map +1 -1
- package/dist/types/alpaca/streams/trading-stream.d.ts +28 -28
- package/dist/types/alpaca/streams/trading-stream.d.ts.map +1 -1
- package/dist/types/alpaca/streams.d.ts +2 -2
- package/dist/types/alpaca/streams.d.ts.map +1 -1
- package/dist/types/alpaca/trading/account.d.ts +2 -2
- package/dist/types/alpaca/trading/account.d.ts.map +1 -1
- package/dist/types/alpaca/trading/bracket-orders.d.ts +3 -3
- package/dist/types/alpaca/trading/bracket-orders.d.ts.map +1 -1
- package/dist/types/alpaca/trading/index.d.ts +12 -12
- package/dist/types/alpaca/trading/oco-orders.d.ts +2 -2
- package/dist/types/alpaca/trading/oco-orders.d.ts.map +1 -1
- package/dist/types/alpaca/trading/order-utils.d.ts +9 -9
- package/dist/types/alpaca/trading/order-utils.d.ts.map +1 -1
- package/dist/types/alpaca/trading/orders.d.ts +2 -2
- package/dist/types/alpaca/trading/orders.d.ts.map +1 -1
- package/dist/types/alpaca/trading/oto-orders.d.ts +3 -3
- package/dist/types/alpaca/trading/oto-orders.d.ts.map +1 -1
- package/dist/types/alpaca/trading/positions.d.ts +3 -3
- package/dist/types/alpaca/trading/positions.d.ts.map +1 -1
- package/dist/types/alpaca/trading/smart-orders.d.ts +12 -12
- package/dist/types/alpaca/trading/smart-orders.d.ts.map +1 -1
- package/dist/types/alpaca/trading/trailing-stops.d.ts +2 -2
- package/dist/types/alpaca/trading/trailing-stops.d.ts.map +1 -1
- package/dist/types/alpaca-market-data-api.d.ts +12 -10
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -1
- package/dist/types/alpaca-trading-api.d.ts +12 -12
- package/dist/types/alpaca-trading-api.d.ts.map +1 -1
- package/dist/types/alphavantage.d.ts +1 -1
- package/dist/types/alphavantage.d.ts.map +1 -1
- package/dist/types/asset-allocation-algorithm.d.ts +7 -1
- package/dist/types/asset-allocation-algorithm.d.ts.map +1 -1
- package/dist/types/cache/stampede-protected-cache.d.ts.map +1 -1
- package/dist/types/config/api-endpoints.d.ts +94 -0
- package/dist/types/config/api-endpoints.d.ts.map +1 -0
- package/dist/types/crypto.d.ts +2 -2
- package/dist/types/crypto.d.ts.map +1 -1
- package/dist/types/display-manager.d.ts +1 -1
- package/dist/types/display-manager.d.ts.map +1 -1
- package/dist/types/errors/index.d.ts +130 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/examples/asset-allocation-example.d.ts +7 -6
- package/dist/types/examples/asset-allocation-example.d.ts.map +1 -1
- package/dist/types/examples/rate-limiter-example.d.ts +7 -0
- package/dist/types/examples/rate-limiter-example.d.ts.map +1 -0
- package/dist/types/format-tools.d.ts.map +1 -1
- package/dist/types/http-timeout.d.ts +37 -0
- package/dist/types/http-timeout.d.ts.map +1 -0
- package/dist/types/index.d.ts +59 -72
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +56 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logging.d.ts +1 -1
- package/dist/types/logging.d.ts.map +1 -1
- package/dist/types/market-hours.d.ts.map +1 -1
- package/dist/types/market-time.d.ts +75 -13
- package/dist/types/market-time.d.ts.map +1 -1
- package/dist/types/metrics-calcs.d.ts.map +1 -1
- package/dist/types/misc-utils.d.ts +4 -1
- package/dist/types/misc-utils.d.ts.map +1 -1
- package/dist/types/performance-metrics.d.ts +4 -4
- package/dist/types/performance-metrics.d.ts.map +1 -1
- package/dist/types/polygon-indices.d.ts +3 -3
- package/dist/types/polygon-indices.d.ts.map +1 -1
- package/dist/types/polygon.d.ts +1 -1
- package/dist/types/polygon.d.ts.map +1 -1
- package/dist/types/price-utils.d.ts.map +1 -1
- package/dist/types/rate-limiter.d.ts +171 -0
- package/dist/types/rate-limiter.d.ts.map +1 -0
- package/dist/types/schemas/alpaca-schemas.d.ts +779 -0
- package/dist/types/schemas/alpaca-schemas.d.ts.map +1 -0
- package/dist/types/schemas/alphavantage-schemas.d.ts +255 -0
- package/dist/types/schemas/alphavantage-schemas.d.ts.map +1 -0
- package/dist/types/schemas/index.d.ts +21 -0
- package/dist/types/schemas/index.d.ts.map +1 -0
- package/dist/types/schemas/polygon-schemas.d.ts +551 -0
- package/dist/types/schemas/polygon-schemas.d.ts.map +1 -0
- package/dist/types/schemas/validate-response.d.ts +88 -0
- package/dist/types/schemas/validate-response.d.ts.map +1 -0
- package/dist/types/technical-analysis.d.ts +9 -9
- package/dist/types/technical-analysis.d.ts.map +1 -1
- package/dist/types/time-utils.d.ts.map +1 -1
- package/dist/types/types/adaptic-types.d.ts +1 -1
- package/dist/types/types/adaptic-types.d.ts.map +1 -1
- package/dist/types/types/alpaca-types.d.ts +172 -98
- package/dist/types/types/alpaca-types.d.ts.map +1 -1
- package/dist/types/types/alphavantage-types.d.ts +2 -2
- package/dist/types/types/asset-allocation-types.d.ts +11 -11
- package/dist/types/types/index.d.ts +8 -8
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/logging-types.d.ts +2 -2
- package/dist/types/types/logging-types.d.ts.map +1 -1
- package/dist/types/types/market-time-types.d.ts +4 -4
- package/dist/types/types/market-time-types.d.ts.map +1 -1
- package/dist/types/types/metrics-types.d.ts +3 -3
- package/dist/types/types/metrics-types.d.ts.map +1 -1
- package/dist/types/types/polygon-indices-types.d.ts +6 -6
- package/dist/types/types/polygon-types.d.ts +3 -3
- package/dist/types/types/ta-types.d.ts +3 -3
- package/dist/types/utils/auth-validator.d.ts +32 -0
- package/dist/types/utils/auth-validator.d.ts.map +1 -0
- package/dist/types/utils/http-keep-alive.d.ts +110 -0
- package/dist/types/utils/http-keep-alive.d.ts.map +1 -0
- package/dist/types/utils/paginator.d.ts +154 -0
- package/dist/types/utils/paginator.d.ts.map +1 -0
- package/dist/types/utils/retry.d.ts +78 -0
- package/dist/types/utils/retry.d.ts.map +1 -0
- package/package.json +22 -5
- package/dist/types/alpaca-functions.d.ts +0 -233
- package/dist/types/alpaca-functions.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ApolloClientType, NormalizedCacheObject } from
|
|
2
|
-
import { types } from
|
|
1
|
+
import { ApolloClientType, NormalizedCacheObject } from "@adaptic/backend-legacy";
|
|
2
|
+
import { types } from "@adaptic/backend-legacy";
|
|
3
3
|
/**
|
|
4
4
|
* Represents the authentication details for Alpaca.
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@ export interface AlpacaAuth {
|
|
|
7
7
|
adapticAccountId?: string;
|
|
8
8
|
alpacaApiKey?: string;
|
|
9
9
|
alpacaApiSecret?: string;
|
|
10
|
-
type?:
|
|
10
|
+
type?: "PAPER" | "LIVE";
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Options for fetching Alpaca account details.
|
|
@@ -40,13 +40,13 @@ export interface AccountConfiguration {
|
|
|
40
40
|
cryptoTradeAllocationPct?: number;
|
|
41
41
|
autoAllocation?: boolean;
|
|
42
42
|
allocation?: AllocationConfig;
|
|
43
|
-
dtbp_check:
|
|
44
|
-
trade_confirm_email:
|
|
43
|
+
dtbp_check: "both" | "entry" | "exit";
|
|
44
|
+
trade_confirm_email: "all" | "none";
|
|
45
45
|
no_shorting: boolean;
|
|
46
46
|
fractional_trading: boolean;
|
|
47
|
-
max_margin_multiplier:
|
|
47
|
+
max_margin_multiplier: "1" | "2" | "4";
|
|
48
48
|
max_options_trading_level?: 0 | 1 | 2 | 3;
|
|
49
|
-
pdt_check:
|
|
49
|
+
pdt_check: "both" | "entry" | "exit";
|
|
50
50
|
ptp_no_exception_entry: boolean;
|
|
51
51
|
enablePortfolioTrailingStop?: boolean;
|
|
52
52
|
portfolioTrailPercent?: number;
|
|
@@ -108,7 +108,7 @@ export type AlpacaPosition = {
|
|
|
108
108
|
qty: string;
|
|
109
109
|
qty_available: string;
|
|
110
110
|
avg_entry_price: string;
|
|
111
|
-
side:
|
|
111
|
+
side: "long" | "short";
|
|
112
112
|
market_value: string;
|
|
113
113
|
cost_basis: string;
|
|
114
114
|
unrealized_pl: string;
|
|
@@ -119,31 +119,31 @@ export type AlpacaPosition = {
|
|
|
119
119
|
lastday_price: string;
|
|
120
120
|
change_today: string;
|
|
121
121
|
};
|
|
122
|
-
export type OrderSide =
|
|
122
|
+
export type OrderSide = "buy" | "sell";
|
|
123
123
|
/**
|
|
124
124
|
* Represents the type of order.
|
|
125
125
|
*/
|
|
126
|
-
export type OrderType =
|
|
126
|
+
export type OrderType = "market" | "limit" | "stop" | "stop_limit" | "trailing_stop";
|
|
127
127
|
/**
|
|
128
128
|
* Represents the time in force for an order.
|
|
129
129
|
*/
|
|
130
|
-
export type TimeInForce =
|
|
130
|
+
export type TimeInForce = "day" | "gtc" | "opg" | "cls" | "ioc" | "fok";
|
|
131
131
|
/**
|
|
132
132
|
* Represents the class of an order.
|
|
133
133
|
*/
|
|
134
|
-
export type OrderClass =
|
|
134
|
+
export type OrderClass = "simple" | "oco" | "oto" | "bracket" | "mleg";
|
|
135
135
|
/**
|
|
136
136
|
* Represents the status of an order.
|
|
137
137
|
*/
|
|
138
|
-
export type OrderStatus =
|
|
138
|
+
export type OrderStatus = "new" | "partially_filled" | "filled" | "done_for_day" | "canceled" | "expired" | "replaced" | "pending_cancel" | "pending_replace" | "accepted" | "pending_new" | "accepted_for_bidding" | "stopped" | "rejected" | "suspended" | "calculated";
|
|
139
139
|
/**
|
|
140
140
|
* Represents the class of an asset.
|
|
141
141
|
*/
|
|
142
|
-
export type AssetClass =
|
|
142
|
+
export type AssetClass = "us_equity" | "us_option" | "crypto";
|
|
143
143
|
/**
|
|
144
144
|
* Represents the intent of a position.
|
|
145
145
|
*/
|
|
146
|
-
export type PositionIntent =
|
|
146
|
+
export type PositionIntent = "buy_to_open" | "buy_to_close" | "sell_to_open" | "sell_to_close";
|
|
147
147
|
/**
|
|
148
148
|
* Parameters for take profit orders.
|
|
149
149
|
*/
|
|
@@ -183,7 +183,7 @@ export interface CreateOrderParams {
|
|
|
183
183
|
legs?: OrderLeg[];
|
|
184
184
|
}
|
|
185
185
|
export interface CreateMultiLegOrderParams {
|
|
186
|
-
order_class:
|
|
186
|
+
order_class: "mleg";
|
|
187
187
|
qty: string;
|
|
188
188
|
type: OrderType;
|
|
189
189
|
limit_price?: string;
|
|
@@ -199,15 +199,34 @@ export interface CreateMultiLegOrderParams {
|
|
|
199
199
|
* Parameters for getting orders.
|
|
200
200
|
*/
|
|
201
201
|
export interface GetOrdersParams {
|
|
202
|
-
status?:
|
|
202
|
+
status?: "open" | "closed" | "all";
|
|
203
203
|
limit?: number;
|
|
204
204
|
after?: string;
|
|
205
205
|
until?: string;
|
|
206
|
-
direction?:
|
|
206
|
+
direction?: "asc" | "desc";
|
|
207
207
|
nested?: boolean;
|
|
208
208
|
symbols?: string[];
|
|
209
209
|
side?: OrderSide;
|
|
210
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* SDK-compatible parameters for getting orders (with symbols as string)
|
|
213
|
+
*/
|
|
214
|
+
export interface SDKGetOrdersParams {
|
|
215
|
+
status?: "open" | "closed" | "all";
|
|
216
|
+
limit?: number;
|
|
217
|
+
after?: string;
|
|
218
|
+
until?: string;
|
|
219
|
+
direction?: "asc" | "desc";
|
|
220
|
+
nested?: boolean;
|
|
221
|
+
symbols?: string;
|
|
222
|
+
side?: OrderSide;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* SDK options for market data requests with feed parameter
|
|
226
|
+
*/
|
|
227
|
+
export interface SDKMarketDataOptions {
|
|
228
|
+
feed?: DataFeed;
|
|
229
|
+
}
|
|
211
230
|
/**
|
|
212
231
|
* Parameters for replacing an order.
|
|
213
232
|
*/
|
|
@@ -256,7 +275,7 @@ export type AlpacaOrder = {
|
|
|
256
275
|
extended_hours: boolean;
|
|
257
276
|
legs: AlpacaOrder[] | null;
|
|
258
277
|
};
|
|
259
|
-
export type CryptoTimeframe = `${number}Min` | `${number}T` | `${number}Hour` | `${number}H` |
|
|
278
|
+
export type CryptoTimeframe = `${number}Min` | `${number}T` | `${number}Hour` | `${number}H` | "1Day" | "1D" | "1Week" | "1W" | `${1 | 2 | 3 | 4 | 6 | 12}Month` | `${1 | 2 | 3 | 4 | 6 | 12}M`;
|
|
260
279
|
/**
|
|
261
280
|
* Represents a single bar of cryptocurrency market data.
|
|
262
281
|
*/
|
|
@@ -280,9 +299,9 @@ export interface CryptoBarsParams {
|
|
|
280
299
|
end?: Date;
|
|
281
300
|
limit?: number;
|
|
282
301
|
page_token?: string;
|
|
283
|
-
sort?:
|
|
302
|
+
sort?: "asc" | "desc";
|
|
284
303
|
}
|
|
285
|
-
export type TimeFrame =
|
|
304
|
+
export type TimeFrame = "1Min" | "5Min" | "15Min" | "30Min" | "1Hour" | "2Hour" | "4Hour" | "1Day" | "1Week" | "1Month";
|
|
286
305
|
/**
|
|
287
306
|
* Response structure for fetching cryptocurrency bars.
|
|
288
307
|
*/
|
|
@@ -292,10 +311,10 @@ export interface CryptoBarsResponse {
|
|
|
292
311
|
};
|
|
293
312
|
next_page_token?: string;
|
|
294
313
|
}
|
|
295
|
-
export type BTCPairs =
|
|
296
|
-
export type USDTPairs =
|
|
297
|
-
export type USDCPairs =
|
|
298
|
-
export type USDPairs =
|
|
314
|
+
export type BTCPairs = "BCH/BTC" | "ETH/BTC" | "LTC/BTC" | "UNI/BTC";
|
|
315
|
+
export type USDTPairs = "AAVE/USDT" | "BCH/USDT" | "BTC/USDT" | "DOGE/USDT" | "ETH/USDT" | "LINK/USDT" | "LTC/USDT" | "SUSHI/USDT" | "UNI/USDT" | "YFI/USDT";
|
|
316
|
+
export type USDCPairs = "AAVE/USDC" | "AVAX/USDC" | "BAT/USDC" | "BCH/USDC" | "BTC/USDC" | "CRV/USDC" | "DOGE/USDC" | "DOT/USDC" | "ETH/USDC" | "GRT/USDC" | "LINK/USDC" | "LTC/USDC" | "MKR/USDC" | "SHIB/USDC" | "SUSHI/USDC" | "UNI/USDC" | "XTZ/USDC" | "YFI/USDC";
|
|
317
|
+
export type USDPairs = "AAVE/USD" | "AVAX/USD" | "BAT/USD" | "BCH/USD" | "BTC/USD" | "CRV/USD" | "DOGE/USD" | "DOT/USD" | "ETH/USD" | "GRT/USD" | "LINK/USD" | "LTC/USD" | "MKR/USD" | "SHIB/USD" | "SUSHI/USD" | "UNI/USD" | "USDC/USD" | "USDT/USD" | "XTZ/USD" | "YFI/USD";
|
|
299
318
|
/**
|
|
300
319
|
* Represents a cryptocurrency trading pair.
|
|
301
320
|
*/
|
|
@@ -304,7 +323,7 @@ export type CryptoPair = BTCPairs | USDTPairs | USDCPairs | USDPairs;
|
|
|
304
323
|
* Represents an image associated with a news article.
|
|
305
324
|
*/
|
|
306
325
|
export interface NewsImage {
|
|
307
|
-
size:
|
|
326
|
+
size: "large" | "small" | "thumb";
|
|
308
327
|
url: string;
|
|
309
328
|
}
|
|
310
329
|
/**
|
|
@@ -350,13 +369,13 @@ export interface SimpleNews {
|
|
|
350
369
|
*/
|
|
351
370
|
export interface PortfolioHistoryParams {
|
|
352
371
|
period?: string;
|
|
353
|
-
timeframe?:
|
|
354
|
-
intraday_reporting?:
|
|
372
|
+
timeframe?: "1Min" | "5Min" | "15Min" | "1H" | "1D";
|
|
373
|
+
intraday_reporting?: "market_hours" | "extended_hours" | "continuous";
|
|
355
374
|
start?: string;
|
|
356
375
|
end?: string;
|
|
357
376
|
date_end?: string;
|
|
358
377
|
extended_hours?: boolean;
|
|
359
|
-
pnl_reset?:
|
|
378
|
+
pnl_reset?: "per_day" | "no_reset";
|
|
360
379
|
cashflow_types?: string;
|
|
361
380
|
}
|
|
362
381
|
/**
|
|
@@ -383,6 +402,7 @@ export interface PortfolioHistoryResponse {
|
|
|
383
402
|
* Parameters for fetching account details.
|
|
384
403
|
*/
|
|
385
404
|
export interface FetchAccountDetailsProps {
|
|
405
|
+
auth?: AlpacaAuth;
|
|
386
406
|
accountId?: string;
|
|
387
407
|
client?: ApolloClientType<NormalizedCacheObject>;
|
|
388
408
|
alpacaAccount?: types.AlpacaAccount;
|
|
@@ -393,7 +413,7 @@ export interface FetchAccountDetailsProps {
|
|
|
393
413
|
export interface AlpacaAccountDetails {
|
|
394
414
|
id: string;
|
|
395
415
|
account_number: string;
|
|
396
|
-
status:
|
|
416
|
+
status: "ONBOARDING" | "SUBMISSION_FAILED" | "SUBMITTED" | "ACCOUNT_UPDATED" | "APPROVAL_PENDING" | "ACTIVE" | "REJECTED";
|
|
397
417
|
currency: string;
|
|
398
418
|
cash: string;
|
|
399
419
|
portfolio_value: string;
|
|
@@ -412,7 +432,7 @@ export interface AlpacaAccountDetails {
|
|
|
412
432
|
short_market_value: string;
|
|
413
433
|
equity: string;
|
|
414
434
|
last_equity: string;
|
|
415
|
-
multiplier:
|
|
435
|
+
multiplier: "1" | "2" | "4";
|
|
416
436
|
buying_power: string;
|
|
417
437
|
initial_margin: string;
|
|
418
438
|
maintenance_margin: string;
|
|
@@ -433,11 +453,11 @@ export interface AlpacaAccountDetails {
|
|
|
433
453
|
*/
|
|
434
454
|
export interface AlpacaAsset {
|
|
435
455
|
id: string;
|
|
436
|
-
class:
|
|
456
|
+
class: "us_equity" | "us_option" | "crypto";
|
|
437
457
|
exchange: string;
|
|
438
458
|
symbol: string;
|
|
439
459
|
name: string;
|
|
440
|
-
status:
|
|
460
|
+
status: "active" | "inactive";
|
|
441
461
|
tradable: boolean;
|
|
442
462
|
marginable: boolean;
|
|
443
463
|
shortable: boolean;
|
|
@@ -454,7 +474,7 @@ export interface AlpacaAsset {
|
|
|
454
474
|
export interface GetAssetParams {
|
|
455
475
|
symbolOrAssetId: string;
|
|
456
476
|
}
|
|
457
|
-
export type DataFeed =
|
|
477
|
+
export type DataFeed = "sip" | "iex" | "delayed_sip";
|
|
458
478
|
export interface AlpacaQuote {
|
|
459
479
|
t: string;
|
|
460
480
|
ap: number;
|
|
@@ -506,13 +526,13 @@ export interface LatestQuotesResponse {
|
|
|
506
526
|
currency: string;
|
|
507
527
|
}
|
|
508
528
|
export type OptionsTradingLevel = 0 | 1 | 2 | 3;
|
|
509
|
-
export type OptionType =
|
|
510
|
-
export type OptionStyle =
|
|
529
|
+
export type OptionType = "call" | "put";
|
|
530
|
+
export type OptionStyle = "american" | "european";
|
|
511
531
|
export interface OptionContract {
|
|
512
532
|
id: string;
|
|
513
533
|
symbol: string;
|
|
514
534
|
name: string;
|
|
515
|
-
status:
|
|
535
|
+
status: "active" | "inactive";
|
|
516
536
|
tradable: boolean;
|
|
517
537
|
expiration_date: string;
|
|
518
538
|
root_symbol: string;
|
|
@@ -534,7 +554,7 @@ export interface GetOptionContractsParams {
|
|
|
534
554
|
strike_price_gte?: string;
|
|
535
555
|
strike_price_lte?: string;
|
|
536
556
|
type?: OptionType;
|
|
537
|
-
status?:
|
|
557
|
+
status?: "active" | "inactive";
|
|
538
558
|
limit?: number;
|
|
539
559
|
page_token?: string;
|
|
540
560
|
}
|
|
@@ -546,8 +566,8 @@ export interface OptionContractsResponse {
|
|
|
546
566
|
export interface OrderLeg {
|
|
547
567
|
symbol: string;
|
|
548
568
|
ratio_qty: string;
|
|
549
|
-
side:
|
|
550
|
-
position_intent:
|
|
569
|
+
side: "buy" | "sell";
|
|
570
|
+
position_intent: "buy_to_open" | "buy_to_close" | "sell_to_open" | "sell_to_close";
|
|
551
571
|
}
|
|
552
572
|
export interface OptionGreeks {
|
|
553
573
|
delta?: number;
|
|
@@ -634,7 +654,7 @@ export interface OptionsChainParams {
|
|
|
634
654
|
* The source feed of the data. opra is the official OPRA feed, indicative is a free indicative feed
|
|
635
655
|
* where trades are delayed and quotes are modified. Default: opra if the user has a subscription, otherwise indicative.
|
|
636
656
|
*/
|
|
637
|
-
feed?:
|
|
657
|
+
feed?: "opra" | "indicative";
|
|
638
658
|
/**
|
|
639
659
|
* Number of maximum snapshots to return in a response (1 to 1000)
|
|
640
660
|
* The limit applies to the total number of data points, not the number per symbol!
|
|
@@ -707,7 +727,7 @@ export interface HistoricalOptionsBarsParams {
|
|
|
707
727
|
/** Pagination token for next page */
|
|
708
728
|
page_token?: string;
|
|
709
729
|
/** Sort order (asc or desc) */
|
|
710
|
-
sort?:
|
|
730
|
+
sort?: "asc" | "desc";
|
|
711
731
|
}
|
|
712
732
|
export interface HistoricalOptionsTradesParams {
|
|
713
733
|
/** Comma-separated list of option contract symbols */
|
|
@@ -727,7 +747,7 @@ export interface HistoricalOptionsTradesParams {
|
|
|
727
747
|
/** Pagination token for next page */
|
|
728
748
|
page_token?: string;
|
|
729
749
|
/** Sort order (asc or desc) */
|
|
730
|
-
sort?:
|
|
750
|
+
sort?: "asc" | "desc";
|
|
731
751
|
}
|
|
732
752
|
export interface OptionsSnapshotsParams {
|
|
733
753
|
/** Comma-separated list of option contract symbols */
|
|
@@ -743,14 +763,14 @@ export interface OptionsConditionCodesResponse {
|
|
|
743
763
|
export interface OptionsExchangeCodesResponse {
|
|
744
764
|
[exchangeCode: string]: string;
|
|
745
765
|
}
|
|
746
|
-
export type OptionTickType =
|
|
766
|
+
export type OptionTickType = "trade" | "quote";
|
|
747
767
|
/**
|
|
748
768
|
* Configuration for options spread trading strategies.
|
|
749
769
|
* Now includes a field to target a predicted stock price movement (in percent, scale 100).
|
|
750
770
|
*/
|
|
751
771
|
export interface OptionsSpreadConfig {
|
|
752
772
|
/** Strategy type to use - only spreads allowed */
|
|
753
|
-
strategy:
|
|
773
|
+
strategy: "call_spread" | "put_spread";
|
|
754
774
|
/** Days to expiration target (will find closest available) */
|
|
755
775
|
daysToExpiration: number;
|
|
756
776
|
/** Delta target for the long leg (0.1-0.9 range) */
|
|
@@ -769,7 +789,7 @@ export interface OptionsSpreadConfig {
|
|
|
769
789
|
*/
|
|
770
790
|
targetMovePercent100?: number;
|
|
771
791
|
}
|
|
772
|
-
export type OptionActivityType =
|
|
792
|
+
export type OptionActivityType = "OPEXC" | "OPASN" | "OPEXP";
|
|
773
793
|
export interface OptionAccountActivity {
|
|
774
794
|
id: string;
|
|
775
795
|
activity_type: OptionActivityType;
|
|
@@ -779,19 +799,19 @@ export interface OptionAccountActivity {
|
|
|
779
799
|
symbol: string;
|
|
780
800
|
qty: string;
|
|
781
801
|
price?: string;
|
|
782
|
-
status:
|
|
802
|
+
status: "executed";
|
|
783
803
|
}
|
|
784
804
|
export interface TradeUpdate {
|
|
785
|
-
event:
|
|
805
|
+
event: "new" | "fill" | "partial_fill" | "canceled" | "expired" | "pending_new" | "pending_cancel" | "pending_replace" | "replaced" | "done_for_day";
|
|
786
806
|
price?: string;
|
|
787
807
|
timestamp: string;
|
|
788
808
|
qty?: string;
|
|
789
809
|
position_qty?: string;
|
|
790
810
|
order: AlpacaOrder;
|
|
791
811
|
}
|
|
792
|
-
export type AlpacaAccountType =
|
|
793
|
-
export type AlpacaOrderType =
|
|
794
|
-
export type EngineType =
|
|
812
|
+
export type AlpacaAccountType = "PAPER" | "LIVE";
|
|
813
|
+
export type AlpacaOrderType = "limit" | "market" | "options";
|
|
814
|
+
export type EngineType = "adaptic" | "brain" | "quant";
|
|
795
815
|
export interface AlpacaCredentials {
|
|
796
816
|
accountName: string;
|
|
797
817
|
apiKey: string;
|
|
@@ -800,8 +820,8 @@ export interface AlpacaCredentials {
|
|
|
800
820
|
orderType: AlpacaOrderType;
|
|
801
821
|
engine: EngineType;
|
|
802
822
|
}
|
|
803
|
-
export type { AlpacaTradingAPI } from
|
|
804
|
-
export type { AlpacaMarketDataAPI } from
|
|
823
|
+
export type { AlpacaTradingAPI } from "../alpaca-trading-api";
|
|
824
|
+
export type { AlpacaMarketDataAPI } from "../alpaca-market-data-api";
|
|
805
825
|
/**
|
|
806
826
|
* Base interface for all real-time stream messages from Alpaca.
|
|
807
827
|
* All stream messages will have a 'T' (Type) and 'S' (Symbol) property.
|
|
@@ -815,7 +835,7 @@ export interface AlpacaStreamMessage {
|
|
|
815
835
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#trades
|
|
816
836
|
*/
|
|
817
837
|
export interface AlpacaTradeStream extends AlpacaStreamMessage {
|
|
818
|
-
T:
|
|
838
|
+
T: "t";
|
|
819
839
|
i: number;
|
|
820
840
|
x: string;
|
|
821
841
|
p: number;
|
|
@@ -829,7 +849,7 @@ export interface AlpacaTradeStream extends AlpacaStreamMessage {
|
|
|
829
849
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#quotes
|
|
830
850
|
*/
|
|
831
851
|
export interface AlpacaQuoteStream extends AlpacaStreamMessage {
|
|
832
|
-
T:
|
|
852
|
+
T: "q";
|
|
833
853
|
ax: string;
|
|
834
854
|
ap: number;
|
|
835
855
|
as: number;
|
|
@@ -845,7 +865,7 @@ export interface AlpacaQuoteStream extends AlpacaStreamMessage {
|
|
|
845
865
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#bars
|
|
846
866
|
*/
|
|
847
867
|
export interface AlpacaBarStream extends AlpacaStreamMessage {
|
|
848
|
-
T:
|
|
868
|
+
T: "b";
|
|
849
869
|
o: number;
|
|
850
870
|
h: number;
|
|
851
871
|
l: number;
|
|
@@ -859,22 +879,22 @@ export interface AlpacaBarStream extends AlpacaStreamMessage {
|
|
|
859
879
|
* Real-time daily stock bar message. (T: 'd')
|
|
860
880
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#bars
|
|
861
881
|
*/
|
|
862
|
-
export interface AlpacaDailyBarStream extends Omit<AlpacaBarStream,
|
|
863
|
-
T:
|
|
882
|
+
export interface AlpacaDailyBarStream extends Omit<AlpacaBarStream, "T"> {
|
|
883
|
+
T: "d";
|
|
864
884
|
}
|
|
865
885
|
/**
|
|
866
886
|
* Real-time updated stock bar message. (T: 'u')
|
|
867
887
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#bars
|
|
868
888
|
*/
|
|
869
|
-
export interface AlpacaUpdatedBarStream extends Omit<AlpacaBarStream,
|
|
870
|
-
T:
|
|
889
|
+
export interface AlpacaUpdatedBarStream extends Omit<AlpacaBarStream, "T"> {
|
|
890
|
+
T: "u";
|
|
871
891
|
}
|
|
872
892
|
/**
|
|
873
893
|
* Real-time trading status message. (T: 's')
|
|
874
894
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#trading-status
|
|
875
895
|
*/
|
|
876
896
|
export interface AlpacaTradingStatusStream extends AlpacaStreamMessage {
|
|
877
|
-
T:
|
|
897
|
+
T: "s";
|
|
878
898
|
sc: string;
|
|
879
899
|
sm: string;
|
|
880
900
|
rc: string;
|
|
@@ -887,7 +907,7 @@ export interface AlpacaTradingStatusStream extends AlpacaStreamMessage {
|
|
|
887
907
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#lulds
|
|
888
908
|
*/
|
|
889
909
|
export interface AlpacaLULDStream extends AlpacaStreamMessage {
|
|
890
|
-
T:
|
|
910
|
+
T: "l";
|
|
891
911
|
ldp: number;
|
|
892
912
|
lup: number;
|
|
893
913
|
i: string;
|
|
@@ -899,7 +919,7 @@ export interface AlpacaLULDStream extends AlpacaStreamMessage {
|
|
|
899
919
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#trade-corrections
|
|
900
920
|
*/
|
|
901
921
|
export interface AlpacaTradeCorrectionStream extends AlpacaStreamMessage {
|
|
902
|
-
T:
|
|
922
|
+
T: "c";
|
|
903
923
|
oi: number;
|
|
904
924
|
ci: number;
|
|
905
925
|
ox: string;
|
|
@@ -918,7 +938,7 @@ export interface AlpacaTradeCorrectionStream extends AlpacaStreamMessage {
|
|
|
918
938
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#trade-cancelserros
|
|
919
939
|
*/
|
|
920
940
|
export interface AlpacaTradeCancelStream extends AlpacaStreamMessage {
|
|
921
|
-
T:
|
|
941
|
+
T: "x";
|
|
922
942
|
i: number;
|
|
923
943
|
p: number;
|
|
924
944
|
s: number;
|
|
@@ -930,7 +950,7 @@ export interface AlpacaTradeCancelStream extends AlpacaStreamMessage {
|
|
|
930
950
|
* @see https://docs.alpaca.markets/docs/real-time-stock-pricing-data#order-imbalances
|
|
931
951
|
*/
|
|
932
952
|
export interface AlpacaOrderImbalanceStream extends AlpacaStreamMessage {
|
|
933
|
-
T:
|
|
953
|
+
T: "i";
|
|
934
954
|
p: number;
|
|
935
955
|
z: string;
|
|
936
956
|
t: string;
|
|
@@ -940,7 +960,7 @@ export interface AlpacaOrderImbalanceStream extends AlpacaStreamMessage {
|
|
|
940
960
|
* @see https://docs.alpaca.markets/docs/real-time-option-data#trades
|
|
941
961
|
*/
|
|
942
962
|
export interface AlpacaOptionTradeStream extends AlpacaStreamMessage {
|
|
943
|
-
T:
|
|
963
|
+
T: "t";
|
|
944
964
|
p: number;
|
|
945
965
|
s: number;
|
|
946
966
|
c: string[];
|
|
@@ -952,7 +972,7 @@ export interface AlpacaOptionTradeStream extends AlpacaStreamMessage {
|
|
|
952
972
|
* @see https://docs.alpaca.markets/docs/real-time-option-data#quotes
|
|
953
973
|
*/
|
|
954
974
|
export interface AlpacaOptionQuoteStream extends AlpacaStreamMessage {
|
|
955
|
-
T:
|
|
975
|
+
T: "q";
|
|
956
976
|
ap: number;
|
|
957
977
|
as: number;
|
|
958
978
|
ax: string;
|
|
@@ -966,7 +986,7 @@ export interface AlpacaOptionQuoteStream extends AlpacaStreamMessage {
|
|
|
966
986
|
* @see https://docs.alpaca.markets/docs/real-time-option-data#bars
|
|
967
987
|
*/
|
|
968
988
|
export interface AlpacaOptionBarStream extends AlpacaStreamMessage {
|
|
969
|
-
T:
|
|
989
|
+
T: "b";
|
|
970
990
|
o: number;
|
|
971
991
|
h: number;
|
|
972
992
|
l: number;
|
|
@@ -978,45 +998,45 @@ export interface AlpacaOptionBarStream extends AlpacaStreamMessage {
|
|
|
978
998
|
}
|
|
979
999
|
export type AlpacaStockStreamMessage = AlpacaTradeStream | AlpacaQuoteStream | AlpacaBarStream | AlpacaDailyBarStream | AlpacaUpdatedBarStream | AlpacaTradingStatusStream | AlpacaLULDStream | AlpacaTradeCorrectionStream | AlpacaTradeCancelStream | AlpacaOrderImbalanceStream;
|
|
980
1000
|
export type AlpacaOptionStreamMessage = AlpacaOptionTradeStream | AlpacaOptionQuoteStream | AlpacaOptionBarStream;
|
|
981
|
-
export type StockStreamEventName =
|
|
982
|
-
export type OptionStreamEventName =
|
|
1001
|
+
export type StockStreamEventName = "stock-t" | "stock-q" | "stock-b" | "stock-d" | "stock-u" | "stock-s" | "stock-l" | "stock-c" | "stock-x" | "stock-i" | "stock-data";
|
|
1002
|
+
export type OptionStreamEventName = "option-t" | "option-q" | "option-b" | "option-data";
|
|
983
1003
|
export interface StockStreamEventMap {
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1004
|
+
"stock-t": AlpacaTradeStream;
|
|
1005
|
+
"stock-q": AlpacaQuoteStream;
|
|
1006
|
+
"stock-b": AlpacaBarStream;
|
|
1007
|
+
"stock-d": AlpacaDailyBarStream;
|
|
1008
|
+
"stock-u": AlpacaUpdatedBarStream;
|
|
1009
|
+
"stock-s": AlpacaTradingStatusStream;
|
|
1010
|
+
"stock-l": AlpacaLULDStream;
|
|
1011
|
+
"stock-c": AlpacaTradeCorrectionStream;
|
|
1012
|
+
"stock-x": AlpacaTradeCancelStream;
|
|
1013
|
+
"stock-i": AlpacaOrderImbalanceStream;
|
|
1014
|
+
"stock-data": AlpacaStockStreamMessage;
|
|
995
1015
|
}
|
|
996
1016
|
export interface OptionStreamEventMap {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1017
|
+
"option-t": AlpacaOptionTradeStream;
|
|
1018
|
+
"option-q": AlpacaOptionQuoteStream;
|
|
1019
|
+
"option-b": AlpacaOptionBarStream;
|
|
1020
|
+
"option-data": AlpacaOptionStreamMessage;
|
|
1001
1021
|
}
|
|
1002
1022
|
/**
|
|
1003
1023
|
* Crypto trade stream message from Alpaca WebSocket
|
|
1004
1024
|
* Format: wss://stream.data.alpaca.markets/v1beta3/crypto/us
|
|
1005
1025
|
*/
|
|
1006
1026
|
export interface AlpacaCryptoTradeStream {
|
|
1007
|
-
T:
|
|
1027
|
+
T: "t";
|
|
1008
1028
|
S: string;
|
|
1009
1029
|
p: number;
|
|
1010
1030
|
s: number;
|
|
1011
1031
|
t: string;
|
|
1012
1032
|
i: number;
|
|
1013
|
-
tks:
|
|
1033
|
+
tks: "B" | "S";
|
|
1014
1034
|
}
|
|
1015
1035
|
/**
|
|
1016
1036
|
* Crypto quote stream message from Alpaca WebSocket
|
|
1017
1037
|
*/
|
|
1018
1038
|
export interface AlpacaCryptoQuoteStream {
|
|
1019
|
-
T:
|
|
1039
|
+
T: "q";
|
|
1020
1040
|
S: string;
|
|
1021
1041
|
bp: number;
|
|
1022
1042
|
bs: number;
|
|
@@ -1028,7 +1048,7 @@ export interface AlpacaCryptoQuoteStream {
|
|
|
1028
1048
|
* Crypto bar stream message from Alpaca WebSocket
|
|
1029
1049
|
*/
|
|
1030
1050
|
export interface AlpacaCryptoBarStream {
|
|
1031
|
-
T:
|
|
1051
|
+
T: "b";
|
|
1032
1052
|
S: string;
|
|
1033
1053
|
o: number;
|
|
1034
1054
|
h: number;
|
|
@@ -1043,7 +1063,7 @@ export interface AlpacaCryptoBarStream {
|
|
|
1043
1063
|
* Crypto daily bar stream message from Alpaca WebSocket
|
|
1044
1064
|
*/
|
|
1045
1065
|
export interface AlpacaCryptoDailyBarStream {
|
|
1046
|
-
T:
|
|
1066
|
+
T: "d";
|
|
1047
1067
|
S: string;
|
|
1048
1068
|
o: number;
|
|
1049
1069
|
h: number;
|
|
@@ -1058,7 +1078,7 @@ export interface AlpacaCryptoDailyBarStream {
|
|
|
1058
1078
|
* Crypto updated bar stream message from Alpaca WebSocket
|
|
1059
1079
|
*/
|
|
1060
1080
|
export interface AlpacaCryptoUpdatedBarStream {
|
|
1061
|
-
T:
|
|
1081
|
+
T: "u";
|
|
1062
1082
|
S: string;
|
|
1063
1083
|
o: number;
|
|
1064
1084
|
h: number;
|
|
@@ -1076,16 +1096,70 @@ export type AlpacaCryptoStreamMessage = AlpacaCryptoTradeStream | AlpacaCryptoQu
|
|
|
1076
1096
|
/**
|
|
1077
1097
|
* Type-safe event names for crypto market data streams
|
|
1078
1098
|
*/
|
|
1079
|
-
export type CryptoStreamEventName =
|
|
1099
|
+
export type CryptoStreamEventName = "crypto-t" | "crypto-q" | "crypto-b" | "crypto-d" | "crypto-u" | "crypto-data";
|
|
1080
1100
|
/**
|
|
1081
1101
|
* Event payload mapping for crypto streams
|
|
1082
1102
|
*/
|
|
1083
1103
|
export interface CryptoStreamEventMap {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1104
|
+
"crypto-t": AlpacaCryptoTradeStream;
|
|
1105
|
+
"crypto-q": AlpacaCryptoQuoteStream;
|
|
1106
|
+
"crypto-b": AlpacaCryptoBarStream;
|
|
1107
|
+
"crypto-d": AlpacaCryptoDailyBarStream;
|
|
1108
|
+
"crypto-u": AlpacaCryptoUpdatedBarStream;
|
|
1109
|
+
"crypto-data": AlpacaCryptoStreamMessage;
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* WebSocket authorization response message
|
|
1113
|
+
*/
|
|
1114
|
+
export interface AlpacaAuthMessage {
|
|
1115
|
+
stream: "authorization";
|
|
1116
|
+
data: {
|
|
1117
|
+
status: "authorized" | "unauthorized";
|
|
1118
|
+
action: "authenticate";
|
|
1119
|
+
message?: string;
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* WebSocket listening response message
|
|
1124
|
+
*/
|
|
1125
|
+
export interface AlpacaListenMessage {
|
|
1126
|
+
stream: "listening";
|
|
1127
|
+
data: {
|
|
1128
|
+
streams: string[];
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Generic WebSocket message structure
|
|
1133
|
+
*/
|
|
1134
|
+
export interface AlpacaWebSocketMessage {
|
|
1135
|
+
stream: string;
|
|
1136
|
+
data: AlpacaAuthMessage["data"] | AlpacaListenMessage["data"] | TradeUpdate;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Response from exercising an option
|
|
1140
|
+
*/
|
|
1141
|
+
export interface ExerciseOptionResponse {
|
|
1142
|
+
id: string;
|
|
1143
|
+
symbol: string;
|
|
1144
|
+
side: "long" | "short";
|
|
1145
|
+
qty: string;
|
|
1146
|
+
asset_class: "us_option";
|
|
1147
|
+
status: "pending" | "complete" | "failed";
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Account with allocation configuration
|
|
1151
|
+
* Extends the base AlpacaAccount from backend-legacy with optional allocation fields
|
|
1152
|
+
*/
|
|
1153
|
+
export interface AlpacaAccountWithAllocation {
|
|
1154
|
+
allocation?: AllocationConfig;
|
|
1155
|
+
autoAllocation?: boolean;
|
|
1156
|
+
marketOpen?: boolean;
|
|
1157
|
+
realTime?: boolean;
|
|
1158
|
+
tradeAllocationPct?: number;
|
|
1159
|
+
minPercentageChange?: number;
|
|
1160
|
+
volumeThreshold?: number;
|
|
1161
|
+
cryptoTradingEnabled?: boolean;
|
|
1162
|
+
cryptoTradingPairs?: string[];
|
|
1163
|
+
cryptoTradeAllocationPct?: number;
|
|
1090
1164
|
}
|
|
1091
1165
|
//# sourceMappingURL=alpaca-types.d.ts.map
|