nexustrade 5.0.0 → 5.2.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/README.md CHANGED
@@ -119,6 +119,27 @@ Backtest operations may include `warnings: string[]` immediately after
119
119
  submission and again in the terminal `result`. Treat them as material caveats;
120
120
  they do not change a successful operation into a failure.
121
121
 
122
+ ### Benchmark
123
+
124
+ A terminal `result` also carries the benchmark the run was compared against:
125
+ `result.baselineSymbol` and `result.baselineStatistics`, the buy-and-hold
126
+ benchmark's statistics over the same window (for example
127
+ `baselineStatistics.percentChange`). Choose the benchmark with
128
+ `backtest(book, { ..., baselineAsset: { type: "Stock", symbol: "QQQ" } })`, or
129
+ `{ type: "Cryptocurrency", symbol: "BTC-USD" }`. `baselineSymbol` is the older
130
+ Stock-only shorthand; pass one or the other, never both. When both are
131
+ omitted, the single traded stock or option underlying is the benchmark,
132
+ otherwise SPY.
133
+
134
+ Changed in 5.2.0: an omitted baseline used to be SPY for every API backtest.
135
+ It is now inferred exactly as the MCP `backtest_portfolio` tool infers it, and
136
+ an explicit baseline symbol is uppercased. Earlier results were not rerun. A
137
+ new run of the same book can therefore report a different benchmark, so pass
138
+ the baseline explicitly where an earlier comparison must hold.
139
+ A cached single-name spec that omitted the baseline therefore runs once more
140
+ after upgrading, because its benchmark is now part of the run's identity. The
141
+ portfolio handle accepts the same typed benchmark: `PortfolioHandle.backtest({ baselineAsset })`.
142
+
122
143
  ### Collateral at risk
123
144
 
124
145
  A terminal operation's `result.statistics` answers how much capital the run had
@@ -898,6 +919,7 @@ is missing here, so this list cannot drift from the code.
898
919
  | `new NexusTradeClient({ apiKey, baseUrl })` | Explicit credentials |
899
920
  | `new NexusTradeClient()` | Lazy anonymous workspace with strict limits |
900
921
  | `NexusTradeClient.fromEnvironment()` | Read them from the environment or `.env` |
922
+ | `new NexusTradeClient({ requestTimeoutSeconds })` | Per-request HTTP timeout (default 30); also accepted by `fromEnvironment` |
901
923
  | `exportWorkspaceSession()` | Export an anonymous workspace for later use |
902
924
  | `importWorkspaceSession(token)` | Resume an existing anonymous workspace |
903
925
 
@@ -1025,9 +1047,17 @@ check on an otherwise-successful reply.
1025
1047
 
1026
1048
  ## Timeouts
1027
1049
 
1028
- `new HttpTransport({ timeoutSeconds })` (default 30) is a total wall-clock
1029
- deadline for one request. Neither it nor the poll timeout bounds how long a
1030
- _job_ takes.
1050
+ `new NexusTradeClient({ requestTimeoutSeconds })` (default 30) sets the HTTP
1051
+ transport's total wall-clock deadline for one request. Raise it for large
1052
+ `createBacktests` batches:
1053
+
1054
+ ```ts
1055
+ const client = NexusTradeClient.fromEnvironment({ requestTimeoutSeconds: 120 });
1056
+ ```
1057
+
1058
+ It is separate from the `timeoutSeconds` wait option, which bounds how long a
1059
+ poll waits. Neither bounds how long a _job_ takes. A custom `transport`
1060
+ configures its own timeout, so passing both throws.
1031
1061
 
1032
1062
  ## Scope
1033
1063
 
@@ -510,6 +510,7 @@ const BACKTEST_ARG_NAMES = [
510
510
  ["start_date", "startDate"],
511
511
  ["end_date", "endDate"],
512
512
  ["baseline_symbol", "baseline"],
513
+ ["baseline_asset", "baselineAsset"],
513
514
  ["interval", "interval"],
514
515
  ["initial_value", "initialValue"],
515
516
  ["generate_events", "generateEvents"],
@@ -788,6 +789,10 @@ class NexusTradeClient {
788
789
  transport;
789
790
  constructor(options = {}) {
790
791
  if (options.transport) {
792
+ if (options.requestTimeoutSeconds !== undefined) {
793
+ throw new Error("requestTimeoutSeconds applies only to the built-in HTTP transport; " +
794
+ "configure a custom transport directly.");
795
+ }
791
796
  this.transport = options.transport;
792
797
  return;
793
798
  }
@@ -801,10 +806,11 @@ class NexusTradeClient {
801
806
  apiKey,
802
807
  baseUrl: baseUrl ?? exports.DEFAULT_API_BASE_URL,
803
808
  workspaceSession: options.workspaceSession,
809
+ timeoutSeconds: options.requestTimeoutSeconds,
804
810
  });
805
811
  }
806
- static fromEnvironment() {
807
- return new NexusTradeClient();
812
+ static fromEnvironment(options = {}) {
813
+ return new NexusTradeClient(options);
808
814
  }
809
815
  /** Return the anonymous workspace token after the first API call bootstraps it. */
810
816
  exportWorkspaceSession() {
@@ -1230,16 +1230,18 @@ function IndicatorWindowAgo(operand, length, interval, initialValue) {
1230
1230
  return d;
1231
1231
  }
1232
1232
  /**
1233
- * News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset.
1233
+ * News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset. includeMemberCompanies (default false): also count headlines about the industry's member companies. A headline the model judges to be about a company (for example "SpaceX valuation hits a record") then counts toward every industry that company belongs to with core or material exposure in NexusTrade's industry classification, including companies not yet listed, by SEC CIK. A headline counts once per industry even when it names several member companies or also names the industry, scored by its industry score when it has one and otherwise by its score for the member company it is most about (ties to the numerically lowest SEC CIK); copies of one story count once per session across both kinds. Membership is the company's classification public when the headline appeared, or its first classification for headlines before that, so older history, and the history placed for a newly listed company, uses a membership that became known later. Default false reads exactly the headlines that name the industry.
1234
1234
  * @param industry Canonical industry tag whose news to read, as IsIndustry lists it. Legacy aliases are separate news series and are rejected, never mapped.
1235
1235
  * @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
1236
1236
  * @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest and about 20 is the usual window. The same value for every asset.
1237
+ * @param includeMemberCompanies Also count headlines about the industry's member companies, each headline once per industry. Default false reads only headlines that name the industry.
1237
1238
  */
1238
- function IndustryNewsSentiment(industry, measure = "Mean", lookbackDays = 1) {
1239
+ function IndustryNewsSentiment(industry, measure = "Mean", lookbackDays = 1, includeMemberCompanies = false) {
1239
1240
  const d = { type: "IndustryNewsSentiment" };
1240
1241
  d["industry"] = industry;
1241
1242
  d["measure"] = measure;
1242
1243
  d["lookbackDays"] = lookbackDays;
1244
+ d["includeMemberCompanies"] = includeMemberCompanies;
1243
1245
  return d;
1244
1246
  }
1245
1247
  /**
@@ -377,6 +377,9 @@ class PortfolioHandle {
377
377
  };
378
378
  if (options.baseline !== undefined)
379
379
  input.baseline = options.baseline;
380
+ if (options.baselineAsset !== undefined) {
381
+ input.baselineAsset = options.baselineAsset;
382
+ }
380
383
  if (options.interval !== undefined)
381
384
  input.interval = options.interval;
382
385
  if (options.initialValue !== undefined) {
@@ -176,6 +176,8 @@ export interface NexusTradeClientOptions {
176
176
  baseUrl?: string;
177
177
  workspaceSession?: string;
178
178
  transport?: Transport;
179
+ /** Per-request HTTP timeout for the built-in transport (default 30). */
180
+ requestTimeoutSeconds?: number;
179
181
  }
180
182
  export interface WaitOptions {
181
183
  timeoutSeconds?: number;
@@ -241,7 +243,7 @@ export declare function waitForOperation(fetch: (operationId: string) => Promise
241
243
  export declare class NexusTradeClient {
242
244
  private readonly transport;
243
245
  constructor(options?: NexusTradeClientOptions);
244
- static fromEnvironment(): NexusTradeClient;
246
+ static fromEnvironment(options?: Pick<NexusTradeClientOptions, "requestTimeoutSeconds">): NexusTradeClient;
245
247
  /** Return the anonymous workspace token after the first API call bootstraps it. */
246
248
  exportWorkspaceSession(): string | undefined;
247
249
  /** Resume an existing anonymous workspace without creating a replacement. */
@@ -500,6 +500,7 @@ const BACKTEST_ARG_NAMES = [
500
500
  ["start_date", "startDate"],
501
501
  ["end_date", "endDate"],
502
502
  ["baseline_symbol", "baseline"],
503
+ ["baseline_asset", "baselineAsset"],
503
504
  ["interval", "interval"],
504
505
  ["initial_value", "initialValue"],
505
506
  ["generate_events", "generateEvents"],
@@ -778,6 +779,10 @@ export class NexusTradeClient {
778
779
  transport;
779
780
  constructor(options = {}) {
780
781
  if (options.transport) {
782
+ if (options.requestTimeoutSeconds !== undefined) {
783
+ throw new Error("requestTimeoutSeconds applies only to the built-in HTTP transport; " +
784
+ "configure a custom transport directly.");
785
+ }
781
786
  this.transport = options.transport;
782
787
  return;
783
788
  }
@@ -791,10 +796,11 @@ export class NexusTradeClient {
791
796
  apiKey,
792
797
  baseUrl: baseUrl ?? DEFAULT_API_BASE_URL,
793
798
  workspaceSession: options.workspaceSession,
799
+ timeoutSeconds: options.requestTimeoutSeconds,
794
800
  });
795
801
  }
796
- static fromEnvironment() {
797
- return new NexusTradeClient();
802
+ static fromEnvironment(options = {}) {
803
+ return new NexusTradeClient(options);
798
804
  }
799
805
  /** Return the anonymous workspace token after the first API call bootstraps it. */
800
806
  exportWorkspaceSession() {
@@ -1253,12 +1253,13 @@ export declare function IndicatorStandardDeviation(operand: Indicator, length?:
1253
1253
  */
1254
1254
  export declare function IndicatorWindowAgo(operand: Indicator, length: number, interval: Interval, initialValue?: number): Indicator;
1255
1255
  /**
1256
- * News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset.
1256
+ * News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset. includeMemberCompanies (default false): also count headlines about the industry's member companies. A headline the model judges to be about a company (for example "SpaceX valuation hits a record") then counts toward every industry that company belongs to with core or material exposure in NexusTrade's industry classification, including companies not yet listed, by SEC CIK. A headline counts once per industry even when it names several member companies or also names the industry, scored by its industry score when it has one and otherwise by its score for the member company it is most about (ties to the numerically lowest SEC CIK); copies of one story count once per session across both kinds. Membership is the company's classification public when the headline appeared, or its first classification for headlines before that, so older history, and the history placed for a newly listed company, uses a membership that became known later. Default false reads exactly the headlines that name the industry.
1257
1257
  * @param industry Canonical industry tag whose news to read, as IsIndustry lists it. Legacy aliases are separate news series and are rejected, never mapped.
1258
1258
  * @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
1259
1259
  * @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest and about 20 is the usual window. The same value for every asset.
1260
+ * @param includeMemberCompanies Also count headlines about the industry's member companies, each headline once per industry. Default false reads only headlines that name the industry.
1260
1261
  */
1261
- export declare function IndustryNewsSentiment(industry: "technology" | "financialServices" | "healthcare" | "energy" | "consumerGoods" | "entertainmentAndMedia" | "manufacturing" | "transportation" | "realEstate" | "utilities" | "agriculture" | "education" | "retail" | "artificialIntelligence" | "aiInfrastructure" | "analytics" | "cloudComputing" | "dataCenter" | "database" | "cybersecurity" | "developerTools" | "software" | "saas" | "enterpriseSoftware" | "customerExperienceSoftware" | "productivityTools" | "collaborationSoftware" | "digitalSignatureAndAuthentication" | "hardware" | "consumerElectronics" | "networking" | "semiconductor" | "chipDesign" | "chipManufacturing" | "semiconductorEquipment" | "gpuAndAccelerators" | "memoryAndStorage" | "quantumComputing" | "robotics" | "industrialAutomation" | "iot" | "smartDevices" | "wearable" | "3dPrinting" | "augmentedReality" | "virtualReality" | "space" | "satellites" | "aerospace" | "defense" | "drones" | "financialInfrastructure" | "capitalMarketsTechnology" | "banking" | "assetManagement" | "brokerage" | "payments" | "fintech" | "insurance" | "autoInsurance" | "homeInsurance" | "lifeInsurance" | "healthInsurance" | "blockchain" | "cryptocurrency" | "biotechnology" | "pharmaceuticals" | "medicalDevices" | "digitalHealth" | "lifeSciencesSoftware" | "bioinformatics" | "computationalBiology" | "computationalDrugDiscovery" | "oncology" | "immunotherapy" | "vaccines" | "veterinary" | "oil" | "gas" | "oilfieldServices" | "cleanEnergy" | "renewableEnergy" | "solarEnergy" | "windEnergy" | "nuclearEnergy" | "hydrogen" | "batteryTechnology" | "miningAndNaturalResources" | "gold" | "silver" | "chemicals" | "advancedMaterials" | "waterInfrastructure" | "wasteManagementAndRecycling" | "forestry" | "construction" | "buildingMaterials" | "electricalAndGridInfrastructure" | "logisticsAndSupplyChain" | "airline" | "maritime" | "railroads" | "automotive" | "electricVehicle" | "autonomousTransportation" | "recreationalVehicle" | "cruise" | "rideShare" | "printing" | "packaging" | "householdProducts" | "ecommerce" | "digitalMarketplace" | "fashionAndApparel" | "luxuryGoods" | "jewelry" | "foodAndBeverage" | "foodDelivery" | "nutrition" | "petCare" | "outdoorAndRecreationalEquipment" | "sportsAndFitness" | "cannabis" | "hospitalityAndTravel" | "homeSecurity" | "advertising" | "gaming" | "gambling" | "sportsBetting" | "socialMedia" | "streaming" | "movies" | "musicAndAudio" | "publishing" | "telecommunications" | "edtech" | "proptech", measure?: Measure, lookbackDays?: number): Indicator;
1262
+ export declare function IndustryNewsSentiment(industry: "technology" | "financialServices" | "healthcare" | "energy" | "consumerGoods" | "entertainmentAndMedia" | "manufacturing" | "transportation" | "realEstate" | "utilities" | "agriculture" | "education" | "retail" | "artificialIntelligence" | "aiInfrastructure" | "analytics" | "cloudComputing" | "dataCenter" | "database" | "cybersecurity" | "developerTools" | "software" | "saas" | "enterpriseSoftware" | "customerExperienceSoftware" | "productivityTools" | "collaborationSoftware" | "digitalSignatureAndAuthentication" | "hardware" | "consumerElectronics" | "networking" | "semiconductor" | "chipDesign" | "chipManufacturing" | "semiconductorEquipment" | "gpuAndAccelerators" | "memoryAndStorage" | "quantumComputing" | "robotics" | "industrialAutomation" | "iot" | "smartDevices" | "wearable" | "3dPrinting" | "augmentedReality" | "virtualReality" | "space" | "satellites" | "aerospace" | "defense" | "drones" | "financialInfrastructure" | "capitalMarketsTechnology" | "banking" | "assetManagement" | "brokerage" | "payments" | "fintech" | "insurance" | "autoInsurance" | "homeInsurance" | "lifeInsurance" | "healthInsurance" | "blockchain" | "cryptocurrency" | "biotechnology" | "pharmaceuticals" | "medicalDevices" | "digitalHealth" | "lifeSciencesSoftware" | "bioinformatics" | "computationalBiology" | "computationalDrugDiscovery" | "oncology" | "immunotherapy" | "vaccines" | "veterinary" | "oil" | "gas" | "oilfieldServices" | "cleanEnergy" | "renewableEnergy" | "solarEnergy" | "windEnergy" | "nuclearEnergy" | "hydrogen" | "batteryTechnology" | "miningAndNaturalResources" | "gold" | "silver" | "chemicals" | "advancedMaterials" | "waterInfrastructure" | "wasteManagementAndRecycling" | "forestry" | "construction" | "buildingMaterials" | "electricalAndGridInfrastructure" | "logisticsAndSupplyChain" | "airline" | "maritime" | "railroads" | "automotive" | "electricVehicle" | "autonomousTransportation" | "recreationalVehicle" | "cruise" | "rideShare" | "printing" | "packaging" | "householdProducts" | "ecommerce" | "digitalMarketplace" | "fashionAndApparel" | "luxuryGoods" | "jewelry" | "foodAndBeverage" | "foodDelivery" | "nutrition" | "petCare" | "outdoorAndRecreationalEquipment" | "sportsAndFitness" | "cannabis" | "hospitalityAndTravel" | "homeSecurity" | "advertising" | "gaming" | "gambling" | "sportsBetting" | "socialMedia" | "streaming" | "movies" | "musicAndAudio" | "publishing" | "telecommunications" | "edtech" | "proptech", measure?: Measure, lookbackDays?: number, includeMemberCompanies?: boolean): Indicator;
1262
1263
  /**
1263
1264
  * InitialValue indicator.
1264
1265
  */
@@ -998,16 +998,18 @@ export function IndicatorWindowAgo(operand, length, interval, initialValue) {
998
998
  return d;
999
999
  }
1000
1000
  /**
1001
- * News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset.
1001
+ * News sentiment about an industry over its last lookbackDays daily news snapshots (default 1, the latest). industry is one of the canonical industry tags (the same list IsIndustry uses). Headlines come from the GDELT global news feed, and a fine-tuned model scores every headline that mentions the industry: whether it is really about the industry, and whether it is positive, neutral or negative news for it (a headline it calls neutral scores 0; others score from -1.0 to 1.0). Each trading day has one snapshot at 09:15 New York, and a headline counts toward the first session whose 09:15 cutoff is at or after the time GDELT published it. Backtests and live trading read the same rows. lookbackDays counts trading sessions whether or not the industry had news in them; a single session is noisy, and about 20 sessions is the usual window for a sentiment rule. Only headlines the model judges to be about the industry count, and copies of one story within 7 days count once per session. measure (default Mean): Mean is the average sentiment from -1.0 to 1.0, Median is the middle score (the average of the two middle scores for an even count), NetCount is positive minus negative headlines, ArticleCount is the number of qualifying headlines. Coverage begins on 2019-09-23: a window reaching earlier is measured over the sessions since then, and the backtest warns that it held less history than configured. Every measure has no value across sessions with no published snapshot, or when the latest snapshot due has not been published. Mean and Median also have no value when the window holds no qualifying headline; the counts are then 0. The value is the same for every asset: it takes no target asset. includeMemberCompanies (default false): also count headlines about the industry's member companies. A headline the model judges to be about a company (for example "SpaceX valuation hits a record") then counts toward every industry that company belongs to with core or material exposure in NexusTrade's industry classification, including companies not yet listed, by SEC CIK. A headline counts once per industry even when it names several member companies or also names the industry, scored by its industry score when it has one and otherwise by its score for the member company it is most about (ties to the numerically lowest SEC CIK); copies of one story count once per session across both kinds. Membership is the company's classification public when the headline appeared, or its first classification for headlines before that, so older history, and the history placed for a newly listed company, uses a membership that became known later. Default false reads exactly the headlines that name the industry.
1002
1002
  * @param industry Canonical industry tag whose news to read, as IsIndustry lists it. Legacy aliases are separate news series and are rejected, never mapped.
1003
1003
  * @param measure Median: middle score from -1 to 1 (the average of the two middle scores for an even count), with no value when no qualifying headline. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying headline. NetCount: positive minus negative headlines. ArticleCount: qualifying headlines. Every measure has no value across missing snapshots or when the due snapshot is unpublished. Before coverage begins on 2019-09-23 the window holds the sessions available.
1004
1004
  * @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest and about 20 is the usual window. The same value for every asset.
1005
+ * @param includeMemberCompanies Also count headlines about the industry's member companies, each headline once per industry. Default false reads only headlines that name the industry.
1005
1006
  */
1006
- export function IndustryNewsSentiment(industry, measure = "Mean", lookbackDays = 1) {
1007
+ export function IndustryNewsSentiment(industry, measure = "Mean", lookbackDays = 1, includeMemberCompanies = false) {
1007
1008
  const d = { type: "IndustryNewsSentiment" };
1008
1009
  d["industry"] = industry;
1009
1010
  d["measure"] = measure;
1010
1011
  d["lookbackDays"] = lookbackDays;
1012
+ d["includeMemberCompanies"] = includeMemberCompanies;
1011
1013
  return d;
1012
1014
  }
1013
1015
  /**
@@ -110,6 +110,8 @@ export declare class PortfolioHandle implements Portfolio {
110
110
  endDate: string;
111
111
  idempotencyKey: string;
112
112
  baseline?: string;
113
+ /** Typed benchmark `{ type, symbol, name? }`; never with `baseline`. */
114
+ baselineAsset?: JsonObject;
113
115
  interval?: string;
114
116
  initialValue?: number;
115
117
  generateEvents?: boolean;
@@ -340,6 +340,9 @@ export class PortfolioHandle {
340
340
  };
341
341
  if (options.baseline !== undefined)
342
342
  input.baseline = options.baseline;
343
+ if (options.baselineAsset !== undefined) {
344
+ input.baselineAsset = options.baselineAsset;
345
+ }
343
346
  if (options.interval !== undefined)
344
347
  input.interval = options.interval;
345
348
  if (options.initialValue !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexustrade",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "Typed TypeScript SDK for NexusTrade portfolio authoring, backtesting, optimization, and natural-language stock screening",
5
5
  "license": "MIT",
6
6
  "author": "Starks Technology",