@startsimpli/api 0.5.15 → 0.5.17
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/package.json +1 -1
- package/src/constants/endpoints.ts +3 -0
- package/src/index.ts +19 -0
- package/src/lib/markets-api.ts +156 -4
package/package.json
CHANGED
|
@@ -74,6 +74,9 @@ export const ENDPOINTS = {
|
|
|
74
74
|
INSTRUMENT_ANALYTICS: (symbol: string) => `api/v1/markets/instruments/${symbol}/analytics`,
|
|
75
75
|
INSTRUMENT_NEWS: (symbol: string) => `api/v1/markets/instruments/${symbol}/news`,
|
|
76
76
|
MARKETS_HEALTH: 'api/v1/markets/health',
|
|
77
|
+
SECTOR_BREADTH: 'api/v1/markets/sector_breadth',
|
|
78
|
+
EARNINGS_CALENDAR: 'api/v1/markets/calendar',
|
|
79
|
+
TRADING_SNAPSHOTS: 'api/v1/markets/trading/snapshots',
|
|
77
80
|
|
|
78
81
|
// Sources ops
|
|
79
82
|
SOURCES_HEALTH: 'api/v1/sources/ops/health',
|
package/src/index.ts
CHANGED
|
@@ -205,6 +205,9 @@ export type {
|
|
|
205
205
|
VolatilityPoint,
|
|
206
206
|
BetaAnalytics,
|
|
207
207
|
PairSpreadPoint,
|
|
208
|
+
NewsDirection,
|
|
209
|
+
NewsSentimentLabel,
|
|
210
|
+
NewsEventType,
|
|
208
211
|
InstrumentNewsItem,
|
|
209
212
|
InstrumentNewsResponse,
|
|
210
213
|
NewsParams,
|
|
@@ -212,4 +215,20 @@ export type {
|
|
|
212
215
|
InstrumentHealthInterval,
|
|
213
216
|
SourceInstanceHealth,
|
|
214
217
|
MarketsHealth,
|
|
218
|
+
SectorBreadthParams,
|
|
219
|
+
SectorBreadthPoint,
|
|
220
|
+
SectorBreadthResponse,
|
|
221
|
+
EarningsCalendarParams,
|
|
222
|
+
EarningsTimeOfDay,
|
|
223
|
+
EarningsCalendarRow,
|
|
224
|
+
EarningsCalendarResponse,
|
|
225
|
+
PairConsensus,
|
|
226
|
+
CommitteeVotes,
|
|
227
|
+
PairMember,
|
|
228
|
+
PairSnapshot,
|
|
229
|
+
AlpacaPosition,
|
|
230
|
+
AlpacaSnapshot,
|
|
231
|
+
TradingSnapshot,
|
|
232
|
+
TradingSnapshotsResponse,
|
|
233
|
+
TradingSnapshotsParams,
|
|
215
234
|
} from './lib/markets-api';
|
package/src/lib/markets-api.ts
CHANGED
|
@@ -92,17 +92,34 @@ export type AnalyticsResponse =
|
|
|
92
92
|
| BetaAnalytics
|
|
93
93
|
| PairSpreadPoint[];
|
|
94
94
|
|
|
95
|
+
export type NewsDirection = 'bullish' | 'bearish' | 'neutral' | 'unclear';
|
|
96
|
+
export type NewsSentimentLabel = 'positive' | 'neutral' | 'negative';
|
|
97
|
+
export type NewsEventType =
|
|
98
|
+
| 'ceasefire'
|
|
99
|
+
| 'escalation'
|
|
100
|
+
| 'supply_disruption'
|
|
101
|
+
| 'opec'
|
|
102
|
+
| 'earnings'
|
|
103
|
+
| 'central_bank'
|
|
104
|
+
| 'regulatory'
|
|
105
|
+
| 'general';
|
|
106
|
+
|
|
95
107
|
export interface InstrumentNewsItem {
|
|
96
108
|
id: string;
|
|
97
|
-
title: string;
|
|
109
|
+
title: string | null;
|
|
98
110
|
summary?: string | null;
|
|
99
|
-
url: string;
|
|
111
|
+
url: string | null;
|
|
100
112
|
publisherName?: string | null;
|
|
101
113
|
publisherDomain?: string | null;
|
|
102
114
|
publishedAt?: string | null;
|
|
103
115
|
queryTag?: string | null;
|
|
104
|
-
confidence
|
|
105
|
-
|
|
116
|
+
confidence: number;
|
|
117
|
+
direction: NewsDirection | null;
|
|
118
|
+
sentiment: number | null;
|
|
119
|
+
sentimentLabel: NewsSentimentLabel | null;
|
|
120
|
+
eventType: NewsEventType;
|
|
121
|
+
marketMovingScore: number;
|
|
122
|
+
ingestedAt: string;
|
|
106
123
|
}
|
|
107
124
|
|
|
108
125
|
export interface InstrumentNewsResponse {
|
|
@@ -117,6 +134,122 @@ export interface NewsParams {
|
|
|
117
134
|
since?: string;
|
|
118
135
|
}
|
|
119
136
|
|
|
137
|
+
export interface SectorBreadthParams {
|
|
138
|
+
sector: string;
|
|
139
|
+
since?: string;
|
|
140
|
+
until?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface SectorBreadthPoint {
|
|
144
|
+
barDate: string;
|
|
145
|
+
nUp: number;
|
|
146
|
+
nTotal: number;
|
|
147
|
+
pctUp: number;
|
|
148
|
+
meanReturn: number;
|
|
149
|
+
returnDispersion: number;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface SectorBreadthResponse {
|
|
153
|
+
sector: string;
|
|
154
|
+
interval: '1d';
|
|
155
|
+
members: string[];
|
|
156
|
+
count: number;
|
|
157
|
+
results: SectorBreadthPoint[];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface EarningsCalendarParams {
|
|
161
|
+
symbols: string[];
|
|
162
|
+
since?: string;
|
|
163
|
+
until?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type EarningsTimeOfDay = 'BMO' | 'AMC' | 'During' | 'Unknown';
|
|
167
|
+
|
|
168
|
+
export interface EarningsCalendarRow {
|
|
169
|
+
date: string;
|
|
170
|
+
symbol: string;
|
|
171
|
+
eventType: 'earnings';
|
|
172
|
+
confirmed: boolean;
|
|
173
|
+
timeOfDay: EarningsTimeOfDay;
|
|
174
|
+
epsEstimate: number | null;
|
|
175
|
+
reportedEps: number | null;
|
|
176
|
+
surprisePct: number | null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface EarningsCalendarResponse {
|
|
180
|
+
symbolsRequested: string[];
|
|
181
|
+
since: string | null;
|
|
182
|
+
until: string | null;
|
|
183
|
+
count: number;
|
|
184
|
+
errors: Record<string, string>;
|
|
185
|
+
results: EarningsCalendarRow[];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export type PairConsensus = 'BULL' | 'BEAR' | 'FLAT';
|
|
189
|
+
|
|
190
|
+
export interface CommitteeVotes {
|
|
191
|
+
BULL: number;
|
|
192
|
+
BEAR: number;
|
|
193
|
+
FLAT: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface PairMember {
|
|
197
|
+
modelName: string;
|
|
198
|
+
features: string[];
|
|
199
|
+
thresholds: [number, number];
|
|
200
|
+
scoreToday: number;
|
|
201
|
+
signalToday: number;
|
|
202
|
+
endValueFull?: number | null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface PairSnapshot {
|
|
206
|
+
consensus: PairConsensus;
|
|
207
|
+
topScore: number;
|
|
208
|
+
topSignal: number;
|
|
209
|
+
targetSymbol: string;
|
|
210
|
+
committeeN: number;
|
|
211
|
+
committeeVotes: CommitteeVotes;
|
|
212
|
+
committeeMeanScore: number;
|
|
213
|
+
topConfigName: string;
|
|
214
|
+
members: PairMember[];
|
|
215
|
+
[key: string]: unknown;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface AlpacaPosition {
|
|
219
|
+
symbol: string;
|
|
220
|
+
qty: number;
|
|
221
|
+
marketValue: number;
|
|
222
|
+
costBasis: number;
|
|
223
|
+
unrealizedPl: number;
|
|
224
|
+
[key: string]: unknown;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface AlpacaSnapshot {
|
|
228
|
+
equity: number;
|
|
229
|
+
cash: number;
|
|
230
|
+
buyingPower: number;
|
|
231
|
+
positions: AlpacaPosition[];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface TradingSnapshot {
|
|
235
|
+
id: string;
|
|
236
|
+
timestampUtc: string;
|
|
237
|
+
createdAt: string;
|
|
238
|
+
alpaca: AlpacaSnapshot;
|
|
239
|
+
pairs: Record<string, PairSnapshot>;
|
|
240
|
+
notes?: string | null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface TradingSnapshotsResponse {
|
|
244
|
+
count: number;
|
|
245
|
+
results: TradingSnapshot[];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface TradingSnapshotsParams {
|
|
249
|
+
since?: string;
|
|
250
|
+
limit?: number;
|
|
251
|
+
}
|
|
252
|
+
|
|
120
253
|
export interface InstrumentHealthInterval {
|
|
121
254
|
interval: BarInterval;
|
|
122
255
|
barCount: number;
|
|
@@ -190,4 +323,23 @@ export class MarketsApi {
|
|
|
190
323
|
async getHealth(): Promise<MarketsHealth> {
|
|
191
324
|
return this.client.fetch.get<MarketsHealth>(ENDPOINTS.MARKETS_HEALTH);
|
|
192
325
|
}
|
|
326
|
+
|
|
327
|
+
async getSectorBreadth(params: SectorBreadthParams): Promise<SectorBreadthResponse> {
|
|
328
|
+
return this.client.fetch.get<SectorBreadthResponse>(ENDPOINTS.SECTOR_BREADTH, {
|
|
329
|
+
params: params as unknown as Record<string, unknown>,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
async getEarningsCalendar(params: EarningsCalendarParams): Promise<EarningsCalendarResponse> {
|
|
334
|
+
const { symbols, ...rest } = params;
|
|
335
|
+
return this.client.fetch.get<EarningsCalendarResponse>(ENDPOINTS.EARNINGS_CALENDAR, {
|
|
336
|
+
params: { ...rest, symbols: symbols.join(',') } as unknown as Record<string, unknown>,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async getTradingSnapshots(params?: TradingSnapshotsParams): Promise<TradingSnapshotsResponse> {
|
|
341
|
+
return this.client.fetch.get<TradingSnapshotsResponse>(ENDPOINTS.TRADING_SNAPSHOTS, {
|
|
342
|
+
params: params as Record<string, unknown> | undefined,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
193
345
|
}
|