@adaptic/utils 0.0.359
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 +824 -0
- package/dist/index.cjs +13641 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +13614 -0
- package/dist/index.mjs.map +1 -0
- package/dist/test.js +7336 -0
- package/dist/test.js.map +1 -0
- package/dist/types/adaptic.d.ts +18 -0
- package/dist/types/adaptic.d.ts.map +1 -0
- package/dist/types/alpaca-functions.d.ts +233 -0
- package/dist/types/alpaca-functions.d.ts.map +1 -0
- package/dist/types/alpaca-market-data-api.d.ts +371 -0
- package/dist/types/alpaca-market-data-api.d.ts.map +1 -0
- package/dist/types/alpaca-trading-api.d.ts +315 -0
- package/dist/types/alpaca-trading-api.d.ts.map +1 -0
- package/dist/types/alphavantage.d.ts +44 -0
- package/dist/types/alphavantage.d.ts.map +1 -0
- package/dist/types/crypto.d.ts +46 -0
- package/dist/types/crypto.d.ts.map +1 -0
- package/dist/types/display-manager.d.ts +24 -0
- package/dist/types/display-manager.d.ts.map +1 -0
- package/dist/types/format-tools.d.ts +54 -0
- package/dist/types/format-tools.d.ts.map +1 -0
- package/dist/types/index.d.ts +415 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/logging.d.ts +12 -0
- package/dist/types/logging.d.ts.map +1 -0
- package/dist/types/market-hours.d.ts +24 -0
- package/dist/types/market-hours.d.ts.map +1 -0
- package/dist/types/market-time.d.ts +184 -0
- package/dist/types/market-time.d.ts.map +1 -0
- package/dist/types/metrics-calcs.d.ts +6 -0
- package/dist/types/metrics-calcs.d.ts.map +1 -0
- package/dist/types/misc-utils.d.ts +49 -0
- package/dist/types/misc-utils.d.ts.map +1 -0
- package/dist/types/performance-metrics.d.ts +88 -0
- package/dist/types/performance-metrics.d.ts.map +1 -0
- package/dist/types/polygon-indices.d.ts +85 -0
- package/dist/types/polygon-indices.d.ts.map +1 -0
- package/dist/types/polygon.d.ts +126 -0
- package/dist/types/polygon.d.ts.map +1 -0
- package/dist/types/price-utils.d.ts +26 -0
- package/dist/types/price-utils.d.ts.map +1 -0
- package/dist/types/technical-analysis.d.ts +90 -0
- package/dist/types/technical-analysis.d.ts.map +1 -0
- package/dist/types/test.d.ts +2 -0
- package/dist/types/test.d.ts.map +1 -0
- package/dist/types/testing/options-ws.d.ts +2 -0
- package/dist/types/testing/options-ws.d.ts.map +1 -0
- package/dist/types/time-utils.d.ts +17 -0
- package/dist/types/time-utils.d.ts.map +1 -0
- package/dist/types/types/adaptic-types.d.ts +11 -0
- package/dist/types/types/adaptic-types.d.ts.map +1 -0
- package/dist/types/types/alpaca-types.d.ts +998 -0
- package/dist/types/types/alpaca-types.d.ts.map +1 -0
- package/dist/types/types/alphavantage-types.d.ts +66 -0
- package/dist/types/types/alphavantage-types.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +21 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/logging-types.d.ts +10 -0
- package/dist/types/types/logging-types.d.ts.map +1 -0
- package/dist/types/types/market-time-types.d.ts +59 -0
- package/dist/types/types/market-time-types.d.ts.map +1 -0
- package/dist/types/types/metrics-types.d.ts +33 -0
- package/dist/types/types/metrics-types.d.ts.map +1 -0
- package/dist/types/types/polygon-indices-types.d.ts +190 -0
- package/dist/types/types/polygon-indices-types.d.ts.map +1 -0
- package/dist/types/types/polygon-types.d.ts +204 -0
- package/dist/types/types/polygon-types.d.ts.map +1 -0
- package/dist/types/types/ta-types.d.ts +89 -0
- package/dist/types/types/ta-types.d.ts.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import * as Alpaca from './alpaca-functions';
|
|
2
|
+
import * as pm from './performance-metrics';
|
|
3
|
+
import * as tu from './time-utils';
|
|
4
|
+
import * as mt from './market-time';
|
|
5
|
+
import fetchTradeMetrics from './metrics-calcs';
|
|
6
|
+
import * as pu from './price-utils';
|
|
7
|
+
import * as ft from './format-tools';
|
|
8
|
+
import * as Types from './types';
|
|
9
|
+
import * as misc from './misc-utils';
|
|
10
|
+
import * as polygon from './polygon';
|
|
11
|
+
import * as av from './alphavantage';
|
|
12
|
+
import * as crypto from './crypto';
|
|
13
|
+
import * as ta from './technical-analysis';
|
|
14
|
+
export * from './types';
|
|
15
|
+
export { AlpacaTradingAPI } from './alpaca-trading-api';
|
|
16
|
+
export { AlpacaMarketDataAPI } from './alpaca-market-data-api';
|
|
17
|
+
export declare const createAlpacaTradingAPI: (credentials: Types.AlpacaCredentials) => Types.AlpacaTradingAPI;
|
|
18
|
+
export declare const createAlpacaMarketDataAPI: () => Types.AlpacaMarketDataAPI;
|
|
19
|
+
export declare const adaptic: {
|
|
20
|
+
types: typeof Types;
|
|
21
|
+
backend: {
|
|
22
|
+
fetchAssetOverview: (symbol: string) => Promise<Types.AssetOverviewResponse>;
|
|
23
|
+
getApolloClient: () => Promise<any>;
|
|
24
|
+
};
|
|
25
|
+
alpaca: {
|
|
26
|
+
TradingAPI: typeof Types.AlpacaTradingAPI;
|
|
27
|
+
MarketDataAPI: typeof Types.AlpacaMarketDataAPI;
|
|
28
|
+
makeRequest: typeof Alpaca.makeRequest;
|
|
29
|
+
accountDetails: typeof Alpaca.fetchAccountDetails;
|
|
30
|
+
positions: typeof Alpaca.fetchAllPositions;
|
|
31
|
+
position: {
|
|
32
|
+
fetch: typeof Alpaca.fetchPosition;
|
|
33
|
+
close: typeof Alpaca.closePosition;
|
|
34
|
+
fetchAll: typeof Alpaca.fetchAllPositions;
|
|
35
|
+
closeAll: typeof Alpaca.closeAllPositions;
|
|
36
|
+
closeAllAfterHours: typeof Alpaca.closeAllPositionsAfterHours;
|
|
37
|
+
};
|
|
38
|
+
portfolioHistory: typeof Alpaca.fetchPortfolioHistory;
|
|
39
|
+
getConfig: typeof Alpaca.getConfiguration;
|
|
40
|
+
updateConfig: typeof Alpaca.updateConfiguration;
|
|
41
|
+
news: typeof Alpaca.fetchNews;
|
|
42
|
+
orders: {
|
|
43
|
+
create: typeof Alpaca.createOrder;
|
|
44
|
+
createLimitOrder: typeof Alpaca.createLimitOrder;
|
|
45
|
+
get: typeof Alpaca.getOrder;
|
|
46
|
+
getAll: typeof Alpaca.getOrders;
|
|
47
|
+
replace: typeof Alpaca.replaceOrder;
|
|
48
|
+
cancel: typeof Alpaca.cancelOrder;
|
|
49
|
+
cancelAll: typeof Alpaca.cancelAllOrders;
|
|
50
|
+
};
|
|
51
|
+
asset: {
|
|
52
|
+
get: typeof Alpaca.getAsset;
|
|
53
|
+
};
|
|
54
|
+
quote: {
|
|
55
|
+
getLatest: typeof Alpaca.getLatestQuotes;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
av: {
|
|
59
|
+
fetchQuote: (ticker: string, options?: {
|
|
60
|
+
apiKey?: string;
|
|
61
|
+
}) => Promise<Types.AlphaVantageQuoteResponse>;
|
|
62
|
+
fetchTickerNews: (ticker: string, options?: {
|
|
63
|
+
start?: Date;
|
|
64
|
+
end?: Date;
|
|
65
|
+
limit?: number;
|
|
66
|
+
apiKey?: string;
|
|
67
|
+
sort?: "LATEST" | "EARLIEST" | "RELEVANCE";
|
|
68
|
+
}) => Promise<Types.AVNewsArticle[]>;
|
|
69
|
+
convertDateToYYYYMMDDTHHMM: typeof av.convertDateToYYYYMMDDTHHMM;
|
|
70
|
+
convertYYYYMMDDTHHMMSSToDate: typeof av.convertYYYYMMDDTHHMMSSToDate;
|
|
71
|
+
};
|
|
72
|
+
crypto: {
|
|
73
|
+
fetchBars: typeof crypto.fetchBars;
|
|
74
|
+
fetchNews: typeof crypto.fetchNews;
|
|
75
|
+
};
|
|
76
|
+
format: {
|
|
77
|
+
capitalize: typeof ft.capitalize;
|
|
78
|
+
enum: typeof ft.formatEnum;
|
|
79
|
+
currency: typeof ft.formatCurrency;
|
|
80
|
+
number: typeof ft.formatNumber;
|
|
81
|
+
percentage: typeof ft.formatPercentage;
|
|
82
|
+
date: (dateString: string, updateDate?: boolean) => string;
|
|
83
|
+
dateToString: (date: Date) => string;
|
|
84
|
+
dateTimeForGS: typeof ft.dateTimeForGS;
|
|
85
|
+
};
|
|
86
|
+
metrics: {
|
|
87
|
+
trade: typeof fetchTradeMetrics;
|
|
88
|
+
alphaAndBeta: typeof pm.calculateAlphaAndBeta;
|
|
89
|
+
maxDrawdown: typeof pm.calculateMaxDrawdown;
|
|
90
|
+
dailyReturns: typeof pm.calculateDailyReturns;
|
|
91
|
+
returnsByDate: typeof pm.alignReturnsByDate;
|
|
92
|
+
beta: typeof pm.calculateBetaFromReturns;
|
|
93
|
+
infoRatio: typeof pm.calculateInformationRatio;
|
|
94
|
+
allpm: typeof pm.fetchPerformanceMetrics;
|
|
95
|
+
};
|
|
96
|
+
polygon: {
|
|
97
|
+
fetchTickerInfo: (symbol: string, options?: {
|
|
98
|
+
apiKey?: string;
|
|
99
|
+
}) => Promise<Types.PolygonTickerInfo | null>;
|
|
100
|
+
fetchGroupedDaily: (date: string, options?: {
|
|
101
|
+
apiKey?: string;
|
|
102
|
+
adjusted?: boolean;
|
|
103
|
+
includeOTC?: boolean;
|
|
104
|
+
}) => Promise<Types.PolygonGroupedDailyResponse>;
|
|
105
|
+
fetchLastTrade: (symbol: string, options?: {
|
|
106
|
+
apiKey?: string;
|
|
107
|
+
}) => Promise<Types.PolygonQuote>;
|
|
108
|
+
fetchTrades: (symbol: string, options?: {
|
|
109
|
+
apiKey?: string;
|
|
110
|
+
timestamp?: string | number;
|
|
111
|
+
timestampgt?: string | number;
|
|
112
|
+
timestampgte?: string | number;
|
|
113
|
+
timestamplt?: string | number;
|
|
114
|
+
timestamplte?: string | number;
|
|
115
|
+
order?: "asc" | "desc";
|
|
116
|
+
limit?: number;
|
|
117
|
+
sort?: string;
|
|
118
|
+
}) => Promise<Types.PolygonTradesResponse>;
|
|
119
|
+
fetchPrices: (params: {
|
|
120
|
+
ticker: string;
|
|
121
|
+
start: number;
|
|
122
|
+
end?: number;
|
|
123
|
+
multiplier: number;
|
|
124
|
+
timespan: string;
|
|
125
|
+
limit?: number;
|
|
126
|
+
}, options?: {
|
|
127
|
+
apiKey?: string;
|
|
128
|
+
}) => Promise<Types.PolygonPriceData[]>;
|
|
129
|
+
analysePolygonPriceData: typeof polygon.analysePolygonPriceData;
|
|
130
|
+
formatPriceData: typeof polygon.formatPriceData;
|
|
131
|
+
fetchDailyOpenClose: (symbol: string, date?: Date, options?: {
|
|
132
|
+
apiKey?: string;
|
|
133
|
+
adjusted?: boolean;
|
|
134
|
+
}) => Promise<Types.PolygonDailyOpenClose>;
|
|
135
|
+
getPreviousClose: typeof polygon.getPreviousClose;
|
|
136
|
+
};
|
|
137
|
+
indices: {
|
|
138
|
+
fetchAggregates: (params: Types.PolygonIndicesAggregatesParams, options?: {
|
|
139
|
+
apiKey?: string;
|
|
140
|
+
}) => Promise<Types.PolygonIndicesAggregatesResponse>;
|
|
141
|
+
fetchPreviousClose: (indicesTicker: string, options?: {
|
|
142
|
+
apiKey?: string;
|
|
143
|
+
}) => Promise<Types.PolygonIndicesPrevCloseResponse>;
|
|
144
|
+
fetchDailyOpenClose: (indicesTicker: string, date: string, options?: {
|
|
145
|
+
apiKey?: string;
|
|
146
|
+
}) => Promise<Types.PolygonIndicesDailyOpenCloseResponse>;
|
|
147
|
+
fetchSnapshot: (params?: Types.PolygonIndicesSnapshotParams, options?: {
|
|
148
|
+
apiKey?: string;
|
|
149
|
+
}) => Promise<Types.PolygonIndicesSnapshotResponse>;
|
|
150
|
+
fetchUniversalSnapshot: (tickers: string[], options?: {
|
|
151
|
+
apiKey?: string;
|
|
152
|
+
type?: string;
|
|
153
|
+
order?: string;
|
|
154
|
+
limit?: number;
|
|
155
|
+
sort?: string;
|
|
156
|
+
}) => Promise<any>;
|
|
157
|
+
formatBarData: (data: Types.PolygonIndicesAggregatesResponse) => Array<{
|
|
158
|
+
date: string;
|
|
159
|
+
open: number;
|
|
160
|
+
high: number;
|
|
161
|
+
low: number;
|
|
162
|
+
close: number;
|
|
163
|
+
timestamp: number;
|
|
164
|
+
}>;
|
|
165
|
+
};
|
|
166
|
+
price: {
|
|
167
|
+
roundUp: typeof pu.roundStockPrice;
|
|
168
|
+
equityValues: typeof pu.getEquityValues;
|
|
169
|
+
totalFees: (trade: import("@adaptic/backend-legacy/generated/typegraphql-prisma/models").Trade) => Promise<number>;
|
|
170
|
+
};
|
|
171
|
+
ta: {
|
|
172
|
+
calculateEMA: typeof ta.calculateEMA;
|
|
173
|
+
calculateMACD: typeof ta.calculateMACD;
|
|
174
|
+
calculateRSI: typeof ta.calculateRSI;
|
|
175
|
+
calculateStochasticOscillator: typeof ta.calculateStochasticOscillator;
|
|
176
|
+
calculateBollingerBands: typeof ta.calculateBollingerBands;
|
|
177
|
+
calculateSupportAndResistance: typeof ta.calculateSupportAndResistance;
|
|
178
|
+
calculateFibonacciLevels: typeof ta.calculateFibonacciLevels;
|
|
179
|
+
};
|
|
180
|
+
time: {
|
|
181
|
+
toUnixTimestamp: (ts: string) => number;
|
|
182
|
+
getTimeAgo: typeof tu.getTimeAgo;
|
|
183
|
+
timeAgo: (timestamp?: Date) => string;
|
|
184
|
+
normalizeDate: typeof tu.normalizeDate;
|
|
185
|
+
getDateInNY: typeof mt.getDateInNY;
|
|
186
|
+
createMarketTimeUtil: typeof mt.createMarketTimeUtil;
|
|
187
|
+
getStartAndEndTimestamps: typeof mt.getStartAndEndTimestamps;
|
|
188
|
+
getStartAndEndDates: typeof mt.getStartAndEndDates;
|
|
189
|
+
getMarketOpenClose: typeof mt.getMarketOpenClose;
|
|
190
|
+
calculateTimeRange: typeof tu.calculateTimeRange;
|
|
191
|
+
calculateDaysLeft: (accountCreationDate: Date) => number;
|
|
192
|
+
formatDate: (dateString: string, updateDate?: boolean) => string;
|
|
193
|
+
currentTimeET: () => Date;
|
|
194
|
+
MarketTimeUtil: typeof mt.MarketTimeUtil;
|
|
195
|
+
MARKET_TIMES: Types.MarketTimesConfig;
|
|
196
|
+
getLastTradingDateYYYYMMDD: typeof mt.getLastTradingDateYYYYMMDD;
|
|
197
|
+
getLastFullTradingDate: typeof mt.getLastFullTradingDate;
|
|
198
|
+
getNextMarketDay: typeof mt.getNextMarketDay;
|
|
199
|
+
parseETDateFromAV: (dateString: string) => Date;
|
|
200
|
+
formatToUSEastern: (date: Date, justDate?: boolean) => string;
|
|
201
|
+
unixTimetoUSEastern: (timestamp: number) => {
|
|
202
|
+
date: Date;
|
|
203
|
+
timeString: string;
|
|
204
|
+
dateString: string;
|
|
205
|
+
};
|
|
206
|
+
getMarketStatus: typeof mt.getMarketStatus;
|
|
207
|
+
timeDiffString: (milliseconds: number) => string;
|
|
208
|
+
getNYTimeZone: (date?: Date) => "-04:00" | "-05:00";
|
|
209
|
+
getTradingDate: typeof mt.getTradingDate;
|
|
210
|
+
};
|
|
211
|
+
utils: {
|
|
212
|
+
logIfDebug: (message: string, data?: unknown, type?: "info" | "warn" | "error" | "debug" | "trace") => void;
|
|
213
|
+
fetchWithRetry: typeof misc.fetchWithRetry;
|
|
214
|
+
validatePolygonApiKey: typeof misc.validatePolygonApiKey;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
export declare const adptc: {
|
|
218
|
+
types: typeof Types;
|
|
219
|
+
backend: {
|
|
220
|
+
fetchAssetOverview: (symbol: string) => Promise<Types.AssetOverviewResponse>;
|
|
221
|
+
getApolloClient: () => Promise<any>;
|
|
222
|
+
};
|
|
223
|
+
alpaca: {
|
|
224
|
+
TradingAPI: typeof Types.AlpacaTradingAPI;
|
|
225
|
+
MarketDataAPI: typeof Types.AlpacaMarketDataAPI;
|
|
226
|
+
makeRequest: typeof Alpaca.makeRequest;
|
|
227
|
+
accountDetails: typeof Alpaca.fetchAccountDetails;
|
|
228
|
+
positions: typeof Alpaca.fetchAllPositions;
|
|
229
|
+
position: {
|
|
230
|
+
fetch: typeof Alpaca.fetchPosition;
|
|
231
|
+
close: typeof Alpaca.closePosition;
|
|
232
|
+
fetchAll: typeof Alpaca.fetchAllPositions;
|
|
233
|
+
closeAll: typeof Alpaca.closeAllPositions;
|
|
234
|
+
closeAllAfterHours: typeof Alpaca.closeAllPositionsAfterHours;
|
|
235
|
+
};
|
|
236
|
+
portfolioHistory: typeof Alpaca.fetchPortfolioHistory;
|
|
237
|
+
getConfig: typeof Alpaca.getConfiguration;
|
|
238
|
+
updateConfig: typeof Alpaca.updateConfiguration;
|
|
239
|
+
news: typeof Alpaca.fetchNews;
|
|
240
|
+
orders: {
|
|
241
|
+
create: typeof Alpaca.createOrder;
|
|
242
|
+
createLimitOrder: typeof Alpaca.createLimitOrder;
|
|
243
|
+
get: typeof Alpaca.getOrder;
|
|
244
|
+
getAll: typeof Alpaca.getOrders;
|
|
245
|
+
replace: typeof Alpaca.replaceOrder;
|
|
246
|
+
cancel: typeof Alpaca.cancelOrder;
|
|
247
|
+
cancelAll: typeof Alpaca.cancelAllOrders;
|
|
248
|
+
};
|
|
249
|
+
asset: {
|
|
250
|
+
get: typeof Alpaca.getAsset;
|
|
251
|
+
};
|
|
252
|
+
quote: {
|
|
253
|
+
getLatest: typeof Alpaca.getLatestQuotes;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
av: {
|
|
257
|
+
fetchQuote: (ticker: string, options?: {
|
|
258
|
+
apiKey?: string;
|
|
259
|
+
}) => Promise<Types.AlphaVantageQuoteResponse>;
|
|
260
|
+
fetchTickerNews: (ticker: string, options?: {
|
|
261
|
+
start?: Date;
|
|
262
|
+
end?: Date;
|
|
263
|
+
limit?: number;
|
|
264
|
+
apiKey?: string;
|
|
265
|
+
sort?: "LATEST" | "EARLIEST" | "RELEVANCE";
|
|
266
|
+
}) => Promise<Types.AVNewsArticle[]>;
|
|
267
|
+
convertDateToYYYYMMDDTHHMM: typeof av.convertDateToYYYYMMDDTHHMM;
|
|
268
|
+
convertYYYYMMDDTHHMMSSToDate: typeof av.convertYYYYMMDDTHHMMSSToDate;
|
|
269
|
+
};
|
|
270
|
+
crypto: {
|
|
271
|
+
fetchBars: typeof crypto.fetchBars;
|
|
272
|
+
fetchNews: typeof crypto.fetchNews;
|
|
273
|
+
};
|
|
274
|
+
format: {
|
|
275
|
+
capitalize: typeof ft.capitalize;
|
|
276
|
+
enum: typeof ft.formatEnum;
|
|
277
|
+
currency: typeof ft.formatCurrency;
|
|
278
|
+
number: typeof ft.formatNumber;
|
|
279
|
+
percentage: typeof ft.formatPercentage;
|
|
280
|
+
date: (dateString: string, updateDate?: boolean) => string;
|
|
281
|
+
dateToString: (date: Date) => string;
|
|
282
|
+
dateTimeForGS: typeof ft.dateTimeForGS;
|
|
283
|
+
};
|
|
284
|
+
metrics: {
|
|
285
|
+
trade: typeof fetchTradeMetrics;
|
|
286
|
+
alphaAndBeta: typeof pm.calculateAlphaAndBeta;
|
|
287
|
+
maxDrawdown: typeof pm.calculateMaxDrawdown;
|
|
288
|
+
dailyReturns: typeof pm.calculateDailyReturns;
|
|
289
|
+
returnsByDate: typeof pm.alignReturnsByDate;
|
|
290
|
+
beta: typeof pm.calculateBetaFromReturns;
|
|
291
|
+
infoRatio: typeof pm.calculateInformationRatio;
|
|
292
|
+
allpm: typeof pm.fetchPerformanceMetrics;
|
|
293
|
+
};
|
|
294
|
+
polygon: {
|
|
295
|
+
fetchTickerInfo: (symbol: string, options?: {
|
|
296
|
+
apiKey?: string;
|
|
297
|
+
}) => Promise<Types.PolygonTickerInfo | null>;
|
|
298
|
+
fetchGroupedDaily: (date: string, options?: {
|
|
299
|
+
apiKey?: string;
|
|
300
|
+
adjusted?: boolean;
|
|
301
|
+
includeOTC?: boolean;
|
|
302
|
+
}) => Promise<Types.PolygonGroupedDailyResponse>;
|
|
303
|
+
fetchLastTrade: (symbol: string, options?: {
|
|
304
|
+
apiKey?: string;
|
|
305
|
+
}) => Promise<Types.PolygonQuote>;
|
|
306
|
+
fetchTrades: (symbol: string, options?: {
|
|
307
|
+
apiKey?: string;
|
|
308
|
+
timestamp?: string | number;
|
|
309
|
+
timestampgt?: string | number;
|
|
310
|
+
timestampgte?: string | number;
|
|
311
|
+
timestamplt?: string | number;
|
|
312
|
+
timestamplte?: string | number;
|
|
313
|
+
order?: "asc" | "desc";
|
|
314
|
+
limit?: number;
|
|
315
|
+
sort?: string;
|
|
316
|
+
}) => Promise<Types.PolygonTradesResponse>;
|
|
317
|
+
fetchPrices: (params: {
|
|
318
|
+
ticker: string;
|
|
319
|
+
start: number;
|
|
320
|
+
end?: number;
|
|
321
|
+
multiplier: number;
|
|
322
|
+
timespan: string;
|
|
323
|
+
limit?: number;
|
|
324
|
+
}, options?: {
|
|
325
|
+
apiKey?: string;
|
|
326
|
+
}) => Promise<Types.PolygonPriceData[]>;
|
|
327
|
+
analysePolygonPriceData: typeof polygon.analysePolygonPriceData;
|
|
328
|
+
formatPriceData: typeof polygon.formatPriceData;
|
|
329
|
+
fetchDailyOpenClose: (symbol: string, date?: Date, options?: {
|
|
330
|
+
apiKey?: string;
|
|
331
|
+
adjusted?: boolean;
|
|
332
|
+
}) => Promise<Types.PolygonDailyOpenClose>;
|
|
333
|
+
getPreviousClose: typeof polygon.getPreviousClose;
|
|
334
|
+
};
|
|
335
|
+
indices: {
|
|
336
|
+
fetchAggregates: (params: Types.PolygonIndicesAggregatesParams, options?: {
|
|
337
|
+
apiKey?: string;
|
|
338
|
+
}) => Promise<Types.PolygonIndicesAggregatesResponse>;
|
|
339
|
+
fetchPreviousClose: (indicesTicker: string, options?: {
|
|
340
|
+
apiKey?: string;
|
|
341
|
+
}) => Promise<Types.PolygonIndicesPrevCloseResponse>;
|
|
342
|
+
fetchDailyOpenClose: (indicesTicker: string, date: string, options?: {
|
|
343
|
+
apiKey?: string;
|
|
344
|
+
}) => Promise<Types.PolygonIndicesDailyOpenCloseResponse>;
|
|
345
|
+
fetchSnapshot: (params?: Types.PolygonIndicesSnapshotParams, options?: {
|
|
346
|
+
apiKey?: string;
|
|
347
|
+
}) => Promise<Types.PolygonIndicesSnapshotResponse>;
|
|
348
|
+
fetchUniversalSnapshot: (tickers: string[], options?: {
|
|
349
|
+
apiKey?: string;
|
|
350
|
+
type?: string;
|
|
351
|
+
order?: string;
|
|
352
|
+
limit?: number;
|
|
353
|
+
sort?: string;
|
|
354
|
+
}) => Promise<any>;
|
|
355
|
+
formatBarData: (data: Types.PolygonIndicesAggregatesResponse) => Array<{
|
|
356
|
+
date: string;
|
|
357
|
+
open: number;
|
|
358
|
+
high: number;
|
|
359
|
+
low: number;
|
|
360
|
+
close: number;
|
|
361
|
+
timestamp: number;
|
|
362
|
+
}>;
|
|
363
|
+
};
|
|
364
|
+
price: {
|
|
365
|
+
roundUp: typeof pu.roundStockPrice;
|
|
366
|
+
equityValues: typeof pu.getEquityValues;
|
|
367
|
+
totalFees: (trade: import("@adaptic/backend-legacy/generated/typegraphql-prisma/models").Trade) => Promise<number>;
|
|
368
|
+
};
|
|
369
|
+
ta: {
|
|
370
|
+
calculateEMA: typeof ta.calculateEMA;
|
|
371
|
+
calculateMACD: typeof ta.calculateMACD;
|
|
372
|
+
calculateRSI: typeof ta.calculateRSI;
|
|
373
|
+
calculateStochasticOscillator: typeof ta.calculateStochasticOscillator;
|
|
374
|
+
calculateBollingerBands: typeof ta.calculateBollingerBands;
|
|
375
|
+
calculateSupportAndResistance: typeof ta.calculateSupportAndResistance;
|
|
376
|
+
calculateFibonacciLevels: typeof ta.calculateFibonacciLevels;
|
|
377
|
+
};
|
|
378
|
+
time: {
|
|
379
|
+
toUnixTimestamp: (ts: string) => number;
|
|
380
|
+
getTimeAgo: typeof tu.getTimeAgo;
|
|
381
|
+
timeAgo: (timestamp?: Date) => string;
|
|
382
|
+
normalizeDate: typeof tu.normalizeDate;
|
|
383
|
+
getDateInNY: typeof mt.getDateInNY;
|
|
384
|
+
createMarketTimeUtil: typeof mt.createMarketTimeUtil;
|
|
385
|
+
getStartAndEndTimestamps: typeof mt.getStartAndEndTimestamps;
|
|
386
|
+
getStartAndEndDates: typeof mt.getStartAndEndDates;
|
|
387
|
+
getMarketOpenClose: typeof mt.getMarketOpenClose;
|
|
388
|
+
calculateTimeRange: typeof tu.calculateTimeRange;
|
|
389
|
+
calculateDaysLeft: (accountCreationDate: Date) => number;
|
|
390
|
+
formatDate: (dateString: string, updateDate?: boolean) => string;
|
|
391
|
+
currentTimeET: () => Date;
|
|
392
|
+
MarketTimeUtil: typeof mt.MarketTimeUtil;
|
|
393
|
+
MARKET_TIMES: Types.MarketTimesConfig;
|
|
394
|
+
getLastTradingDateYYYYMMDD: typeof mt.getLastTradingDateYYYYMMDD;
|
|
395
|
+
getLastFullTradingDate: typeof mt.getLastFullTradingDate;
|
|
396
|
+
getNextMarketDay: typeof mt.getNextMarketDay;
|
|
397
|
+
parseETDateFromAV: (dateString: string) => Date;
|
|
398
|
+
formatToUSEastern: (date: Date, justDate?: boolean) => string;
|
|
399
|
+
unixTimetoUSEastern: (timestamp: number) => {
|
|
400
|
+
date: Date;
|
|
401
|
+
timeString: string;
|
|
402
|
+
dateString: string;
|
|
403
|
+
};
|
|
404
|
+
getMarketStatus: typeof mt.getMarketStatus;
|
|
405
|
+
timeDiffString: (milliseconds: number) => string;
|
|
406
|
+
getNYTimeZone: (date?: Date) => "-04:00" | "-05:00";
|
|
407
|
+
getTradingDate: typeof mt.getTradingDate;
|
|
408
|
+
};
|
|
409
|
+
utils: {
|
|
410
|
+
logIfDebug: (message: string, data?: unknown, type?: "info" | "warn" | "error" | "debug" | "trace") => void;
|
|
411
|
+
fetchWithRetry: typeof misc.fetchWithRetry;
|
|
412
|
+
validatePolygonApiKey: typeof misc.validatePolygonApiKey;
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM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AAC;gBAAkB,CAAC;iBAAmB,CAAC;iBAAmB,CAAC;gBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAHluD,CAAC;AAEF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBArIqB,CAAC;;;iBA8Ea,CAAC;eACjD,CAAC;iBAAa,CAAC;kBAAgB,CAAC;gBAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBArFpB,CAAC;;;kBA4I8tM,CAAC;oBAAsB,CAAC;sBAAyB,CAAC;;;kBAtC7yM,CAAA;;;kBAsCkiZ,CAAC;qBAAuB,CAAC;uBAAkC,CAAC;wBAAmC,CAAC;uBAAkC,CAAC;wBAAmC,CAAC;iBAA4B,CAAC;iBAA2B,CAAC;gBAAkB,CAAC;;;;;eAAz6W,CAAC;;;iBAAiE,CAAC;;kBAAmC,CAAC;;;;;kBAA60Q,CAAC;oBAAsB,CAAC;;;;;;kBA3H9yT,CAAC;;;kBAmDe,CAAC;;;kBAkCkC,CAAC;;;kBAiC/C,CAAC;;;kBAKgoD,CAAC;gBAAkB,CAAC;iBAAmB,CAAC;iBAAmB,CAAC;gBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CADvsD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LogOptions } from './types/logging-types';
|
|
2
|
+
/**
|
|
3
|
+
* Logs a message to the console.
|
|
4
|
+
* @param message The message to log.
|
|
5
|
+
* @param options Optional options.
|
|
6
|
+
* @param options.source The source of the message.
|
|
7
|
+
* @param options.type The type of message to log.
|
|
8
|
+
* @param options.symbol The trading symbol associated with this log.
|
|
9
|
+
* @param options.logToFile Force logging to a file even when no symbol is provided.
|
|
10
|
+
*/
|
|
11
|
+
export declare function log(message: string, options?: LogOptions): void;
|
|
12
|
+
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/logging.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAA+C,GAAG,IAAI,CAGnG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface HolidayDetails {
|
|
2
|
+
date: string;
|
|
3
|
+
}
|
|
4
|
+
export interface MarketHolidaysForYear {
|
|
5
|
+
[holidayName: string]: HolidayDetails;
|
|
6
|
+
}
|
|
7
|
+
export interface MarketHolidays {
|
|
8
|
+
[year: number]: MarketHolidaysForYear;
|
|
9
|
+
}
|
|
10
|
+
export interface EarlyCloseDetails {
|
|
11
|
+
date: string;
|
|
12
|
+
time: string;
|
|
13
|
+
optionsTime: string;
|
|
14
|
+
notes: string;
|
|
15
|
+
}
|
|
16
|
+
export interface EarlyClosesForYear {
|
|
17
|
+
[date: string]: EarlyCloseDetails;
|
|
18
|
+
}
|
|
19
|
+
export interface MarketEarlyCloses {
|
|
20
|
+
[year: number]: EarlyClosesForYear;
|
|
21
|
+
}
|
|
22
|
+
export declare const marketHolidays: MarketHolidays;
|
|
23
|
+
export declare const marketEarlyCloses: MarketEarlyCloses;
|
|
24
|
+
//# sourceMappingURL=market-hours.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"market-hours.d.ts","sourceRoot":"","sources":["../../src/market-hours.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC;CACvC;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC;CACnC;AAED,MAAM,WAAW,iBAAiB;IAChC,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAAC;CACpC;AAED,eAAO,MAAM,cAAc,EAAE,cAsC5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBA6D/B,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { IntradayReporting, PeriodDates, MarketTimeParams, MarketOpenCloseResult, MarketStatus, MarketTimesConfig } from './types/market-time-types';
|
|
2
|
+
/**
|
|
3
|
+
* Market times for NYSE
|
|
4
|
+
* Regular market hours are 9:30am-4:00pm
|
|
5
|
+
* Early market hours are 9:30am-10:00am (first 30 minutes)
|
|
6
|
+
* Extended market hours are 4:00am to 9:30am and 4:00pm-8:00pm
|
|
7
|
+
* On days before some holidays, the market closes early at 1:00pm
|
|
8
|
+
* Early extended market hours are 1:00pm-5:00pm on early close days
|
|
9
|
+
*/
|
|
10
|
+
export declare const MARKET_TIMES: MarketTimesConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Utility class for handling market time-related operations
|
|
13
|
+
*/
|
|
14
|
+
export declare class MarketTimeUtil {
|
|
15
|
+
private timezone;
|
|
16
|
+
private intradayReporting;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new MarketTimeUtil instance
|
|
19
|
+
* @param {string} [timezone='America/New_York'] - The timezone to use for market time calculations
|
|
20
|
+
* @param {IntradayReporting} [intradayReporting='market_hours'] - The intraday reporting mode
|
|
21
|
+
*/
|
|
22
|
+
constructor(timezone?: string, intradayReporting?: IntradayReporting);
|
|
23
|
+
/**
|
|
24
|
+
* Validates the provided timezone
|
|
25
|
+
* @private
|
|
26
|
+
* @param {string} timezone - The timezone to validate
|
|
27
|
+
* @throws {Error} If the timezone is invalid
|
|
28
|
+
*/
|
|
29
|
+
private validateTimezone;
|
|
30
|
+
private formatDate;
|
|
31
|
+
private isWeekend;
|
|
32
|
+
private isHoliday;
|
|
33
|
+
isEarlyCloseDay(date: Date): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get the early close time for a given date
|
|
36
|
+
* @param date - The date to get the early close time for
|
|
37
|
+
* @returns The early close time in minutes from midnight, or null if there is no early close
|
|
38
|
+
*/
|
|
39
|
+
getEarlyCloseTime(date: Date): number | null;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a given date is a market day
|
|
42
|
+
* @param date - The date to check
|
|
43
|
+
* @returns true if the date is a market day, false otherwise
|
|
44
|
+
*/
|
|
45
|
+
isMarketDay(date: Date): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Check if a given date is within market hours
|
|
48
|
+
* @param date - The date to check
|
|
49
|
+
* @returns true if the date is within market hours, false otherwise
|
|
50
|
+
*/
|
|
51
|
+
isWithinMarketHours(date: Date): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a given date is before market hours
|
|
54
|
+
* @param date - The date to check
|
|
55
|
+
* @returns true if the date is before market hours, false otherwise
|
|
56
|
+
*/
|
|
57
|
+
private isBeforeMarketHours;
|
|
58
|
+
/**
|
|
59
|
+
* Get the last trading date, i.e. the last date that was a market day
|
|
60
|
+
* @param currentDate - The current date
|
|
61
|
+
* @returns The last trading date
|
|
62
|
+
*/
|
|
63
|
+
getLastTradingDate(currentDate?: Date): Date;
|
|
64
|
+
private getLastMarketDay;
|
|
65
|
+
getLastFullTradingDate(currentDate?: Date): Date;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the next market day from a reference date
|
|
68
|
+
* @param {Object} [options] - Options object
|
|
69
|
+
* @param {Date} [options.referenceDate] - The reference date (defaults to current date)
|
|
70
|
+
* @returns {Object} The next market day information
|
|
71
|
+
* @property {Date} date - The date object (start of day in NY time)
|
|
72
|
+
* @property {string} yyyymmdd - The date in YYYY-MM-DD format
|
|
73
|
+
* @property {string} dateISOString - Full ISO date string
|
|
74
|
+
*/
|
|
75
|
+
getNextMarketDay(date: Date): Date;
|
|
76
|
+
private getDayBoundaries;
|
|
77
|
+
private calculatePeriodStartDate;
|
|
78
|
+
getMarketTimePeriod({ period, end, intraday_reporting, outputFormat, }: MarketTimeParams): PeriodDates;
|
|
79
|
+
getMarketOpenClose(options?: {
|
|
80
|
+
date?: Date;
|
|
81
|
+
}): MarketOpenCloseResult;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new MarketTimeUtil instance
|
|
85
|
+
* @param {string} [timezone] - The timezone to use for market time calculations
|
|
86
|
+
* @param {IntradayReporting} [intraday_reporting] - The intraday reporting mode
|
|
87
|
+
* @returns {MarketTimeUtil} A new MarketTimeUtil instance
|
|
88
|
+
*/
|
|
89
|
+
export declare function createMarketTimeUtil(timezone?: string, intraday_reporting?: IntradayReporting): MarketTimeUtil;
|
|
90
|
+
/**
|
|
91
|
+
* Gets start and end timestamps for a given market time period
|
|
92
|
+
* @param {MarketTimeParams} [params] - The market time parameters
|
|
93
|
+
* @returns {PeriodDates} The start and end timestamps
|
|
94
|
+
*/
|
|
95
|
+
export declare function getStartAndEndTimestamps(params?: MarketTimeParams): PeriodDates;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the market open/close times for a given date
|
|
98
|
+
* @param {Object} [options] - Options object
|
|
99
|
+
* @param {Date} [options.date] - The date to check (defaults to current date)
|
|
100
|
+
* @returns {MarketOpenCloseResult} The market open/close times
|
|
101
|
+
*/
|
|
102
|
+
export declare function getMarketOpenClose(options?: {
|
|
103
|
+
date?: Date;
|
|
104
|
+
}): MarketOpenCloseResult;
|
|
105
|
+
/**
|
|
106
|
+
* Gets the start and end dates for a given market time period
|
|
107
|
+
* @param {MarketTimeParams} [params] - The market time parameters
|
|
108
|
+
* @returns {Object} The start and end dates
|
|
109
|
+
* @property {Date} start - The start date
|
|
110
|
+
* @property {Date} end - The end date
|
|
111
|
+
*/
|
|
112
|
+
export declare function getStartAndEndDates(params?: MarketTimeParams): {
|
|
113
|
+
start: Date;
|
|
114
|
+
end: Date;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Gets the last trading date in YYYY-MM-DD format
|
|
118
|
+
* @returns {string} The last trading date in YYYY-MM-DD format
|
|
119
|
+
*/
|
|
120
|
+
export declare function getLastTradingDateYYYYMMDD(): string;
|
|
121
|
+
/**
|
|
122
|
+
* Gets the last full trading date
|
|
123
|
+
* @param {Date} [currentDate] - The current date (defaults to now)
|
|
124
|
+
* @returns {Object} The last full trading date
|
|
125
|
+
* @property {Date} date - The date object
|
|
126
|
+
* @property {string} YYYYMMDD - The date in YYYY-MM-DD format
|
|
127
|
+
*/
|
|
128
|
+
export declare function getLastFullTradingDate(currentDate?: Date): {
|
|
129
|
+
date: Date;
|
|
130
|
+
YYYYMMDD: string;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Gets the next market day from a reference date
|
|
134
|
+
* @param {Object} [options] - Options object
|
|
135
|
+
* @param {Date} [options.referenceDate] - The reference date (defaults to current date)
|
|
136
|
+
* @returns {Object} The next market day information
|
|
137
|
+
* @property {Date} date - The date object (start of day in NY time)
|
|
138
|
+
* @property {string} yyyymmdd - The date in YYYY-MM-DD format
|
|
139
|
+
* @property {string} dateISOString - Full ISO date string
|
|
140
|
+
*/
|
|
141
|
+
export declare function getNextMarketDay({ referenceDate }?: {
|
|
142
|
+
referenceDate?: Date;
|
|
143
|
+
}): {
|
|
144
|
+
date: Date;
|
|
145
|
+
yyyymmdd: string;
|
|
146
|
+
dateISOString: string;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Gets the current time in Eastern Time
|
|
150
|
+
* @returns {Date} The current time in Eastern Time
|
|
151
|
+
*/
|
|
152
|
+
export declare const currentTimeET: () => Date;
|
|
153
|
+
/**
|
|
154
|
+
* Gets a date in New York timezone, rezoned using date-fns-tz
|
|
155
|
+
* @param {number|string|Date} time - The time to convert
|
|
156
|
+
* @returns {Date} The date in New York timezone
|
|
157
|
+
*/
|
|
158
|
+
export declare function getDateInNY(time: number | string | {
|
|
159
|
+
year: number;
|
|
160
|
+
month: number;
|
|
161
|
+
day: number;
|
|
162
|
+
}): Date;
|
|
163
|
+
/**
|
|
164
|
+
* Gets the trading date in YYYY-MM-DD format for New York timezone, for grouping of data
|
|
165
|
+
* @param {string|number|Date} time - The time to convert (string, unix timestamp in ms, or Date object)
|
|
166
|
+
* @returns {string} The trading date in YYYY-MM-DD format
|
|
167
|
+
*/
|
|
168
|
+
export declare function getTradingDate(time: string | number | Date): string;
|
|
169
|
+
/**
|
|
170
|
+
* Returns the New York timezone offset based on whether daylight savings is active
|
|
171
|
+
* @param dateString - The date string to check
|
|
172
|
+
* @returns "-04:00" during daylight savings (EDT) or "-05:00" during standard time (EST)
|
|
173
|
+
*/
|
|
174
|
+
export declare const getNYTimeZone: (date?: Date) => "-04:00" | "-05:00";
|
|
175
|
+
/**
|
|
176
|
+
* Gets the current market status
|
|
177
|
+
* @param {Object} [options] - Options object
|
|
178
|
+
* @param {Date} [options.date] - The date to check (defaults to current date)
|
|
179
|
+
* @returns {MarketStatus} The current market status
|
|
180
|
+
*/
|
|
181
|
+
export declare function getMarketStatus(options?: {
|
|
182
|
+
date?: Date;
|
|
183
|
+
}): MarketStatus;
|
|
184
|
+
//# sourceMappingURL=market-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"market-time.d.ts","sourceRoot":"","sources":["../../src/market-time.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAEhB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAGnC;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EA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AE;IAAE,IAAI,CAAC,EAAE,IAAI,CAAA;CAAO,GAAG,YAAY,CAwG3E"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Bar, BenchmarkBar } from "./types/alpaca-types";
|
|
2
|
+
import { types } from "@adaptic/backend-legacy";
|
|
3
|
+
import { CalculateBetaResult, TradeMetrics } from "./types";
|
|
4
|
+
export declare function calculateBetaFromReturns(portfolioReturns: number[], benchmarkReturns: number[]): CalculateBetaResult;
|
|
5
|
+
export default function fetchTradeMetrics(trade: types.Trade, tradeBars: Bar[], benchmarkBars: BenchmarkBar[]): Promise<TradeMetrics>;
|
|
6
|
+
//# sourceMappingURL=metrics-calcs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics-calcs.d.ts","sourceRoot":"","sources":["../../src/metrics-calcs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAoI5D,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAgFpH;AAwQD,wBAA8B,iBAAiB,CAC7C,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,SAAS,EAAE,GAAG,EAAE,EAChB,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,YAAY,CAAC,CA6BvB"}
|