@piaa/sdk 1.0.2 → 1.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
@@ -8,12 +8,13 @@ Designed for institutional algorithmic traders, fintech dashboards, and quantita
8
8
 
9
9
  ## Features
10
10
 
11
- - **Zero-Fuss Sensible Defaults**: Connect in 3 lines of code with pre-configured endpoints and sensible timeout/retry defaults.
12
- - 🔁 **Enterprise Resiliency**: Automatic exponential backoff with full jitter for transient 5xx/429 network hiccups and retry-after headers.
13
- - 🛡️ **Typed Error Hierarchy**: Clear, actionable, strongly-typed errors (`AuthenticationError`, `RateLimitError`, `TimeoutError`, `ValidationError`, `NetworkError`).
14
- - 🔒 **Zero Sensitive Data Leaks**: Automatic redaction of API keys, bearer tokens, and secrets from error logs and stack traces.
15
- - 📡 **Cross-Platform Realtime Streaming**: Built-in resilient WebSocket client with **In-Band Message Authentication**, ping/pong keep-alives, and automatic re-subscription on reconnect.
16
- - 📊 **Rate Limit Telemetry**: Real-time inspection of RFC 6585 and daily quota headers (`X-RateLimit-*`, `X-DailyQuota-*`).
11
+ - **Zero-Fuss Sensible Defaults**: Connect in 3 lines of code with pre-configured endpoints and sensible timeout/retry defaults.
12
+ - **Dual Proxy-Resilient Auth**: Transparently sends both standard `Authorization: Bearer <key>` and `x-api-key` headers to guarantee 100% compatibility across Cloudflare tunnels, WAFs, and internal gateways.
13
+ - **Typed Error Hierarchy**: Clear, actionable, strongly-typed errors (`AuthenticationError`, `RateLimitError`, `TimeoutError`, `ValidationError`, `NetworkError`).
14
+ - **Derivatives & Macro Intelligence**: Real-time Options Chain, Gamma Exposure (GEX), Fear & Greed Index, and CFTC Commitment of Traders (COT) positioning.
15
+ - **Zero Sensitive Data Leaks**: Automatic redaction of API keys, bearer tokens, and secrets from error logs and stack traces.
16
+ - **Cross-Platform Realtime Streaming**: Built-in resilient WebSocket client with **In-Band Message Authentication**, ping/pong keep-alives, and automatic re-subscription on reconnect.
17
+ - **Rate Limit Telemetry**: Real-time inspection of RFC 6585 and daily quota headers (`X-RateLimit-*`, `X-DailyQuota-*`).
17
18
 
18
19
  ---
19
20
 
@@ -41,7 +42,7 @@ import { PiaClient, RateLimitError, AuthenticationError } from "@piaa/sdk";
41
42
 
42
43
  // Automatically picks up process.env.PIA_API_KEY if omitted
43
44
  const client = new PiaClient({
44
- apiKey: "wi_live_your_api_key",
45
+ apiKey: "wi_live_...",
45
46
  });
46
47
 
47
48
  async function run() {
@@ -60,7 +61,22 @@ async function run() {
60
61
  });
61
62
  console.log(`Fetched ${candles.count} bars for ${candles.symbol}`);
62
63
 
63
- // 3. Inspect rate limit telemetry
64
+ // 3. Options Chain & Gamma Exposure (GEX)
65
+ const gex = await client.options.getGex("SPX");
66
+ console.log(`SPX Net GEX: $${gex.net_gex?.toLocaleString()} (0-Gamma: ${gex.zero_gamma_level})`);
67
+
68
+ // 4. Macro Sentiment & Positioning (Fear & Greed, COT)
69
+ const fg = await client.macro.getFearGreed();
70
+ console.log(`Fear & Greed Index: ${fg.score} (${fg.rating})`);
71
+
72
+ const cot = await client.macro.getCot("GOLD");
73
+ console.log(`Gold Commercial Net: ${cot.reports[0]?.net_position}`);
74
+
75
+ // 5. Social Discussions & Breaking News
76
+ const posts = await client.social.getPosts({ limit: 10, symbol: "BTC" });
77
+ console.log(`Latest post by @${posts.items[0]?.author_username}: "${posts.items[0]?.text}"`);
78
+
79
+ // 6. Inspect rate limit telemetry
64
80
  const quota = client.getRateLimitInfo();
65
81
  console.log(`Remaining daily hits: ${quota.dailyRemaining}/${quota.dailyLimit}`);
66
82
  } catch (err) {
@@ -81,7 +97,7 @@ run();
81
97
 
82
98
  ### 2. Realtime WebSocket Streaming (In-Band Message Auth)
83
99
 
84
- Cross-platform streaming without query-string leakage:
100
+ Cross-platform streaming without query-string token leakage:
85
101
 
86
102
  ```typescript
87
103
  import { PiaClient } from "@piaa/sdk";
@@ -120,6 +136,22 @@ client.realtime.connect();
120
136
 
121
137
  ---
122
138
 
139
+ ## Complete Resource Reference
140
+
141
+ | Resource | Methods | Endpoint | Description |
142
+ |---|---|---|---|
143
+ | `client.market` | `getPrices()`, `getCandles()`, `getOrderBook()` | `/api/v1/market/*` | Live price snapshot, ClickHouse OHLCV candles, and Level 2 DOM. |
144
+ | `client.options` | `getChain()`, `getGex()`, `getSummary()` | `/api/v1/options/*` | Full options chain, Gamma Exposure levels, and put/call sentiment. |
145
+ | `client.macro` | `getFearGreed()`, `getCot()`, `getCentralBankStance()` | `/api/v1/fear-greed`, `/api/v1/cot/*`, `/api/v1/central-banks/*` | Fear & Greed sentiment index, CFTC institutional COT reports, and central bank monetary policy stance. |
146
+ | `client.social` | `getPosts()`, `getFeed()` | `/api/v1/social/*` | Real-time social sentiment and discussion feeds from Twitter/𝕏. |
147
+ | `client.news` | `getNews()` | `/api/v1/news` | Curated multi-asset financial news headlines and articles. |
148
+ | `client.economic` | `getCalendar()` | `/api/v1/economic/calendar` | Global economic calendar events, CPI releases, and rate decisions. |
149
+ | `client.fixedIncome` | `getYieldCurve()` | `/api/v1/rates/yield-curve` | Benchmark sovereign bond yield curves across tenors. |
150
+ | `client.ws` | `createTicket()` | `/api/v1/ws/ticket` | Ephemeral single-use WebSocket connection tickets. |
151
+ | `client.realtime` | `connect()`, `subscribe()`, `unsubscribe()`, `disconnect()` | `/api/v1/ws` | Low-latency streaming socket client with event emitters. |
152
+
153
+ ---
154
+
123
155
  ## Configuration Reference
124
156
 
125
157
  ```typescript
package/dist/client.d.ts CHANGED
@@ -6,6 +6,10 @@ import { RealtimeClient } from "./realtime/socket";
6
6
  import { MarketResource } from "./resources/market";
7
7
  import { NewsResource } from "./resources/news";
8
8
  import { SocialResource } from "./resources/social";
9
+ import { EconomicResource } from "./resources/economic";
10
+ import { FixedIncomeResource } from "./resources/fixed-income";
11
+ import { MacroResource } from "./resources/macro";
12
+ import { OptionsResource } from "./resources/options";
9
13
  import { WsResource } from "./resources/ws";
10
14
  import type { RateLimitInfo } from "./types";
11
15
  export declare class PiaClient {
@@ -15,6 +19,14 @@ export declare class PiaClient {
15
19
  * Market data & prices API resource.
16
20
  */
17
21
  readonly market: MarketResource;
22
+ /**
23
+ * Derivatives, options chain, and Gamma Exposure (GEX) resource.
24
+ */
25
+ readonly options: OptionsResource;
26
+ /**
27
+ * Macro indicators, Fear & Greed index, COT positioning, and central banks.
28
+ */
29
+ readonly macro: MacroResource;
18
30
  /**
19
31
  * Social sentiment and discussions resource.
20
32
  */
@@ -23,6 +35,14 @@ export declare class PiaClient {
23
35
  * Financial news resource.
24
36
  */
25
37
  readonly news: NewsResource;
38
+ /**
39
+ * Macroeconomic calendar and indicators resource.
40
+ */
41
+ readonly economic: EconomicResource;
42
+ /**
43
+ * Sovereign bond yields and fixed income rates resource.
44
+ */
45
+ readonly fixedIncome: FixedIncomeResource;
26
46
  /**
27
47
  * WebSocket ticket issuance resource.
28
48
  */
package/dist/index.d.ts CHANGED
@@ -6,6 +6,14 @@ export { PiaClient } from "./client";
6
6
  export { type PiaClientOptions, type ResolvedPiaConfig, resolveConfig, DEFAULT_BASE_URL, DEFAULT_WS_URL, DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, } from "./config";
7
7
  export { PiaError, type PiaErrorDetails, ConfigurationError, ValidationError, AuthenticationError, PermissionError, RateLimitError, TimeoutError, NetworkError, ParseError, ApiError, } from "./errors";
8
8
  export { type PiaLogger, type LogLevel, DefaultLogger, redactSensitive, } from "./logger";
9
- export { type Timeframe, type RateLimitInfo, type RequestOptions, type MarketPrice, type MarketPricesResponse, type Candle, type CandleResponse, type GetCandlesOptions, type OrderBook, type OrderBookLevel, type SocialPost, type SocialFeedResponse, type GetSocialOptions, type NewsArticle, type NewsFeedResponse, type GetNewsOptions, type WsTicketResponse, } from "./types";
9
+ export { type Timeframe, type RateLimitInfo, type RequestOptions, type MarketPrice, type MarketPricesResponse, type Candle, type CandleResponse, type GetCandlesOptions, type OrderBook, type OrderBookLevel, type SocialPost, type SocialFeedResponse, type GetSocialOptions, type SocialPostItem, type SocialPostsResponse, type GetSocialPostsOptions, type OptionContract, type OptionChainResponse, type OptionGexResponse, type OptionSummaryResponse, type FearGreedData, type FearGreedHistoryResponse, type CotPositioning, type CotReportResponse, type CentralBankStanceResponse, type NewsArticle, type NewsFeedResponse, type GetNewsOptions, type EconomicEvent, type EconomicCalendarResponse, type GetCalendarOptions, type YieldCurvePoint, type YieldCurveResponse, type MarketInsight, type WsTicketResponse, } from "./types";
10
+ export { MarketResource } from "./resources/market";
11
+ export { OptionsResource } from "./resources/options";
12
+ export { MacroResource } from "./resources/macro";
13
+ export { SocialResource } from "./resources/social";
14
+ export { NewsResource } from "./resources/news";
15
+ export { EconomicResource } from "./resources/economic";
16
+ export { FixedIncomeResource } from "./resources/fixed-income";
17
+ export { WsResource } from "./resources/ws";
10
18
  export { RealtimeClient, type SocketState } from "./realtime/socket";
11
19
  export { type RealtimeEvents } from "./realtime/events";
package/dist/index.js CHANGED
@@ -253,7 +253,7 @@ function resolveConfig(options = {}) {
253
253
 
254
254
  // src/http/transport.ts
255
255
  var RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504]);
256
- var SDK_VERSION = "1.0.2";
256
+ var SDK_VERSION = "1.2.0";
257
257
 
258
258
  class HttpTransport {
259
259
  config;
@@ -290,6 +290,7 @@ class HttpTransport {
290
290
  }
291
291
  try {
292
292
  const headers = {
293
+ Authorization: `Bearer ${this.config.apiKey}`,
293
294
  "x-api-key": this.config.apiKey,
294
295
  Accept: "application/json",
295
296
  "User-Agent": `pia-sdk-ts/${SDK_VERSION}`,
@@ -731,6 +732,16 @@ class MarketResource {
731
732
  const cleanSymbol = symbol.trim().toUpperCase();
732
733
  return this.transport.request(`/api/v1/market/orderbook/${encodeURIComponent(cleanSymbol)}`, "GET", undefined, options);
733
734
  }
735
+ async getInsights(symbol, options) {
736
+ if (!symbol || typeof symbol !== "string" || symbol.trim() === "") {
737
+ throw new ValidationError("Symbol must be a non-empty string.", "symbol");
738
+ }
739
+ const cleanSymbol = symbol.trim().toUpperCase();
740
+ return this.transport.request(`/api/v1/market/insights/${encodeURIComponent(cleanSymbol)}`, "GET", undefined, options);
741
+ }
742
+ async getWhy(symbol, options) {
743
+ return this.getInsights(symbol, options);
744
+ }
734
745
  }
735
746
 
736
747
  // src/resources/news.ts
@@ -744,11 +755,19 @@ class NewsResource {
744
755
  if (options?.symbols && options.symbols.length > 0) {
745
756
  params.set("symbols", options.symbols.map((s) => s.trim().toUpperCase()).join(","));
746
757
  }
758
+ if (options?.category)
759
+ params.set("category", options.category);
747
760
  if (options?.limit)
748
761
  params.set("limit", String(options.limit));
749
762
  const query = params.toString() ? `?${params.toString()}` : "";
750
763
  return this.transport.request(`/api/v1/news${query}`, "GET", undefined, options);
751
764
  }
765
+ async getLatest(options) {
766
+ return this.transport.request("/api/v1/news/latest", "GET", undefined, options);
767
+ }
768
+ async getById(id, options) {
769
+ return this.transport.request(`/api/v1/news/${encodeURIComponent(id)}`, "GET", undefined, options);
770
+ }
752
771
  }
753
772
 
754
773
  // src/resources/social.ts
@@ -768,6 +787,104 @@ class SocialResource {
768
787
  const query = params.toString() ? `?${params.toString()}` : "";
769
788
  return this.transport.request(`/api/v1/social/posts${query}`, "GET", undefined, options);
770
789
  }
790
+ async getFeed(options) {
791
+ const params = new URLSearchParams;
792
+ if (options?.symbol)
793
+ params.set("symbol", options.symbol.trim().toUpperCase());
794
+ if (options?.limit)
795
+ params.set("limit", String(options.limit));
796
+ if (options?.cursor)
797
+ params.set("cursor", options.cursor);
798
+ const query = params.toString() ? `?${params.toString()}` : "";
799
+ return this.transport.request(`/api/v1/social/feed${query}`, "GET", undefined, options);
800
+ }
801
+ }
802
+
803
+ // src/resources/economic.ts
804
+ class EconomicResource {
805
+ transport;
806
+ constructor(transport) {
807
+ this.transport = transport;
808
+ }
809
+ async getCalendar(options) {
810
+ const params = new URLSearchParams;
811
+ if (options?.impact)
812
+ params.set("impact", options.impact);
813
+ if (options?.limit)
814
+ params.set("limit", String(options.limit));
815
+ const query = params.toString() ? `?${params.toString()}` : "";
816
+ return this.transport.request(`/api/v1/economic/calendar${query}`, "GET", undefined, options);
817
+ }
818
+ async getIndicators(options) {
819
+ return this.transport.request("/api/v1/economic/indicators", "GET", undefined, options);
820
+ }
821
+ }
822
+
823
+ // src/resources/fixed-income.ts
824
+ class FixedIncomeResource {
825
+ transport;
826
+ constructor(transport) {
827
+ this.transport = transport;
828
+ }
829
+ async getYieldCurve(options) {
830
+ return this.transport.request("/api/v1/fixed-income/yield-curve", "GET", undefined, options);
831
+ }
832
+ async getSpreads(options) {
833
+ return this.transport.request("/api/v1/fixed-income/spreads", "GET", undefined, options);
834
+ }
835
+ }
836
+
837
+ // src/resources/macro.ts
838
+ class MacroResource {
839
+ transport;
840
+ constructor(transport) {
841
+ this.transport = transport;
842
+ }
843
+ async getFearGreed(options) {
844
+ return this.transport.request("/api/v1/fear-greed", "GET", undefined, options);
845
+ }
846
+ async getFearGreedHistory(options) {
847
+ return this.transport.request("/api/v1/fear-greed/history", "GET", undefined, options);
848
+ }
849
+ async getCot(symbol, options) {
850
+ if (!symbol || typeof symbol !== "string" || symbol.trim() === "") {
851
+ throw new ValidationError("Symbol must be a non-empty string.", "symbol");
852
+ }
853
+ const clean = symbol.trim().toUpperCase();
854
+ return this.transport.request(`/api/v1/cot/symbol/${encodeURIComponent(clean)}`, "GET", undefined, options);
855
+ }
856
+ async getCentralBankStance(bank, options) {
857
+ if (!bank || typeof bank !== "string" || bank.trim() === "") {
858
+ throw new ValidationError("Bank must be a non-empty string.", "bank");
859
+ }
860
+ const clean = bank.trim().toLowerCase();
861
+ return this.transport.request(`/api/v1/central-banks/${encodeURIComponent(clean)}/stance`, "GET", undefined, options);
862
+ }
863
+ }
864
+
865
+ // src/resources/options.ts
866
+ class OptionsResource {
867
+ transport;
868
+ constructor(transport) {
869
+ this.transport = transport;
870
+ }
871
+ async getChain(symbol, options) {
872
+ if (!symbol || typeof symbol !== "string" || symbol.trim() === "") {
873
+ throw new ValidationError("Symbol must be a non-empty string.", "symbol");
874
+ }
875
+ const clean = symbol.trim().toUpperCase();
876
+ return this.transport.request(`/api/v1/options/chain/${encodeURIComponent(clean)}`, "GET", undefined, options);
877
+ }
878
+ async getGex(symbol, options) {
879
+ if (!symbol || typeof symbol !== "string" || symbol.trim() === "") {
880
+ throw new ValidationError("Symbol must be a non-empty string.", "symbol");
881
+ }
882
+ const clean = symbol.trim().toUpperCase();
883
+ return this.transport.request(`/api/v1/options/gex/${encodeURIComponent(clean)}`, "GET", undefined, options);
884
+ }
885
+ async getSummary(options) {
886
+ return this.transport.request("/api/v1/options/summary", "GET", undefined, options);
887
+ }
771
888
  }
772
889
 
773
890
  // src/resources/ws.ts
@@ -786,16 +903,24 @@ class PiaClient {
786
903
  config;
787
904
  transport;
788
905
  market;
906
+ options;
907
+ macro;
789
908
  social;
790
909
  news;
910
+ economic;
911
+ fixedIncome;
791
912
  ws;
792
913
  realtime;
793
- constructor(options = {}) {
794
- this.config = Object.freeze(resolveConfig(options));
914
+ constructor(options) {
915
+ this.config = resolveConfig(options);
795
916
  this.transport = new HttpTransport(this.config);
796
917
  this.market = new MarketResource(this.transport);
918
+ this.options = new OptionsResource(this.transport);
919
+ this.macro = new MacroResource(this.transport);
797
920
  this.social = new SocialResource(this.transport);
798
921
  this.news = new NewsResource(this.transport);
922
+ this.economic = new EconomicResource(this.transport);
923
+ this.fixedIncome = new FixedIncomeResource(this.transport);
799
924
  this.ws = new WsResource(this.transport);
800
925
  this.realtime = new RealtimeClient(this.config);
801
926
  }
@@ -812,15 +937,23 @@ export {
812
937
  DEFAULT_TIMEOUT_MS,
813
938
  DEFAULT_WS_URL,
814
939
  DefaultLogger,
940
+ EconomicResource,
941
+ FixedIncomeResource,
942
+ MacroResource,
943
+ MarketResource,
815
944
  NetworkError,
945
+ NewsResource,
946
+ OptionsResource,
816
947
  ParseError,
817
948
  PermissionError,
818
949
  PiaClient,
819
950
  PiaError,
820
951
  RateLimitError,
821
952
  RealtimeClient,
953
+ SocialResource,
822
954
  TimeoutError,
823
955
  ValidationError,
956
+ WsResource,
824
957
  redactSensitive,
825
958
  resolveConfig
826
959
  };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Official PIA SDK - Economic Intelligence API Resource
3
+ */
4
+ import type { HttpTransport } from "../http/transport";
5
+ import type { EconomicCalendarResponse, GetCalendarOptions, RequestOptions } from "../types";
6
+ export declare class EconomicResource {
7
+ private readonly transport;
8
+ constructor(transport: HttpTransport);
9
+ /**
10
+ * Fetches global macroeconomic calendar events (NFP, CPI, interest rates, GDP).
11
+ */
12
+ getCalendar(options?: GetCalendarOptions): Promise<EconomicCalendarResponse>;
13
+ /**
14
+ * Retrieves macroeconomic indicators and series metadata.
15
+ */
16
+ getIndicators(options?: RequestOptions): Promise<any>;
17
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Official PIA SDK - Fixed Income & Sovereign Rates API Resource
3
+ */
4
+ import type { HttpTransport } from "../http/transport";
5
+ import type { RequestOptions, YieldCurveResponse } from "../types";
6
+ export declare class FixedIncomeResource {
7
+ private readonly transport;
8
+ constructor(transport: HttpTransport);
9
+ /**
10
+ * Retrieves US Treasury sovereign bond yield curve structure across all standard tenors.
11
+ */
12
+ getYieldCurve(options?: RequestOptions): Promise<YieldCurveResponse>;
13
+ /**
14
+ * Retrieves sovereign yield spreads (2Y-10Y, 3M-10Y curve steepness indicators).
15
+ */
16
+ getSpreads(options?: RequestOptions): Promise<any>;
17
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Official PIA SDK - Macro & Market Sentiment Resource
3
+ */
4
+ import type { HttpTransport } from "../http/transport";
5
+ import type { CentralBankStanceResponse, CotReportResponse, FearGreedData, FearGreedHistoryResponse, RequestOptions } from "../types";
6
+ export declare class MacroResource {
7
+ private readonly transport;
8
+ constructor(transport: HttpTransport);
9
+ /**
10
+ * Retrieves the current Fear & Greed Index score and sentiment rating.
11
+ */
12
+ getFearGreed(options?: RequestOptions): Promise<FearGreedData>;
13
+ /**
14
+ * Retrieves historical Fear & Greed Index time series.
15
+ */
16
+ getFearGreedHistory(options?: RequestOptions): Promise<FearGreedHistoryResponse>;
17
+ /**
18
+ * Fetches CFTC Commitment of Traders (COT) institutional positioning report for a symbol.
19
+ *
20
+ * @param symbol Commodity/Currency/Index symbol (e.g. "GOLD", "WTI", "EURUSD", "SPX")
21
+ */
22
+ getCot(symbol: string, options?: RequestOptions): Promise<CotReportResponse>;
23
+ /**
24
+ * Fetches monetary policy stance and interest rate assessment for a central bank.
25
+ *
26
+ * @param bank Bank code (e.g. "fed", "ecb", "boj", "bi", "boe")
27
+ */
28
+ getCentralBankStance(bank: string, options?: RequestOptions): Promise<CentralBankStanceResponse>;
29
+ }
@@ -21,4 +21,12 @@ export declare class MarketResource {
21
21
  * Retrieves Level 2 DOM (Depth of Market) order book for a symbol.
22
22
  */
23
23
  getOrderBook(symbol: string, options?: RequestOptions): Promise<OrderBook>;
24
+ /**
25
+ * Retrieves AI/Quant market insights and price movement narrative for a given instrument.
26
+ */
27
+ getInsights(symbol: string, options?: RequestOptions): Promise<any>;
28
+ /**
29
+ * @deprecated Use `getInsights(symbol)` instead.
30
+ */
31
+ getWhy(symbol: string, options?: RequestOptions): Promise<any>;
24
32
  }
@@ -2,7 +2,7 @@
2
2
  * Official PIA SDK - News Intelligence API Resource
3
3
  */
4
4
  import type { HttpTransport } from "../http/transport";
5
- import type { GetNewsOptions, NewsFeedResponse } from "../types";
5
+ import type { GetNewsOptions, NewsFeedResponse, RequestOptions } from "../types";
6
6
  export declare class NewsResource {
7
7
  private readonly transport;
8
8
  constructor(transport: HttpTransport);
@@ -10,4 +10,12 @@ export declare class NewsResource {
10
10
  * Fetches curated financial and macro news articles.
11
11
  */
12
12
  getNews(options?: GetNewsOptions): Promise<NewsFeedResponse>;
13
+ /**
14
+ * Fetches the latest breaking financial news bulletin.
15
+ */
16
+ getLatest(options?: RequestOptions): Promise<any>;
17
+ /**
18
+ * Fetches detailed intelligence for a specific news article ID.
19
+ */
20
+ getById(id: string, options?: RequestOptions): Promise<any>;
13
21
  }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Official PIA SDK - Derivatives & Options Analytics Resource
3
+ */
4
+ import type { HttpTransport } from "../http/transport";
5
+ import type { OptionChainResponse, OptionGexResponse, OptionSummaryResponse, RequestOptions } from "../types";
6
+ export declare class OptionsResource {
7
+ private readonly transport;
8
+ constructor(transport: HttpTransport);
9
+ /**
10
+ * Fetches the real-time option chain for an underlying asset symbol.
11
+ *
12
+ * @param symbol Underlier ticker (e.g. "AAPL", "NVDA", "SPX")
13
+ */
14
+ getChain(symbol: string, options?: RequestOptions): Promise<OptionChainResponse>;
15
+ /**
16
+ * Fetches Gamma Exposure (GEX) profile and key zero-gamma levels.
17
+ *
18
+ * @param symbol Underlier ticker (e.g. "SPX", "NVDA", "QQQ")
19
+ */
20
+ getGex(symbol: string, options?: RequestOptions): Promise<OptionGexResponse>;
21
+ /**
22
+ * Retrieves overall options market activity and put/call sentiment summary.
23
+ */
24
+ getSummary(options?: RequestOptions): Promise<OptionSummaryResponse>;
25
+ }
@@ -2,12 +2,18 @@
2
2
  * Official PIA SDK - Social Intelligence API Resource
3
3
  */
4
4
  import type { HttpTransport } from "../http/transport";
5
- import type { GetSocialOptions, SocialFeedResponse } from "../types";
5
+ import type { GetSocialOptions, GetSocialPostsOptions, SocialFeedResponse, SocialPostsResponse } from "../types";
6
6
  export declare class SocialResource {
7
7
  private readonly transport;
8
8
  constructor(transport: HttpTransport);
9
9
  /**
10
- * Fetches the latest social sentiment posts and discussions.
10
+ * Fetches the latest social sentiment posts from PostgreSQL / RSSHub ingestion pipeline.
11
+ *
12
+ * @param options Pagination limit, cursor, and optional symbol filter.
11
13
  */
12
- getPosts(options?: GetSocialOptions): Promise<SocialFeedResponse>;
14
+ getPosts(options?: GetSocialPostsOptions): Promise<SocialPostsResponse>;
15
+ /**
16
+ * Fetches the real-time social discussion feed.
17
+ */
18
+ getFeed(options?: GetSocialOptions): Promise<SocialFeedResponse>;
13
19
  }
package/dist/types.d.ts CHANGED
@@ -98,10 +98,156 @@ export interface NewsFeedResponse {
98
98
  }
99
99
  export interface GetNewsOptions extends RequestOptions {
100
100
  symbols?: string[];
101
+ category?: "forex" | "stock" | "all" | string;
101
102
  limit?: number;
102
103
  }
104
+ export interface EconomicEvent {
105
+ id?: string;
106
+ event: string;
107
+ country: string;
108
+ currency?: string;
109
+ date: string;
110
+ time?: string;
111
+ actual?: number | null;
112
+ forecast?: number | null;
113
+ previous?: number | null;
114
+ impact?: "high" | "medium" | "low" | string;
115
+ }
116
+ export interface EconomicCalendarResponse {
117
+ total: number;
118
+ items: EconomicEvent[];
119
+ }
120
+ export interface GetCalendarOptions extends RequestOptions {
121
+ impact?: string;
122
+ limit?: number;
123
+ }
124
+ export interface YieldCurvePoint {
125
+ tenor: string;
126
+ yield: number;
127
+ date?: string;
128
+ }
129
+ export interface YieldCurveResponse {
130
+ date: string;
131
+ points: YieldCurvePoint[];
132
+ }
133
+ export interface MarketInsight {
134
+ symbol: string;
135
+ title: string;
136
+ summary: string;
137
+ sentiment?: string;
138
+ confidence?: number;
139
+ }
103
140
  export interface WsTicketResponse {
104
141
  ticket: string;
105
142
  expires_in?: number;
106
143
  ws_url?: string;
107
144
  }
145
+ export interface SocialPostItem {
146
+ author_username: string;
147
+ author_display_name?: string;
148
+ text: string;
149
+ url: string;
150
+ created_at: string;
151
+ platform: string;
152
+ like_count?: number;
153
+ retweet_count?: number;
154
+ media_urls?: string[];
155
+ source_account?: string;
156
+ }
157
+ export interface SocialPostsResponse {
158
+ has_more: boolean;
159
+ items: SocialPostItem[];
160
+ next_before?: string | null;
161
+ }
162
+ export interface GetSocialPostsOptions extends RequestOptions {
163
+ limit?: number;
164
+ cursor?: string;
165
+ symbol?: string;
166
+ }
167
+ export interface OptionContract {
168
+ symbol: string;
169
+ strike: number;
170
+ expiration: string;
171
+ option_type: "call" | "put" | string;
172
+ bid?: number;
173
+ ask?: number;
174
+ last?: number;
175
+ volume?: number;
176
+ open_interest?: number;
177
+ implied_volatility?: number;
178
+ delta?: number;
179
+ gamma?: number;
180
+ theta?: number;
181
+ vega?: number;
182
+ }
183
+ export interface OptionChainResponse {
184
+ symbol: string;
185
+ underlying_price?: number;
186
+ expirations: string[];
187
+ contracts: OptionContract[];
188
+ }
189
+ export interface OptionGexResponse {
190
+ symbol: string;
191
+ net_gex?: number;
192
+ total_call_gex?: number;
193
+ total_put_gex?: number;
194
+ zero_gamma_level?: number;
195
+ major_positive_levels?: Array<{
196
+ strike: number;
197
+ gex: number;
198
+ }>;
199
+ major_negative_levels?: Array<{
200
+ strike: number;
201
+ gex: number;
202
+ }>;
203
+ updated_at?: string;
204
+ }
205
+ export interface OptionSummaryResponse {
206
+ total_volume?: number;
207
+ total_open_interest?: number;
208
+ put_call_ratio?: number;
209
+ most_active_symbols?: Array<{
210
+ symbol: string;
211
+ volume: number;
212
+ }>;
213
+ }
214
+ export interface FearGreedData {
215
+ score: number;
216
+ rating: string;
217
+ timestamp: string | number;
218
+ previous_close?: number;
219
+ previous_1_week?: number;
220
+ previous_1_month?: number;
221
+ previous_1_year?: number;
222
+ }
223
+ export interface FearGreedHistoryResponse {
224
+ current: FearGreedData;
225
+ history: Array<{
226
+ score: number;
227
+ rating: string;
228
+ timestamp: string | number;
229
+ }>;
230
+ }
231
+ export interface CotPositioning {
232
+ market_code: string;
233
+ market_name?: string;
234
+ report_date: string;
235
+ commercial_long?: number;
236
+ commercial_short?: number;
237
+ non_commercial_long?: number;
238
+ non_commercial_short?: number;
239
+ net_position?: number;
240
+ }
241
+ export interface CotReportResponse {
242
+ symbol?: string;
243
+ market_code?: string;
244
+ reports: CotPositioning[];
245
+ }
246
+ export interface CentralBankStanceResponse {
247
+ bank: string;
248
+ name?: string;
249
+ stance: "hawkish" | "dovish" | "neutral" | string;
250
+ rate?: number;
251
+ last_updated?: string;
252
+ summary?: string;
253
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piaa/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Official TypeScript/JavaScript SDK for PIA Market Intelligence Platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",