@adaptic/utils 0.0.383 → 0.1.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.
- package/dist/index.cjs +10241 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +10057 -121
- package/dist/index.mjs.map +1 -1
- package/dist/types/alpaca/client.d.ts +95 -0
- package/dist/types/alpaca/client.d.ts.map +1 -0
- package/dist/types/alpaca/crypto/data.d.ts +281 -0
- package/dist/types/alpaca/crypto/data.d.ts.map +1 -0
- package/dist/types/alpaca/crypto/index.d.ts +75 -0
- package/dist/types/alpaca/crypto/index.d.ts.map +1 -0
- package/dist/types/alpaca/crypto/orders.d.ts +221 -0
- package/dist/types/alpaca/crypto/orders.d.ts.map +1 -0
- package/dist/types/alpaca/index.d.ts +201 -0
- package/dist/types/alpaca/index.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/bars.d.ts +142 -0
- package/dist/types/alpaca/market-data/bars.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/index.d.ts +13 -0
- package/dist/types/alpaca/market-data/index.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/news.d.ts +87 -0
- package/dist/types/alpaca/market-data/news.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/quotes.d.ts +85 -0
- package/dist/types/alpaca/market-data/quotes.d.ts.map +1 -0
- package/dist/types/alpaca/market-data/trades.d.ts +98 -0
- package/dist/types/alpaca/market-data/trades.d.ts.map +1 -0
- package/dist/types/alpaca/options/contracts.d.ts +279 -0
- package/dist/types/alpaca/options/contracts.d.ts.map +1 -0
- package/dist/types/alpaca/options/data.d.ts +126 -0
- package/dist/types/alpaca/options/data.d.ts.map +1 -0
- package/dist/types/alpaca/options/index.d.ts +17 -0
- package/dist/types/alpaca/options/index.d.ts.map +1 -0
- package/dist/types/alpaca/options/orders.d.ts +366 -0
- package/dist/types/alpaca/options/orders.d.ts.map +1 -0
- package/dist/types/alpaca/options/strategies.d.ts +224 -0
- package/dist/types/alpaca/options/strategies.d.ts.map +1 -0
- package/dist/types/alpaca/streams/base-stream.d.ts +143 -0
- package/dist/types/alpaca/streams/base-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams/crypto-stream.d.ts +173 -0
- package/dist/types/alpaca/streams/crypto-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams/index.d.ts +54 -0
- package/dist/types/alpaca/streams/index.d.ts.map +1 -0
- package/dist/types/alpaca/streams/option-stream.d.ts +167 -0
- package/dist/types/alpaca/streams/option-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams/stock-stream.d.ts +176 -0
- package/dist/types/alpaca/streams/stock-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams/stream-manager.d.ts +277 -0
- package/dist/types/alpaca/streams/stream-manager.d.ts.map +1 -0
- package/dist/types/alpaca/streams/trading-stream.d.ts +186 -0
- package/dist/types/alpaca/streams/trading-stream.d.ts.map +1 -0
- package/dist/types/alpaca/streams.d.ts +88 -0
- package/dist/types/alpaca/streams.d.ts.map +1 -0
- package/dist/types/alpaca/test-imports.d.ts +7 -0
- package/dist/types/alpaca/test-imports.d.ts.map +1 -0
- package/dist/types/alpaca/trading/account.d.ts +198 -0
- package/dist/types/alpaca/trading/account.d.ts.map +1 -0
- package/dist/types/alpaca/trading/bracket-orders.d.ts +162 -0
- package/dist/types/alpaca/trading/bracket-orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/index.d.ts +13 -0
- package/dist/types/alpaca/trading/index.d.ts.map +1 -0
- package/dist/types/alpaca/trading/oco-orders.d.ts +203 -0
- package/dist/types/alpaca/trading/oco-orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/order-utils.d.ts +404 -0
- package/dist/types/alpaca/trading/order-utils.d.ts.map +1 -0
- package/dist/types/alpaca/trading/orders.d.ts +199 -0
- package/dist/types/alpaca/trading/orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/oto-orders.d.ts +282 -0
- package/dist/types/alpaca/trading/oto-orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/positions.d.ts +389 -0
- package/dist/types/alpaca/trading/positions.d.ts.map +1 -0
- package/dist/types/alpaca/trading/smart-orders.d.ts +301 -0
- package/dist/types/alpaca/trading/smart-orders.d.ts.map +1 -0
- package/dist/types/alpaca/trading/trailing-stops.d.ts +240 -0
- package/dist/types/alpaca/trading/trailing-stops.d.ts.map +1 -0
- package/dist/types/index.d.ts +353 -6
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alpaca SDK Client Factory
|
|
3
|
+
* Provides unified access to Alpaca Trading API using official SDK
|
|
4
|
+
*/
|
|
5
|
+
import Alpaca from '@alpacahq/alpaca-trade-api';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for Alpaca client
|
|
8
|
+
*/
|
|
9
|
+
export interface AlpacaClientConfig {
|
|
10
|
+
/** Alpaca API Key */
|
|
11
|
+
apiKey: string;
|
|
12
|
+
/** Alpaca API Secret */
|
|
13
|
+
apiSecret: string;
|
|
14
|
+
/** Account type: PAPER for testing, LIVE for production */
|
|
15
|
+
accountType: 'PAPER' | 'LIVE';
|
|
16
|
+
/** Optional data feed: 'sip' for premium, 'iex' for free tier */
|
|
17
|
+
dataFeed?: 'sip' | 'iex';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validated Alpaca credentials with account info
|
|
21
|
+
*/
|
|
22
|
+
export interface ValidatedCredentials extends AlpacaClientConfig {
|
|
23
|
+
accountId: string;
|
|
24
|
+
accountNumber: string;
|
|
25
|
+
isValid: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* AlpacaClient wraps the official SDK with additional features:
|
|
29
|
+
* - Connection pooling
|
|
30
|
+
* - Automatic reconnection
|
|
31
|
+
* - Logging
|
|
32
|
+
* - Error handling
|
|
33
|
+
* - Direct API access for endpoints not covered by SDK
|
|
34
|
+
*/
|
|
35
|
+
export declare class AlpacaClient {
|
|
36
|
+
private sdk;
|
|
37
|
+
private config;
|
|
38
|
+
private isConnected;
|
|
39
|
+
private apiBaseUrl;
|
|
40
|
+
private headers;
|
|
41
|
+
constructor(config: AlpacaClientConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Get the underlying SDK instance for direct access
|
|
44
|
+
*/
|
|
45
|
+
getSDK(): Alpaca;
|
|
46
|
+
/**
|
|
47
|
+
* Get the configuration
|
|
48
|
+
*/
|
|
49
|
+
getConfig(): AlpacaClientConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Check if using paper trading
|
|
52
|
+
*/
|
|
53
|
+
isPaper(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Validate credentials by fetching account info
|
|
56
|
+
*/
|
|
57
|
+
validateCredentials(): Promise<ValidatedCredentials>;
|
|
58
|
+
/**
|
|
59
|
+
* Check connection status
|
|
60
|
+
*/
|
|
61
|
+
isConnectionValid(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get the API base URL
|
|
64
|
+
*/
|
|
65
|
+
getApiBaseUrl(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Get the API headers for authentication
|
|
68
|
+
*/
|
|
69
|
+
getHeaders(): Record<string, string>;
|
|
70
|
+
/**
|
|
71
|
+
* Make a direct HTTP request to the Alpaca API
|
|
72
|
+
* Use this for endpoints not covered by the SDK
|
|
73
|
+
*
|
|
74
|
+
* @param endpoint - API endpoint (e.g., '/options/contracts')
|
|
75
|
+
* @param method - HTTP method (default: 'GET')
|
|
76
|
+
* @param body - Request body for POST/PUT requests
|
|
77
|
+
* @returns Response data
|
|
78
|
+
*/
|
|
79
|
+
makeRequest<T>(endpoint: string, method?: 'GET' | 'POST' | 'PUT' | 'DELETE', body?: Record<string, unknown>): Promise<T>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Create or get a cached Alpaca client
|
|
83
|
+
* Uses apiKey as cache key for connection pooling
|
|
84
|
+
*/
|
|
85
|
+
export declare function createAlpacaClient(config: AlpacaClientConfig): AlpacaClient;
|
|
86
|
+
/**
|
|
87
|
+
* Create a client from environment variables
|
|
88
|
+
*/
|
|
89
|
+
export declare function createClientFromEnv(): AlpacaClient;
|
|
90
|
+
/**
|
|
91
|
+
* Clear client cache (useful for testing or credential rotation)
|
|
92
|
+
*/
|
|
93
|
+
export declare function clearClientCache(): void;
|
|
94
|
+
export default AlpacaClient;
|
|
95
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/alpaca/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,MAAM,MAAM,4BAA4B,CAAC;AAQhD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,WAAW,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAyB;gBAE5B,MAAM,EAAE,kBAAkB;IAuBtC;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACH,SAAS,IAAI,kBAAkB;IAI/B;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAiB1D;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIpC;;;;;;;;OAQG;IACG,WAAW,CAAC,CAAC,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAgB,EACjD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC;CAiCd;AAKD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAW3E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CAclD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crypto Market Data Module
|
|
3
|
+
* Real-time and historical cryptocurrency data
|
|
4
|
+
* Crypto data is available 24/7
|
|
5
|
+
*/
|
|
6
|
+
import { AlpacaClient } from '../client';
|
|
7
|
+
import { CryptoBar, CryptoPair, BTCPairs, USDTPairs, USDCPairs, USDPairs } from '../../types/alpaca-types';
|
|
8
|
+
/**
|
|
9
|
+
* Error thrown when crypto data operations fail
|
|
10
|
+
*/
|
|
11
|
+
export declare class CryptoDataError extends Error {
|
|
12
|
+
code: string;
|
|
13
|
+
symbol?: string | undefined;
|
|
14
|
+
details?: unknown | undefined;
|
|
15
|
+
constructor(message: string, code: string, symbol?: string | undefined, details?: unknown | undefined);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Crypto trade data
|
|
19
|
+
*/
|
|
20
|
+
export interface CryptoTrade {
|
|
21
|
+
/** Trade price */
|
|
22
|
+
price: number;
|
|
23
|
+
/** Trade size */
|
|
24
|
+
size: number;
|
|
25
|
+
/** Trade timestamp */
|
|
26
|
+
timestamp: Date;
|
|
27
|
+
/** Trade ID */
|
|
28
|
+
id?: number;
|
|
29
|
+
/** Taker side: 'B' for buy, 'S' for sell */
|
|
30
|
+
takerSide?: 'B' | 'S';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Crypto quote data
|
|
34
|
+
*/
|
|
35
|
+
export interface CryptoQuote {
|
|
36
|
+
/** Bid price */
|
|
37
|
+
bid: number;
|
|
38
|
+
/** Bid size */
|
|
39
|
+
bidSize: number;
|
|
40
|
+
/** Ask price */
|
|
41
|
+
ask: number;
|
|
42
|
+
/** Ask size */
|
|
43
|
+
askSize: number;
|
|
44
|
+
/** Quote timestamp */
|
|
45
|
+
timestamp: Date;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parameters for fetching crypto bars
|
|
49
|
+
*/
|
|
50
|
+
export interface GetCryptoBarsParams {
|
|
51
|
+
/** Array of crypto symbols (e.g., ['BTC/USD', 'ETH/USD']) */
|
|
52
|
+
symbols: string[];
|
|
53
|
+
/** Timeframe for bars (e.g., '1Min', '1Hour', '1Day') */
|
|
54
|
+
timeframe: string;
|
|
55
|
+
/** Start date/time for data range */
|
|
56
|
+
start?: Date;
|
|
57
|
+
/** End date/time for data range */
|
|
58
|
+
end?: Date;
|
|
59
|
+
/** Maximum number of bars to return per symbol */
|
|
60
|
+
limit?: number;
|
|
61
|
+
/** Sort order */
|
|
62
|
+
sort?: 'asc' | 'desc';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Crypto snapshot data
|
|
66
|
+
*/
|
|
67
|
+
export interface CryptoSnapshot {
|
|
68
|
+
/** Symbol */
|
|
69
|
+
symbol: string;
|
|
70
|
+
/** Latest trade */
|
|
71
|
+
latestTrade?: CryptoTrade;
|
|
72
|
+
/** Latest quote */
|
|
73
|
+
latestQuote?: CryptoQuote;
|
|
74
|
+
/** Daily bar */
|
|
75
|
+
dailyBar?: CryptoBar;
|
|
76
|
+
/** Previous daily bar */
|
|
77
|
+
prevDailyBar?: CryptoBar;
|
|
78
|
+
/** Minute bar */
|
|
79
|
+
minuteBar?: CryptoBar;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get crypto bars (OHLCV data)
|
|
83
|
+
*
|
|
84
|
+
* @param client - AlpacaClient instance
|
|
85
|
+
* @param params - Parameters for fetching bars
|
|
86
|
+
* @returns Map of symbol to array of bars
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* const bars = await getCryptoBars(client, {
|
|
90
|
+
* symbols: ['BTC/USD', 'ETH/USD'],
|
|
91
|
+
* timeframe: '1Hour',
|
|
92
|
+
* start: new Date('2024-01-01'),
|
|
93
|
+
* limit: 100,
|
|
94
|
+
* });
|
|
95
|
+
*/
|
|
96
|
+
export declare function getCryptoBars(client: AlpacaClient, params: GetCryptoBarsParams): Promise<Map<string, CryptoBar[]>>;
|
|
97
|
+
/**
|
|
98
|
+
* Get latest crypto trades
|
|
99
|
+
*
|
|
100
|
+
* @param client - AlpacaClient instance
|
|
101
|
+
* @param symbols - Array of crypto symbols
|
|
102
|
+
* @returns Map of symbol to latest trade data
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const trades = await getLatestCryptoTrades(client, ['BTC/USD', 'ETH/USD']);
|
|
106
|
+
* const btcTrade = trades.get('BTC/USD');
|
|
107
|
+
* console.log(`BTC last trade: $${btcTrade?.price}`);
|
|
108
|
+
*/
|
|
109
|
+
export declare function getLatestCryptoTrades(client: AlpacaClient, symbols: string[]): Promise<Map<string, CryptoTrade>>;
|
|
110
|
+
/**
|
|
111
|
+
* Get latest crypto quotes
|
|
112
|
+
*
|
|
113
|
+
* @param client - AlpacaClient instance
|
|
114
|
+
* @param symbols - Array of crypto symbols
|
|
115
|
+
* @returns Map of symbol to latest quote data
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* const quotes = await getLatestCryptoQuotes(client, ['BTC/USD']);
|
|
119
|
+
* const btcQuote = quotes.get('BTC/USD');
|
|
120
|
+
* console.log(`BTC bid/ask: $${btcQuote?.bid}/$${btcQuote?.ask}`);
|
|
121
|
+
*/
|
|
122
|
+
export declare function getLatestCryptoQuotes(client: AlpacaClient, symbols: string[]): Promise<Map<string, CryptoQuote>>;
|
|
123
|
+
/**
|
|
124
|
+
* Get the current price for a crypto symbol
|
|
125
|
+
* Uses the latest trade price
|
|
126
|
+
*
|
|
127
|
+
* @param client - AlpacaClient instance
|
|
128
|
+
* @param symbol - Crypto symbol (e.g., 'BTC/USD')
|
|
129
|
+
* @returns Current price
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* const btcPrice = await getCryptoPrice(client, 'BTC/USD');
|
|
133
|
+
* console.log(`Bitcoin is currently $${btcPrice.toFixed(2)}`);
|
|
134
|
+
*/
|
|
135
|
+
export declare function getCryptoPrice(client: AlpacaClient, symbol: string): Promise<number>;
|
|
136
|
+
/**
|
|
137
|
+
* Get the bid-ask spread for a crypto symbol
|
|
138
|
+
*
|
|
139
|
+
* @param client - AlpacaClient instance
|
|
140
|
+
* @param symbol - Crypto symbol (e.g., 'BTC/USD')
|
|
141
|
+
* @returns Object with bid, ask, spread, and spreadPercent
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* const spread = await getCryptoSpread(client, 'BTC/USD');
|
|
145
|
+
* console.log(`BTC spread: $${spread.spread.toFixed(2)} (${spread.spreadPercent.toFixed(4)}%)`);
|
|
146
|
+
*/
|
|
147
|
+
export declare function getCryptoSpread(client: AlpacaClient, symbol: string): Promise<{
|
|
148
|
+
bid: number;
|
|
149
|
+
ask: number;
|
|
150
|
+
spread: number;
|
|
151
|
+
spreadPercent: number;
|
|
152
|
+
}>;
|
|
153
|
+
/**
|
|
154
|
+
* Get crypto snapshots with latest trade, quote, and bar data
|
|
155
|
+
*
|
|
156
|
+
* @param client - AlpacaClient instance
|
|
157
|
+
* @param symbols - Array of crypto symbols
|
|
158
|
+
* @returns Map of symbol to snapshot data
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* const snapshots = await getCryptoSnapshots(client, ['BTC/USD', 'ETH/USD']);
|
|
162
|
+
*/
|
|
163
|
+
export declare function getCryptoSnapshots(client: AlpacaClient, symbols: string[]): Promise<Map<string, CryptoSnapshot>>;
|
|
164
|
+
/**
|
|
165
|
+
* Get historical crypto trades
|
|
166
|
+
*
|
|
167
|
+
* @param client - AlpacaClient instance
|
|
168
|
+
* @param symbol - Crypto symbol
|
|
169
|
+
* @param start - Start date/time
|
|
170
|
+
* @param end - Optional end date/time
|
|
171
|
+
* @param limit - Maximum number of trades
|
|
172
|
+
* @returns Array of trades
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* const trades = await getCryptoTrades(client, 'BTC/USD', new Date('2024-01-01'), undefined, 100);
|
|
176
|
+
*/
|
|
177
|
+
export declare function getCryptoTrades(client: AlpacaClient, symbol: string, start: Date, end?: Date, limit?: number): Promise<CryptoTrade[]>;
|
|
178
|
+
/**
|
|
179
|
+
* Get daily prices for a crypto symbol
|
|
180
|
+
*
|
|
181
|
+
* @param client - AlpacaClient instance
|
|
182
|
+
* @param symbol - Crypto symbol
|
|
183
|
+
* @param days - Number of days of history
|
|
184
|
+
* @returns Array of daily bars
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* const dailyBars = await getCryptoDailyPrices(client, 'BTC/USD', 30);
|
|
188
|
+
*/
|
|
189
|
+
export declare function getCryptoDailyPrices(client: AlpacaClient, symbol: string, days: number): Promise<CryptoBar[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Calculate 24-hour price change for a crypto symbol
|
|
192
|
+
*
|
|
193
|
+
* @param client - AlpacaClient instance
|
|
194
|
+
* @param symbol - Crypto symbol
|
|
195
|
+
* @returns Object with current price, previous price, change, and change percent
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* const change = await getCrypto24HourChange(client, 'BTC/USD');
|
|
199
|
+
* console.log(`BTC 24h change: ${change.changePercent.toFixed(2)}%`);
|
|
200
|
+
*/
|
|
201
|
+
export declare function getCrypto24HourChange(client: AlpacaClient, symbol: string): Promise<{
|
|
202
|
+
currentPrice: number;
|
|
203
|
+
previousPrice: number;
|
|
204
|
+
change: number;
|
|
205
|
+
changePercent: number;
|
|
206
|
+
}>;
|
|
207
|
+
/**
|
|
208
|
+
* All supported BTC trading pairs
|
|
209
|
+
*/
|
|
210
|
+
export declare const BTC_PAIRS: BTCPairs[];
|
|
211
|
+
/**
|
|
212
|
+
* All supported USDT trading pairs
|
|
213
|
+
*/
|
|
214
|
+
export declare const USDT_PAIRS: USDTPairs[];
|
|
215
|
+
/**
|
|
216
|
+
* All supported USDC trading pairs
|
|
217
|
+
*/
|
|
218
|
+
export declare const USDC_PAIRS: USDCPairs[];
|
|
219
|
+
/**
|
|
220
|
+
* All supported USD trading pairs
|
|
221
|
+
*/
|
|
222
|
+
export declare const USD_PAIRS: USDPairs[];
|
|
223
|
+
/**
|
|
224
|
+
* Get all supported crypto pairs
|
|
225
|
+
*
|
|
226
|
+
* @returns Array of all supported crypto trading pairs
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* const pairs = getSupportedCryptoPairs();
|
|
230
|
+
* console.log(`${pairs.length} crypto pairs available`);
|
|
231
|
+
*/
|
|
232
|
+
export declare function getSupportedCryptoPairs(): CryptoPair[];
|
|
233
|
+
/**
|
|
234
|
+
* Get supported crypto pairs by quote currency
|
|
235
|
+
*
|
|
236
|
+
* @param quoteCurrency - Quote currency ('USD', 'USDC', 'USDT', 'BTC')
|
|
237
|
+
* @returns Array of supported pairs for that quote currency
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* const usdPairs = getCryptoPairsByQuote('USD');
|
|
241
|
+
*/
|
|
242
|
+
export declare function getCryptoPairsByQuote(quoteCurrency: 'USD' | 'USDC' | 'USDT' | 'BTC'): CryptoPair[];
|
|
243
|
+
/**
|
|
244
|
+
* Check if a crypto pair is supported
|
|
245
|
+
*
|
|
246
|
+
* @param symbol - Crypto pair to check
|
|
247
|
+
* @returns true if the pair is supported
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* if (isSupportedCryptoPair('BTC/USD')) {
|
|
251
|
+
* // Trade BTC
|
|
252
|
+
* }
|
|
253
|
+
*/
|
|
254
|
+
export declare function isSupportedCryptoPair(symbol: string): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Get popular crypto pairs (most commonly traded)
|
|
257
|
+
*
|
|
258
|
+
* @returns Array of popular crypto trading pairs
|
|
259
|
+
*/
|
|
260
|
+
export declare function getPopularCryptoPairs(): CryptoPair[];
|
|
261
|
+
declare const _default: {
|
|
262
|
+
getCryptoBars: typeof getCryptoBars;
|
|
263
|
+
getLatestCryptoTrades: typeof getLatestCryptoTrades;
|
|
264
|
+
getLatestCryptoQuotes: typeof getLatestCryptoQuotes;
|
|
265
|
+
getCryptoPrice: typeof getCryptoPrice;
|
|
266
|
+
getCryptoSpread: typeof getCryptoSpread;
|
|
267
|
+
getCryptoSnapshots: typeof getCryptoSnapshots;
|
|
268
|
+
getCryptoTrades: typeof getCryptoTrades;
|
|
269
|
+
getCryptoDailyPrices: typeof getCryptoDailyPrices;
|
|
270
|
+
getCrypto24HourChange: typeof getCrypto24HourChange;
|
|
271
|
+
getSupportedCryptoPairs: typeof getSupportedCryptoPairs;
|
|
272
|
+
getCryptoPairsByQuote: typeof getCryptoPairsByQuote;
|
|
273
|
+
isSupportedCryptoPair: typeof isSupportedCryptoPair;
|
|
274
|
+
getPopularCryptoPairs: typeof getPopularCryptoPairs;
|
|
275
|
+
BTC_PAIRS: BTCPairs[];
|
|
276
|
+
USDT_PAIRS: USDTPairs[];
|
|
277
|
+
USDC_PAIRS: USDCPairs[];
|
|
278
|
+
USD_PAIRS: USDPairs[];
|
|
279
|
+
};
|
|
280
|
+
export default _default;
|
|
281
|
+
//# sourceMappingURL=data.d.ts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;;;;;GAQG;AACH,wBAAgB,uBAAuB,IAAI,UAAU,EAAE,CAEtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAC7C,UAAU,EAAE,CAad;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAI7D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,UAAU,EAAE,CAWpD;;;;;;;;;;;;;;;;;;;;AAED,wBAkBE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crypto Module Index
|
|
3
|
+
* Exports all crypto trading and market data functions
|
|
4
|
+
* Crypto trading is available 24/7 on Alpaca
|
|
5
|
+
*/
|
|
6
|
+
export { CryptoOrderError, CryptoOrderParams, createCryptoOrder, createCryptoMarketOrder, createCryptoLimitOrder, createCryptoStopOrder, createCryptoStopLimitOrder, buyCryptoNotional, sellCryptoNotional, sellAllCrypto, getOpenCryptoOrders, cancelAllCryptoOrders, isCryptoPair, } from './orders';
|
|
7
|
+
export { CryptoDataError, CryptoTrade, CryptoQuote, GetCryptoBarsParams, CryptoSnapshot, getCryptoBars, getLatestCryptoTrades, getLatestCryptoQuotes, getCryptoPrice, getCryptoSpread, getCryptoSnapshots, getCryptoTrades, getCryptoDailyPrices, getCrypto24HourChange, getSupportedCryptoPairs, getCryptoPairsByQuote, isSupportedCryptoPair, getPopularCryptoPairs, BTC_PAIRS, USDT_PAIRS, USDC_PAIRS, USD_PAIRS, } from './data';
|
|
8
|
+
export declare const orders: {
|
|
9
|
+
createCryptoOrder: typeof import("./orders").createCryptoOrder;
|
|
10
|
+
createCryptoMarketOrder: typeof import("./orders").createCryptoMarketOrder;
|
|
11
|
+
createCryptoLimitOrder: typeof import("./orders").createCryptoLimitOrder;
|
|
12
|
+
createCryptoStopOrder: typeof import("./orders").createCryptoStopOrder;
|
|
13
|
+
createCryptoStopLimitOrder: typeof import("./orders").createCryptoStopLimitOrder;
|
|
14
|
+
buyCryptoNotional: typeof import("./orders").buyCryptoNotional;
|
|
15
|
+
sellCryptoNotional: typeof import("./orders").sellCryptoNotional;
|
|
16
|
+
sellAllCrypto: typeof import("./orders").sellAllCrypto;
|
|
17
|
+
getOpenCryptoOrders: typeof import("./orders").getOpenCryptoOrders;
|
|
18
|
+
cancelAllCryptoOrders: typeof import("./orders").cancelAllCryptoOrders;
|
|
19
|
+
isCryptoPair: typeof import("./orders").isCryptoPair;
|
|
20
|
+
};
|
|
21
|
+
export declare const data: {
|
|
22
|
+
getCryptoBars: typeof import("./data").getCryptoBars;
|
|
23
|
+
getLatestCryptoTrades: typeof import("./data").getLatestCryptoTrades;
|
|
24
|
+
getLatestCryptoQuotes: typeof import("./data").getLatestCryptoQuotes;
|
|
25
|
+
getCryptoPrice: typeof import("./data").getCryptoPrice;
|
|
26
|
+
getCryptoSpread: typeof import("./data").getCryptoSpread;
|
|
27
|
+
getCryptoSnapshots: typeof import("./data").getCryptoSnapshots;
|
|
28
|
+
getCryptoTrades: typeof import("./data").getCryptoTrades;
|
|
29
|
+
getCryptoDailyPrices: typeof import("./data").getCryptoDailyPrices;
|
|
30
|
+
getCrypto24HourChange: typeof import("./data").getCrypto24HourChange;
|
|
31
|
+
getSupportedCryptoPairs: typeof import("./data").getSupportedCryptoPairs;
|
|
32
|
+
getCryptoPairsByQuote: typeof import("./data").getCryptoPairsByQuote;
|
|
33
|
+
isSupportedCryptoPair: typeof import("./data").isSupportedCryptoPair;
|
|
34
|
+
getPopularCryptoPairs: typeof import("./data").getPopularCryptoPairs;
|
|
35
|
+
BTC_PAIRS: import("../..").BTCPairs[];
|
|
36
|
+
USDT_PAIRS: import("../..").USDTPairs[];
|
|
37
|
+
USDC_PAIRS: import("../..").USDCPairs[];
|
|
38
|
+
USD_PAIRS: import("../..").USDPairs[];
|
|
39
|
+
};
|
|
40
|
+
declare const _default: {
|
|
41
|
+
orders: {
|
|
42
|
+
createCryptoOrder: typeof import("./orders").createCryptoOrder;
|
|
43
|
+
createCryptoMarketOrder: typeof import("./orders").createCryptoMarketOrder;
|
|
44
|
+
createCryptoLimitOrder: typeof import("./orders").createCryptoLimitOrder;
|
|
45
|
+
createCryptoStopOrder: typeof import("./orders").createCryptoStopOrder;
|
|
46
|
+
createCryptoStopLimitOrder: typeof import("./orders").createCryptoStopLimitOrder;
|
|
47
|
+
buyCryptoNotional: typeof import("./orders").buyCryptoNotional;
|
|
48
|
+
sellCryptoNotional: typeof import("./orders").sellCryptoNotional;
|
|
49
|
+
sellAllCrypto: typeof import("./orders").sellAllCrypto;
|
|
50
|
+
getOpenCryptoOrders: typeof import("./orders").getOpenCryptoOrders;
|
|
51
|
+
cancelAllCryptoOrders: typeof import("./orders").cancelAllCryptoOrders;
|
|
52
|
+
isCryptoPair: typeof import("./orders").isCryptoPair;
|
|
53
|
+
};
|
|
54
|
+
data: {
|
|
55
|
+
getCryptoBars: typeof import("./data").getCryptoBars;
|
|
56
|
+
getLatestCryptoTrades: typeof import("./data").getLatestCryptoTrades;
|
|
57
|
+
getLatestCryptoQuotes: typeof import("./data").getLatestCryptoQuotes;
|
|
58
|
+
getCryptoPrice: typeof import("./data").getCryptoPrice;
|
|
59
|
+
getCryptoSpread: typeof import("./data").getCryptoSpread;
|
|
60
|
+
getCryptoSnapshots: typeof import("./data").getCryptoSnapshots;
|
|
61
|
+
getCryptoTrades: typeof import("./data").getCryptoTrades;
|
|
62
|
+
getCryptoDailyPrices: typeof import("./data").getCryptoDailyPrices;
|
|
63
|
+
getCrypto24HourChange: typeof import("./data").getCrypto24HourChange;
|
|
64
|
+
getSupportedCryptoPairs: typeof import("./data").getSupportedCryptoPairs;
|
|
65
|
+
getCryptoPairsByQuote: typeof import("./data").getCryptoPairsByQuote;
|
|
66
|
+
isSupportedCryptoPair: typeof import("./data").isSupportedCryptoPair;
|
|
67
|
+
getPopularCryptoPairs: typeof import("./data").getPopularCryptoPairs;
|
|
68
|
+
BTC_PAIRS: import("../..").BTCPairs[];
|
|
69
|
+
USDT_PAIRS: import("../..").USDTPairs[];
|
|
70
|
+
USDC_PAIRS: import("../..").USDCPairs[];
|
|
71
|
+
USD_PAIRS: import("../..").USDPairs[];
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export default _default;
|
|
75
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/alpaca/crypto/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,GACb,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,eAAe,EACf,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,QAAQ,CAAC;AAMhB,eAAO,MAAM,MAAM;;;;;;;;;;;;CAAe,CAAC;AACnC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;CAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE/B,wBAGE"}
|