nexustrade 1.55.0 → 1.59.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.
@@ -98,6 +98,7 @@ exports.Negative = Negative;
98
98
  exports.NewInsiderDisclosure = NewInsiderDisclosure;
99
99
  exports.NewInstitutionalFiling = NewInstitutionalFiling;
100
100
  exports.NewPoliticalDisclosure = NewPoliticalDisclosure;
101
+ exports.NewsSentiment = NewsSentiment;
101
102
  exports.NewTradingWeek = NewTradingWeek;
102
103
  exports.OnBalanceVolume = OnBalanceVolume;
103
104
  exports.OpeningPrice = OpeningPrice;
@@ -1608,6 +1609,19 @@ function NewPoliticalDisclosure(memberId, instrument, disclosureAction) {
1608
1609
  d["disclosureAction"] = disclosureAction;
1609
1610
  return d;
1610
1611
  }
1612
+ /**
1613
+ * Labelled news sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Each trading day has one snapshot at 09:15 New York, and a row is visible from its snapshot's time. The lake assigns each article to the first snapshot it could have been in: for history that is by publish time, and an article that live collection fetched or labelled after a snapshot's deadline is moved to the next session's snapshot. Backtests and live trading read the same rows by that time. lookbackDays counts trading sessions whether or not the asset had news in them. Only articles in which the asset is the subject or significantly affected count; passing mentions, law-firm solicitations and routine filings never do, 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 articles, ArticleCount is the number of qualifying articles. Every measure has no value when the window cannot be read in full: before coverage begins in May 2021, 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 article; the counts are then 0. Rows follow the security, so META reads Facebook-era FB articles.
1614
+ * @param asset Pass CANDIDATE in a dynamic rebalance pipeline.
1615
+ * @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative articles. ArticleCount: qualifying articles. Every measure has no value before May 2021 coverage, across missing snapshots, or when the due snapshot is unpublished.
1616
+ * @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest. A row is visible from the snapshot the lake assigned it, the same time in backtests and live trading.
1617
+ */
1618
+ function NewsSentiment(asset, measure = "Mean", lookbackDays = 1) {
1619
+ const d = { type: "NewsSentiment" };
1620
+ setAsset(d, "targetAsset", asset);
1621
+ d["measure"] = measure;
1622
+ d["lookbackDays"] = lookbackDays;
1623
+ return d;
1624
+ }
1611
1625
  /**
1612
1626
  * NewTradingWeek indicator.
1613
1627
  */
@@ -2208,6 +2222,7 @@ const backtest = (portfolio, config) => ({
2208
2222
  "start_date": config.startDate,
2209
2223
  "end_date": config.endDate,
2210
2224
  "baseline_symbol": config.baselineSymbol,
2225
+ "baseline_asset": config.baselineAsset,
2211
2226
  "interval": config.interval,
2212
2227
  "initial_value": config.initialValue,
2213
2228
  "generate_events": config.generateEvents,
@@ -1406,6 +1406,13 @@ export declare function NewInstitutionalFiling(manager: string): Indicator;
1406
1406
  * @param disclosureAction Which newly public trade sides trigger a decision.
1407
1407
  */
1408
1408
  export declare function NewPoliticalDisclosure(memberId: string, instrument: Instrument2, disclosureAction: "Any" | "Purchase" | "Sale"): Indicator;
1409
+ /**
1410
+ * Labelled news sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Each trading day has one snapshot at 09:15 New York, and a row is visible from its snapshot's time. The lake assigns each article to the first snapshot it could have been in: for history that is by publish time, and an article that live collection fetched or labelled after a snapshot's deadline is moved to the next session's snapshot. Backtests and live trading read the same rows by that time. lookbackDays counts trading sessions whether or not the asset had news in them. Only articles in which the asset is the subject or significantly affected count; passing mentions, law-firm solicitations and routine filings never do, 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 articles, ArticleCount is the number of qualifying articles. Every measure has no value when the window cannot be read in full: before coverage begins in May 2021, 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 article; the counts are then 0. Rows follow the security, so META reads Facebook-era FB articles.
1411
+ * @param asset Pass CANDIDATE in a dynamic rebalance pipeline.
1412
+ * @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative articles. ArticleCount: qualifying articles. Every measure has no value before May 2021 coverage, across missing snapshots, or when the due snapshot is unpublished.
1413
+ * @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest. A row is visible from the snapshot the lake assigned it, the same time in backtests and live trading.
1414
+ */
1415
+ export declare function NewsSentiment(asset: AssetArg, measure?: "Mean" | "Median" | "NetCount" | "ArticleCount", lookbackDays?: number): Indicator;
1409
1416
  /**
1410
1417
  * NewTradingWeek indicator.
1411
1418
  */
@@ -1780,8 +1787,10 @@ export interface BacktestConfig {
1780
1787
  startDate: string;
1781
1788
  /** Backtest end date (ISO format, e.g. 2024-12-31). Minute allows up to 730 days of minute data from start_date, counting minute-indicator warmup; never split a longer span into yearly Minute jobs. */
1782
1789
  endDate: string;
1783
- /** Benchmark for comparisonValue (buy-and-hold of this ticker). Defaults to SPY if omitted — use SPY only for broad equity/market strategies. For single-name options, set to that underlying (AAPL options → AAPL). For multi-name options books, run separate backtests with each material underlying as baseline (AAPL for AAPL sleeve, MSFT for MSFT), or equal-weight B&H of the traded universe — do not default to SPY. */
1790
+ /** Legacy Stock benchmark shorthand for comparisonValue. Use baseline_asset with explicit Cryptocurrency type for crypto pairs; never provide both fields. When both fields are omitted, the single traded stock/option underlying is inferred, otherwise SPY. For single-name options use that underlying; compare multi-name books against a deliberately chosen benchmark. */
1784
1791
  baselineSymbol?: string;
1792
+ /** Typed buy-and-hold benchmark for comparisonValue. Use {type:'Cryptocurrency',symbol:'BTC-USD',name:'BTC-USD'} for BTC or {type:'Stock',symbol:'SPY',name:'SPY'} for a stock/ETF. Symbol text never determines asset type. Omit baseline_symbol when using this field. */
1793
+ baselineAsset?: Record<string, unknown>;
1785
1794
  /** Time interval: Day or Minute (default Day). Minute is a daytrade tape. 730 days of minute data (selected range plus warmup) is the HARD CAP; 90 days is only the DEFAULT when you name no dates. Name the dates you actually want — certifying a candidate on a full year or two is a normal second backtest, not an escalation. */
1786
1795
  interval?: "Day" | "Minute";
1787
1796
  /** Starting portfolio value (default 10000) Range 1..inf. */
@@ -1388,6 +1388,19 @@ export function NewPoliticalDisclosure(memberId, instrument, disclosureAction) {
1388
1388
  d["disclosureAction"] = disclosureAction;
1389
1389
  return d;
1390
1390
  }
1391
+ /**
1392
+ * Labelled news sentiment about the asset over its last lookbackDays daily news snapshots (default 1, the latest). Each trading day has one snapshot at 09:15 New York, and a row is visible from its snapshot's time. The lake assigns each article to the first snapshot it could have been in: for history that is by publish time, and an article that live collection fetched or labelled after a snapshot's deadline is moved to the next session's snapshot. Backtests and live trading read the same rows by that time. lookbackDays counts trading sessions whether or not the asset had news in them. Only articles in which the asset is the subject or significantly affected count; passing mentions, law-firm solicitations and routine filings never do, 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 articles, ArticleCount is the number of qualifying articles. Every measure has no value when the window cannot be read in full: before coverage begins in May 2021, 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 article; the counts are then 0. Rows follow the security, so META reads Facebook-era FB articles.
1393
+ * @param asset Pass CANDIDATE in a dynamic rebalance pipeline.
1394
+ * @param measure Median: middle score from -1 to 1, with no value when no qualifying news. Mean: average sentiment from -1 to 1, with no value when the window has no qualifying news. NetCount: positive minus negative articles. ArticleCount: qualifying articles. Every measure has no value before May 2021 coverage, across missing snapshots, or when the due snapshot is unpublished.
1395
+ * @param lookbackDays Whole trading sessions of daily 09:15 New York news snapshots; 1 is the latest. A row is visible from the snapshot the lake assigned it, the same time in backtests and live trading.
1396
+ */
1397
+ export function NewsSentiment(asset, measure = "Mean", lookbackDays = 1) {
1398
+ const d = { type: "NewsSentiment" };
1399
+ setAsset(d, "targetAsset", asset);
1400
+ d["measure"] = measure;
1401
+ d["lookbackDays"] = lookbackDays;
1402
+ return d;
1403
+ }
1391
1404
  /**
1392
1405
  * NewTradingWeek indicator.
1393
1406
  */
@@ -1988,6 +2001,7 @@ export const backtest = (portfolio, config) => ({
1988
2001
  "start_date": config.startDate,
1989
2002
  "end_date": config.endDate,
1990
2003
  "baseline_symbol": config.baselineSymbol,
2004
+ "baseline_asset": config.baselineAsset,
1991
2005
  "interval": config.interval,
1992
2006
  "initial_value": config.initialValue,
1993
2007
  "generate_events": config.generateEvents,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexustrade",
3
- "version": "1.55.0",
3
+ "version": "1.59.1",
4
4
  "description": "Typed TypeScript SDK for NexusTrade portfolio authoring, backtesting, and optimization",
5
5
  "license": "MIT",
6
6
  "author": "Starks Technology",