@xbbg/core 1.3.0 → 1.4.1
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 +15 -0
- package/dist/index.d.ts +54 -8
- package/dist/index.js +222 -18
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -104,6 +104,7 @@ npm run bench:subscription-replay -- --fixture tmp/xbtusd-ticks.jsonl --iteratio
|
|
|
104
104
|
|
|
105
105
|
```typescript
|
|
106
106
|
import * as xbbg from '@xbbg/core';
|
|
107
|
+
import { bdp, ovr } from '@xbbg/core';
|
|
107
108
|
|
|
108
109
|
xbbg.configure({
|
|
109
110
|
host: 'localhost',
|
|
@@ -138,6 +139,19 @@ const zfpEngine = await xbbg.connect({
|
|
|
138
139
|
const hist = await xbbg.blp.abdh(['AAPL US Equity'], ['PX_LAST'], '2024-01-01', '2024-12-31');
|
|
139
140
|
const ref = await xbbg.blp.abdp(['AAPL US Equity'], ['PX_LAST', 'SECURITY_NAME']);
|
|
140
141
|
const bulk = await xbbg.blp.abds(['ES1 Index'], ['FUT_CHAIN_LAST_TRADE_DATES']);
|
|
142
|
+
|
|
143
|
+
// Composable override helper
|
|
144
|
+
await bdp(['AAPL US Equity'], ['CRNCY_ADJ_PX_LAST'], {
|
|
145
|
+
overrides: ovr({ EQY_FUND_CRNCY: 'EUR' }),
|
|
146
|
+
});
|
|
147
|
+
await bdp(['AAPL US Equity', 'MSFT US Equity'], ['CRNCY_ADJ_PX_LAST'], {
|
|
148
|
+
overrides: ovr({
|
|
149
|
+
EQY_FUND_CRNCY: 'USD',
|
|
150
|
+
'AAPL US Equity': ovr({ EQY_FUND_CRNCY: 'EUR' }),
|
|
151
|
+
'MSFT US Equity': ovr({ EQY_FUND_CRNCY: 'JPY' }),
|
|
152
|
+
}),
|
|
153
|
+
});
|
|
154
|
+
|
|
141
155
|
const bars = await xbbg.blp.abdib('AAPL US Equity', '2024-12-01', 5);
|
|
142
156
|
const ticks = await xbbg.blp.abdtick(
|
|
143
157
|
'AAPL US Equity',
|
|
@@ -230,6 +244,7 @@ const px = await engine.currencyConversion('700 HK Equity', 'USD', '20240101', '
|
|
|
230
244
|
- `zfpRemote` (`'8194'` or `'8196'`) for Bloomberg-assigned ZFP endpoints in an entitled environment; do not combine it with `host`/`port`/`servers`/`socks5`
|
|
231
245
|
- `socks5` for proxied access to already-provisioned direct Bloomberg endpoints
|
|
232
246
|
- `retryPolicy`, `numStartAttempts`, and recovery settings for reconnect behavior
|
|
247
|
+
- `shardRequests`, `shardThreshold`, `shardChunkSize`, and `shardMaxConcurrent` for opt-in sharding of wide multi-security `bdp`/`bdh` requests
|
|
233
248
|
|
|
234
249
|
The JS binding forwards these fields directly to the Rust engine, so Node can configure the same auth and transport features already available in the core runtime. Invalid transport combinations such as `zfpRemote` plus direct hosts fail during configuration instead of silently connecting to `localhost:8194`.
|
|
235
250
|
|
package/dist/index.d.ts
CHANGED
|
@@ -122,6 +122,14 @@ interface EngineConfig {
|
|
|
122
122
|
zfpRemote?: '8194' | '8196';
|
|
123
123
|
requestPoolSize?: number;
|
|
124
124
|
subscriptionPoolSize?: number;
|
|
125
|
+
/** Enable request sharding for eligible multi-security bdp/bdh requests. Default false. */
|
|
126
|
+
shardRequests?: boolean;
|
|
127
|
+
/** Minimum securities before request sharding applies. Default 20. */
|
|
128
|
+
shardThreshold?: number;
|
|
129
|
+
/** Maximum securities per sharded request. Default 16. */
|
|
130
|
+
shardChunkSize?: number;
|
|
131
|
+
/** Maximum concurrent shard requests per user request. Default 4. */
|
|
132
|
+
shardMaxConcurrent?: number;
|
|
125
133
|
validationMode?: string;
|
|
126
134
|
subscriptionFlushThreshold?: number;
|
|
127
135
|
maxEventQueueSize?: number;
|
|
@@ -161,7 +169,7 @@ interface RequestInput {
|
|
|
161
169
|
securities?: readonly string[];
|
|
162
170
|
security?: string;
|
|
163
171
|
fields?: readonly string[];
|
|
164
|
-
overrides?:
|
|
172
|
+
overrides?: OverridesInput;
|
|
165
173
|
elements?: readonly StringPair[];
|
|
166
174
|
kwargs?: readonly StringPair[];
|
|
167
175
|
jsonElements?: string;
|
|
@@ -197,8 +205,34 @@ interface FieldInfo {
|
|
|
197
205
|
}
|
|
198
206
|
type PrimitiveValue = string | number | boolean;
|
|
199
207
|
type OverridesMap = Record<string, PrimitiveValue>;
|
|
208
|
+
type OverrideValue = PrimitiveValue | Date | {
|
|
209
|
+
toJSDate: () => Date;
|
|
210
|
+
};
|
|
211
|
+
interface OverrideObject {
|
|
212
|
+
readonly [key: string]: OverrideValue | OverrideNestedSource;
|
|
213
|
+
}
|
|
214
|
+
type OverrideNestedSource = OverrideObject | OverrideSpecLike | readonly OverrideEntry[];
|
|
215
|
+
interface SecurityOverrideSpec {
|
|
216
|
+
readonly security: string;
|
|
217
|
+
readonly overrides: readonly StringPair[];
|
|
218
|
+
}
|
|
219
|
+
interface OverrideSpecLike {
|
|
220
|
+
readonly pairs: readonly StringPair[];
|
|
221
|
+
readonly securityOverrides: readonly SecurityOverrideSpec[];
|
|
222
|
+
toPairs(): StringPair[];
|
|
223
|
+
toObject(): OverridesMap;
|
|
224
|
+
toSecurityOverrides(): SecurityOverrideSpec[];
|
|
225
|
+
merge(...sources: OverrideSource[]): OverrideSpecLike;
|
|
226
|
+
forSecurity(security: string, ...sources: OverrideSource[]): OverrideSpecLike;
|
|
227
|
+
}
|
|
228
|
+
type OverrideEntry = {
|
|
229
|
+
readonly key: string;
|
|
230
|
+
readonly value: OverrideValue | OverrideNestedSource;
|
|
231
|
+
} | readonly [string, OverrideValue | OverrideNestedSource];
|
|
232
|
+
type OverrideSource = OverrideObject | OverrideSpecLike | readonly OverrideEntry[];
|
|
233
|
+
type OverridesInput = OverrideSource;
|
|
200
234
|
interface BdpOptions {
|
|
201
|
-
overrides?:
|
|
235
|
+
overrides?: OverridesInput;
|
|
202
236
|
kwargs?: OverridesMap;
|
|
203
237
|
format?: string;
|
|
204
238
|
backend?: BackendKind;
|
|
@@ -208,7 +242,7 @@ interface BdpOptions {
|
|
|
208
242
|
interface BdhOptions {
|
|
209
243
|
start?: DateLike;
|
|
210
244
|
end?: DateLike;
|
|
211
|
-
overrides?:
|
|
245
|
+
overrides?: OverridesInput;
|
|
212
246
|
kwargs?: OverridesMap;
|
|
213
247
|
format?: string;
|
|
214
248
|
backend?: BackendKind;
|
|
@@ -253,13 +287,13 @@ interface BeqsOptions {
|
|
|
253
287
|
asof?: DateLike;
|
|
254
288
|
screenType?: string;
|
|
255
289
|
group?: string;
|
|
256
|
-
overrides?:
|
|
290
|
+
overrides?: OverridesInput;
|
|
257
291
|
kwargs?: OverridesMap;
|
|
258
292
|
format?: string;
|
|
259
293
|
backend?: BackendKind;
|
|
260
294
|
}
|
|
261
295
|
interface BsrchOptions {
|
|
262
|
-
overrides?:
|
|
296
|
+
overrides?: OverridesInput;
|
|
263
297
|
kwargs?: OverridesMap;
|
|
264
298
|
format?: string;
|
|
265
299
|
backend?: BackendKind;
|
|
@@ -289,7 +323,7 @@ interface BlkpOptions {
|
|
|
289
323
|
backend?: BackendKind;
|
|
290
324
|
}
|
|
291
325
|
interface RequestOptions {
|
|
292
|
-
overrides?:
|
|
326
|
+
overrides?: OverridesInput;
|
|
293
327
|
kwargs?: OverridesMap;
|
|
294
328
|
format?: string;
|
|
295
329
|
backend?: BackendKind;
|
|
@@ -533,6 +567,18 @@ declare function formatDateTime(value: DateTimeLike | undefined | null): string
|
|
|
533
567
|
declare const CDX_INFO_FIELDS: readonly string[];
|
|
534
568
|
declare const CDX_PRICING_FIELDS: readonly string[];
|
|
535
569
|
declare const CDX_RISK_FIELDS: readonly string[];
|
|
570
|
+
declare class OverrideSpec implements OverrideSpecLike {
|
|
571
|
+
readonly pairs: readonly StringPair[];
|
|
572
|
+
readonly securityOverrides: readonly SecurityOverrideSpec[];
|
|
573
|
+
constructor(pairs: readonly StringPair[], securityOverrides?: readonly SecurityOverrideSpec[]);
|
|
574
|
+
[Symbol.iterator](): Iterator<StringPair>;
|
|
575
|
+
toPairs(): StringPair[];
|
|
576
|
+
toObject(): OverridesMap;
|
|
577
|
+
toSecurityOverrides(): SecurityOverrideSpec[];
|
|
578
|
+
merge(...sources: OverrideSource[]): OverrideSpec;
|
|
579
|
+
forSecurity(security: string, ...sources: OverrideSource[]): OverrideSpec;
|
|
580
|
+
}
|
|
581
|
+
declare function ovr(...sources: OverrideSource[]): OverrideSpec;
|
|
536
582
|
interface RawStudy {
|
|
537
583
|
studyType?: string;
|
|
538
584
|
study?: string;
|
|
@@ -665,7 +711,7 @@ declare function abdp(tickers: string | readonly string[], fields: string | read
|
|
|
665
711
|
declare function bdp(tickers: string | readonly string[], fields: string | readonly string[], options?: BdpOptions): Promise<unknown>;
|
|
666
712
|
declare function abdh(tickers: string | readonly string[], fields: string | readonly string[], start?: DateLike | BdhOptions, end?: DateLike, options?: BdhOptions): Promise<unknown>;
|
|
667
713
|
declare function bdh(tickers: string | readonly string[], fields: string | readonly string[], options?: BdhOptions): Promise<unknown>;
|
|
668
|
-
declare function abds(tickers: string | readonly string[], fields: string | readonly string[], overrides?:
|
|
714
|
+
declare function abds(tickers: string | readonly string[], fields: string | readonly string[], overrides?: OverridesInput, options?: BdpOptions): Promise<unknown>;
|
|
669
715
|
declare function bds(tickers: string | readonly string[], fields: string | readonly string[], options?: BdpOptions): Promise<unknown>;
|
|
670
716
|
declare function abdib(ticker: string, dt?: DateTimeLike | BdibOptions, interval?: number | BdibOptions, options?: BdibOptions): Promise<unknown>;
|
|
671
717
|
declare function bdib(ticker: string, options?: BdibOptions): Promise<unknown>;
|
|
@@ -746,4 +792,4 @@ declare function version(): string;
|
|
|
746
792
|
declare const setLogLevel: (level: string) => void;
|
|
747
793
|
declare const getLogLevel: () => string;
|
|
748
794
|
|
|
749
|
-
export { type ActiveCdxOptions, ArrowSubscription, type AuthConfig, Backend, type BackendKind, type BdhOptions, type BdibOptions, type BdpOptions, type BdtickOptions, type BeqsOptions, type BfldsOptions, type BlkpOptions, BlpError, BlpInternalError, BlpLimitError, BlpRequestError, BlpSessionError, BlpTimeoutError, BlpValidationError, type BqlOptions, type BqrOptions, type BsrchOptions, type BtaOptions, CDX_INFO_FIELDS, CDX_PRICING_FIELDS, CDX_RISK_FIELDS, type CdxOptions, type CdxTickerInfo, type CorporateBondsOptions, type DateLike, type DateTimeLike, type DividendOptions, type DividendYieldOptions, Engine, type EngineConfig, type EtfHoldingsOptions, type ExchangeInfoResult, type ExchangeOverrideInput, FieldHandle, type FieldInfo, Format, type FormatKind, type FuturesCandidate, type FuturesCurveOptions, type FuturesResolveOptions, type FxPairInfo, type IndexMembersOptions, type MarketRule, type OverridesMap, type PreferredsOptions, type PrimitiveValue, type RecipeBackendOptions, type RequestInput, type RequestOptions, type ServerAddress, type SessionWindowsInfo, type Socks5Config, type StreamOptions, type StringPair, Subscription, type SubscriptionStats, Tick, type TickValue, type TickerParts, type TimeRange, type TlsConfig, type TurnoverOptions, type VolFieldSpec, type VolSurfaceOptions, type VolSurfacePreset, type YasOptions, abdh, abdib, abdp, abds, abdtick, asubscribe, bdh, bdib, bdp, bds, bdtick, blp, configure, connect, ext, formatDate, formatDateTime, getLogLevel, setLogLevel, subscribe, version, wrapError };
|
|
795
|
+
export { type ActiveCdxOptions, ArrowSubscription, type AuthConfig, Backend, type BackendKind, type BdhOptions, type BdibOptions, type BdpOptions, type BdtickOptions, type BeqsOptions, type BfldsOptions, type BlkpOptions, BlpError, BlpInternalError, BlpLimitError, BlpRequestError, BlpSessionError, BlpTimeoutError, BlpValidationError, type BqlOptions, type BqrOptions, type BsrchOptions, type BtaOptions, CDX_INFO_FIELDS, CDX_PRICING_FIELDS, CDX_RISK_FIELDS, type CdxOptions, type CdxTickerInfo, type CorporateBondsOptions, type DateLike, type DateTimeLike, type DividendOptions, type DividendYieldOptions, Engine, type EngineConfig, type EtfHoldingsOptions, type ExchangeInfoResult, type ExchangeOverrideInput, FieldHandle, type FieldInfo, Format, type FormatKind, type FuturesCandidate, type FuturesCurveOptions, type FuturesResolveOptions, type FxPairInfo, type IndexMembersOptions, type MarketRule, type OverrideEntry, type OverrideNestedSource, type OverrideObject, type OverrideSource, OverrideSpec, type OverrideSpecLike, type OverrideValue, type OverridesInput, type OverridesMap, type PreferredsOptions, type PrimitiveValue, type RecipeBackendOptions, type RequestInput, type RequestOptions, type SecurityOverrideSpec, type ServerAddress, type SessionWindowsInfo, type Socks5Config, type StreamOptions, type StringPair, Subscription, type SubscriptionStats, Tick, type TickValue, type TickerParts, type TimeRange, type TlsConfig, type TurnoverOptions, type VolFieldSpec, type VolSurfaceOptions, type VolSurfacePreset, type YasOptions, abdh, abdib, abdp, abds, abdtick, asubscribe, bdh, bdib, bdp, bds, bdtick, blp, configure, connect, ext, formatDate, formatDateTime, getLogLevel, ovr, setLogLevel, subscribe, version, wrapError };
|
package/dist/index.js
CHANGED
|
@@ -1095,6 +1095,189 @@ function mapObjectToPairs(obj) {
|
|
|
1095
1095
|
value: toRequestString(value)
|
|
1096
1096
|
}));
|
|
1097
1097
|
}
|
|
1098
|
+
var OVR_SOURCE_TYPE_ERROR = "ovr() expects objects, OverrideSpec, or arrays of override entries";
|
|
1099
|
+
function normalizeOverrideValue(value) {
|
|
1100
|
+
if (value instanceof Date || hasToJSDate(value)) {
|
|
1101
|
+
return formatDate(value) ?? "";
|
|
1102
|
+
}
|
|
1103
|
+
return String(value);
|
|
1104
|
+
}
|
|
1105
|
+
function isOverrideSpecLike(value) {
|
|
1106
|
+
return isPlainObject(value) && Array.isArray(value.pairs) && typeof value.toPairs === "function" && typeof value.toObject === "function" && typeof value.merge === "function";
|
|
1107
|
+
}
|
|
1108
|
+
function isOverrideObject(value) {
|
|
1109
|
+
return isPlainObject(value) && !(value instanceof Date) && !hasToJSDate(value) && !isOverrideSpecLike(value) && !ArrayBuffer.isView(value);
|
|
1110
|
+
}
|
|
1111
|
+
function normalizeOverrideEntry(entry) {
|
|
1112
|
+
if (Array.isArray(entry)) {
|
|
1113
|
+
if (entry.length !== 2) {
|
|
1114
|
+
throw new TypeError(OVR_SOURCE_TYPE_ERROR);
|
|
1115
|
+
}
|
|
1116
|
+
return [String(entry[0]), entry[1]];
|
|
1117
|
+
}
|
|
1118
|
+
if (isPlainObject(entry) && "key" in entry && "value" in entry) {
|
|
1119
|
+
return [String(entry.key), entry.value];
|
|
1120
|
+
}
|
|
1121
|
+
throw new TypeError(OVR_SOURCE_TYPE_ERROR);
|
|
1122
|
+
}
|
|
1123
|
+
function createOverrideState() {
|
|
1124
|
+
return {
|
|
1125
|
+
merged: /* @__PURE__ */ new Map(),
|
|
1126
|
+
securityMerged: /* @__PURE__ */ new Map(),
|
|
1127
|
+
securityOrder: []
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
function isPerSecurityOverrideValue(value) {
|
|
1131
|
+
return isOverrideSpecLike(value) || Array.isArray(value) || isOverrideObject(value);
|
|
1132
|
+
}
|
|
1133
|
+
function addSecurityOverrideSource(security, source, state) {
|
|
1134
|
+
const spec = ovr(source);
|
|
1135
|
+
const pairs = spec.toPairs();
|
|
1136
|
+
if (pairs.length === 0) {
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
let merged = state.securityMerged.get(security);
|
|
1140
|
+
if (merged === void 0) {
|
|
1141
|
+
merged = /* @__PURE__ */ new Map();
|
|
1142
|
+
state.securityMerged.set(security, merged);
|
|
1143
|
+
state.securityOrder.push(security);
|
|
1144
|
+
}
|
|
1145
|
+
for (const pair of pairs) {
|
|
1146
|
+
merged.set(pair.key, pair.value);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
function addOverridePair(key, value, state) {
|
|
1150
|
+
if (isPerSecurityOverrideValue(value)) {
|
|
1151
|
+
addSecurityOverrideSource(key, value, state);
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
state.merged.set(key, normalizeOverrideValue(value));
|
|
1155
|
+
}
|
|
1156
|
+
function addOverrideSource(source, state) {
|
|
1157
|
+
if (typeof source === "string" || ArrayBuffer.isView(source)) {
|
|
1158
|
+
throw new TypeError(OVR_SOURCE_TYPE_ERROR);
|
|
1159
|
+
}
|
|
1160
|
+
if (isOverrideSpecLike(source)) {
|
|
1161
|
+
for (const pair of source.toPairs()) {
|
|
1162
|
+
state.merged.set(pair.key, normalizeOverrideValue(pair.value));
|
|
1163
|
+
}
|
|
1164
|
+
const securityOverrides = typeof source.toSecurityOverrides === "function" ? source.toSecurityOverrides() : source.securityOverrides ?? [];
|
|
1165
|
+
for (const entry of securityOverrides) {
|
|
1166
|
+
addSecurityOverrideSource(entry.security, entry.overrides, state);
|
|
1167
|
+
}
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
if (Array.isArray(source)) {
|
|
1171
|
+
for (const entry of source) {
|
|
1172
|
+
const [key, value] = normalizeOverrideEntry(entry);
|
|
1173
|
+
addOverridePair(key, value, state);
|
|
1174
|
+
}
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
if (isOverrideObject(source)) {
|
|
1178
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1179
|
+
addOverridePair(key, value, state);
|
|
1180
|
+
}
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
throw new TypeError(OVR_SOURCE_TYPE_ERROR);
|
|
1184
|
+
}
|
|
1185
|
+
function securityOverridesFromState(state) {
|
|
1186
|
+
return state.securityOrder.flatMap((security) => {
|
|
1187
|
+
const pairs = state.securityMerged.get(security);
|
|
1188
|
+
if (pairs === void 0 || pairs.size === 0) {
|
|
1189
|
+
return [];
|
|
1190
|
+
}
|
|
1191
|
+
return [
|
|
1192
|
+
{
|
|
1193
|
+
overrides: [...pairs].map(([key, value]) => ({ key, value })),
|
|
1194
|
+
security
|
|
1195
|
+
}
|
|
1196
|
+
];
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
var OverrideSpec = class {
|
|
1200
|
+
pairs;
|
|
1201
|
+
securityOverrides;
|
|
1202
|
+
constructor(pairs, securityOverrides = []) {
|
|
1203
|
+
this.pairs = Object.freeze(
|
|
1204
|
+
pairs.map(
|
|
1205
|
+
(pair) => Object.freeze({
|
|
1206
|
+
key: pair.key,
|
|
1207
|
+
value: pair.value
|
|
1208
|
+
})
|
|
1209
|
+
)
|
|
1210
|
+
);
|
|
1211
|
+
this.securityOverrides = Object.freeze(
|
|
1212
|
+
securityOverrides.map(
|
|
1213
|
+
(entry) => Object.freeze({
|
|
1214
|
+
overrides: Object.freeze(
|
|
1215
|
+
entry.overrides.map(
|
|
1216
|
+
(pair) => Object.freeze({
|
|
1217
|
+
key: pair.key,
|
|
1218
|
+
value: pair.value
|
|
1219
|
+
})
|
|
1220
|
+
)
|
|
1221
|
+
),
|
|
1222
|
+
security: entry.security
|
|
1223
|
+
})
|
|
1224
|
+
)
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
[Symbol.iterator]() {
|
|
1228
|
+
return this.toPairs()[Symbol.iterator]();
|
|
1229
|
+
}
|
|
1230
|
+
toPairs() {
|
|
1231
|
+
return this.pairs.map((pair) => ({ key: pair.key, value: pair.value }));
|
|
1232
|
+
}
|
|
1233
|
+
toObject() {
|
|
1234
|
+
return Object.fromEntries(this.pairs.map((pair) => [pair.key, pair.value]));
|
|
1235
|
+
}
|
|
1236
|
+
toSecurityOverrides() {
|
|
1237
|
+
return this.securityOverrides.map((entry) => ({
|
|
1238
|
+
overrides: entry.overrides.map((pair) => ({ key: pair.key, value: pair.value })),
|
|
1239
|
+
security: entry.security
|
|
1240
|
+
}));
|
|
1241
|
+
}
|
|
1242
|
+
merge(...sources) {
|
|
1243
|
+
return ovr(this, ...sources);
|
|
1244
|
+
}
|
|
1245
|
+
forSecurity(security, ...sources) {
|
|
1246
|
+
return ovr(this, { [security]: ovr(...sources) });
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
function ovr(...sources) {
|
|
1250
|
+
const state = createOverrideState();
|
|
1251
|
+
for (const source of sources) {
|
|
1252
|
+
addOverrideSource(source, state);
|
|
1253
|
+
}
|
|
1254
|
+
return new OverrideSpec(
|
|
1255
|
+
[...state.merged].map(([key, value]) => ({ key, value })),
|
|
1256
|
+
securityOverridesFromState(state)
|
|
1257
|
+
);
|
|
1258
|
+
}
|
|
1259
|
+
function mapOverridesToPairs(input) {
|
|
1260
|
+
if (input === void 0) {
|
|
1261
|
+
return void 0;
|
|
1262
|
+
}
|
|
1263
|
+
const spec = ovr(input);
|
|
1264
|
+
if (spec.toSecurityOverrides().length > 0) {
|
|
1265
|
+
throw new TypeError("Per-security overrides are only supported by bdp(), bdh(), and bds()");
|
|
1266
|
+
}
|
|
1267
|
+
return spec.toPairs();
|
|
1268
|
+
}
|
|
1269
|
+
function mapOverridesToRequestParts(input) {
|
|
1270
|
+
if (input === void 0) {
|
|
1271
|
+
return {};
|
|
1272
|
+
}
|
|
1273
|
+
const spec = ovr(input);
|
|
1274
|
+
const overrides = spec.toPairs();
|
|
1275
|
+
const securityOverrides = spec.toSecurityOverrides();
|
|
1276
|
+
return {
|
|
1277
|
+
...overrides.length === 0 ? {} : { overrides },
|
|
1278
|
+
...securityOverrides.length === 0 ? {} : { securityOverrides }
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1098
1281
|
var BDTICK_BOOLEAN_KWARGS = Object.freeze([
|
|
1099
1282
|
["includeConditionCodes", "includeConditionCodes"],
|
|
1100
1283
|
["includeExchangeCodes", "includeExchangeCodes"],
|
|
@@ -1225,10 +1408,9 @@ function normalizeRecoveryOptions(options = {}) {
|
|
|
1225
1408
|
delete normalized.recoveryRate;
|
|
1226
1409
|
delete normalized.recovery_rate;
|
|
1227
1410
|
if (recoveryRate !== void 0) {
|
|
1228
|
-
normalized.overrides = {
|
|
1229
|
-
...normalized.overrides,
|
|
1411
|
+
normalized.overrides = ovr(normalized.overrides ?? {}, {
|
|
1230
1412
|
CDS_RR: toRequestString(recoveryRate)
|
|
1231
|
-
};
|
|
1413
|
+
});
|
|
1232
1414
|
}
|
|
1233
1415
|
return normalized;
|
|
1234
1416
|
}
|
|
@@ -1618,7 +1800,18 @@ var Engine = class _Engine {
|
|
|
1618
1800
|
}
|
|
1619
1801
|
async request(params) {
|
|
1620
1802
|
const backend = normalizeBackend(params.backend);
|
|
1621
|
-
const {
|
|
1803
|
+
const {
|
|
1804
|
+
backend: _discarded,
|
|
1805
|
+
overrides,
|
|
1806
|
+
securityOverrides: legacySecurityOverrides,
|
|
1807
|
+
...rest
|
|
1808
|
+
} = params;
|
|
1809
|
+
if (legacySecurityOverrides !== void 0) {
|
|
1810
|
+
throw new TypeError(
|
|
1811
|
+
'Use overrides: ovr({ "<SECURITY>": { ... } }) for per-security overrides'
|
|
1812
|
+
);
|
|
1813
|
+
}
|
|
1814
|
+
const nativeParams = { ...rest, ...mapOverridesToRequestParts(overrides) };
|
|
1622
1815
|
try {
|
|
1623
1816
|
const buffer = await this.inner.request(nativeParams);
|
|
1624
1817
|
return ipcToBackend(buffer, backend);
|
|
@@ -1627,8 +1820,18 @@ var Engine = class _Engine {
|
|
|
1627
1820
|
}
|
|
1628
1821
|
}
|
|
1629
1822
|
async requestRaw(params) {
|
|
1823
|
+
const {
|
|
1824
|
+
overrides,
|
|
1825
|
+
securityOverrides: legacySecurityOverrides,
|
|
1826
|
+
...rest
|
|
1827
|
+
} = params;
|
|
1828
|
+
if (legacySecurityOverrides !== void 0) {
|
|
1829
|
+
throw new TypeError(
|
|
1830
|
+
'Use overrides: ovr({ "<SECURITY>": { ... } }) for per-security overrides'
|
|
1831
|
+
);
|
|
1832
|
+
}
|
|
1630
1833
|
try {
|
|
1631
|
-
return await this.inner.request(
|
|
1834
|
+
return await this.inner.request({ ...rest, ...mapOverridesToRequestParts(overrides) });
|
|
1632
1835
|
} catch (error) {
|
|
1633
1836
|
throw wrapError(error);
|
|
1634
1837
|
}
|
|
@@ -1642,7 +1845,7 @@ var Engine = class _Engine {
|
|
|
1642
1845
|
includeSecurityErrors: Boolean(options.includeSecurityErrors),
|
|
1643
1846
|
kwargs: mapObjectToPairs(options.kwargs),
|
|
1644
1847
|
operation: "ReferenceDataRequest",
|
|
1645
|
-
overrides:
|
|
1848
|
+
overrides: options.overrides,
|
|
1646
1849
|
securities: tickers,
|
|
1647
1850
|
service: "//blp/refdata",
|
|
1648
1851
|
validateFields: options.validateFields
|
|
@@ -1656,7 +1859,7 @@ var Engine = class _Engine {
|
|
|
1656
1859
|
format: options.format,
|
|
1657
1860
|
kwargs: mapObjectToPairs(options.kwargs),
|
|
1658
1861
|
operation: "ReferenceDataRequest",
|
|
1659
|
-
overrides:
|
|
1862
|
+
overrides: options.overrides,
|
|
1660
1863
|
securities: tickers,
|
|
1661
1864
|
service: "//blp/refdata",
|
|
1662
1865
|
validateFields: options.validateFields
|
|
@@ -1671,7 +1874,7 @@ var Engine = class _Engine {
|
|
|
1671
1874
|
format: options.format,
|
|
1672
1875
|
kwargs: mapObjectToPairs(options.kwargs),
|
|
1673
1876
|
operation: "HistoricalDataRequest",
|
|
1674
|
-
overrides:
|
|
1877
|
+
overrides: options.overrides,
|
|
1675
1878
|
securities: tickers,
|
|
1676
1879
|
service: "//blp/refdata",
|
|
1677
1880
|
startDate: formatDate(options.start),
|
|
@@ -1732,7 +1935,6 @@ var Engine = class _Engine {
|
|
|
1732
1935
|
elements.push({ key: "asOfDate", value: asofFormatted });
|
|
1733
1936
|
}
|
|
1734
1937
|
}
|
|
1735
|
-
const overrides = { ...options.overrides };
|
|
1736
1938
|
return await this.request({
|
|
1737
1939
|
backend: options.backend,
|
|
1738
1940
|
elements,
|
|
@@ -1740,19 +1942,19 @@ var Engine = class _Engine {
|
|
|
1740
1942
|
format: options.format,
|
|
1741
1943
|
kwargs: mapObjectToPairs(options.kwargs),
|
|
1742
1944
|
operation: "BeqsRequest",
|
|
1743
|
-
overrides:
|
|
1945
|
+
overrides: mapOverridesToPairs(options.overrides),
|
|
1744
1946
|
service: "//blp/refdata"
|
|
1745
1947
|
});
|
|
1746
1948
|
}
|
|
1747
1949
|
async bsrch(searchSpec, options = {}) {
|
|
1748
|
-
const elements =
|
|
1749
|
-
Domain: toRequestString(searchSpec),
|
|
1750
|
-
...options.overrides,
|
|
1751
|
-
...options.kwargs
|
|
1752
|
-
|
|
1950
|
+
const elements = [
|
|
1951
|
+
{ key: "Domain", value: toRequestString(searchSpec) },
|
|
1952
|
+
...mapOverridesToPairs(options.overrides) ?? [],
|
|
1953
|
+
...mapObjectToPairs(options.kwargs) ?? []
|
|
1954
|
+
];
|
|
1753
1955
|
return await this.request({
|
|
1754
1956
|
backend: options.backend,
|
|
1755
|
-
elements
|
|
1957
|
+
elements,
|
|
1756
1958
|
extractor: "bsrch",
|
|
1757
1959
|
format: options.format,
|
|
1758
1960
|
operation: "ExcelGetGridRequest",
|
|
@@ -1807,7 +2009,7 @@ var Engine = class _Engine {
|
|
|
1807
2009
|
format: options.format,
|
|
1808
2010
|
kwargs: mapObjectToPairs(options.kwargs),
|
|
1809
2011
|
operation: "PortfolioDataRequest",
|
|
1810
|
-
overrides:
|
|
2012
|
+
overrides: mapOverridesToPairs(options.overrides),
|
|
1811
2013
|
security: toRequestString(portfolio),
|
|
1812
2014
|
service: "//blp/refdata"
|
|
1813
2015
|
});
|
|
@@ -2288,7 +2490,7 @@ async function bdh(tickers, fields, options = {}) {
|
|
|
2288
2490
|
}
|
|
2289
2491
|
async function abds(tickers, fields, overrides, options = {}) {
|
|
2290
2492
|
const engine = await getConfiguredEngine();
|
|
2291
|
-
const normalizedOptions =
|
|
2493
|
+
const normalizedOptions = overrides === void 0 ? options : { ...options, overrides: ovr(options.overrides ?? {}, overrides) };
|
|
2292
2494
|
return await engine.bds(toStringArray(tickers), toStringArray(fields), normalizedOptions);
|
|
2293
2495
|
}
|
|
2294
2496
|
async function bds(tickers, fields, options = {}) {
|
|
@@ -2438,6 +2640,7 @@ exports.CDX_RISK_FIELDS = CDX_RISK_FIELDS;
|
|
|
2438
2640
|
exports.Engine = Engine;
|
|
2439
2641
|
exports.FieldHandle = FieldHandle;
|
|
2440
2642
|
exports.Format = Format;
|
|
2643
|
+
exports.OverrideSpec = OverrideSpec;
|
|
2441
2644
|
exports.Subscription = Subscription;
|
|
2442
2645
|
exports.Tick = Tick;
|
|
2443
2646
|
exports.abdh = abdh;
|
|
@@ -2458,6 +2661,7 @@ exports.ext = ext;
|
|
|
2458
2661
|
exports.formatDate = formatDate;
|
|
2459
2662
|
exports.formatDateTime = formatDateTime;
|
|
2460
2663
|
exports.getLogLevel = getLogLevel;
|
|
2664
|
+
exports.ovr = ovr;
|
|
2461
2665
|
exports.setLogLevel = setLogLevel;
|
|
2462
2666
|
exports.subscribe = subscribe;
|
|
2463
2667
|
exports.version = version;
|