@fullstackcraftllc/floe 0.0.4 → 0.0.6

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.
@@ -107,7 +107,7 @@ type TradierEventListener<T> = (data: T) => void;
107
107
  */
108
108
  export declare class TradierClient {
109
109
  /** Tradier API authentication token */
110
- private authKey;
110
+ private authToken;
111
111
  /** Current streaming session */
112
112
  private streamSession;
113
113
  /** WebSocket connection */
@@ -147,12 +147,18 @@ export declare class TradierClient {
147
147
  private readonly apiBaseUrl;
148
148
  /** Tradier WebSocket URL */
149
149
  private readonly wsUrl;
150
+ /** Whether to log verbose debug information */
151
+ private readonly verbose;
150
152
  /**
151
153
  * Creates a new TradierClient instance.
152
154
  *
153
- * @param authKey - Tradier API access token
155
+ * @param authToken - Tradier API auth token
156
+ * @param options - Optional configuration options
157
+ * @param options.verbose - Whether to log verbose debug information (default: false)
154
158
  */
155
- constructor(authKey: string);
159
+ constructor(authToken: string, options?: {
160
+ verbose?: boolean;
161
+ });
156
162
  /**
157
163
  * Establishes a streaming connection to Tradier.
158
164
  *
@@ -33,9 +33,11 @@ class TradierClient {
33
33
  /**
34
34
  * Creates a new TradierClient instance.
35
35
  *
36
- * @param authKey - Tradier API access token
36
+ * @param authToken - Tradier API auth token
37
+ * @param options - Optional configuration options
38
+ * @param options.verbose - Whether to log verbose debug information (default: false)
37
39
  */
38
- constructor(authKey) {
40
+ constructor(authToken, options) {
39
41
  /** Current streaming session */
40
42
  this.streamSession = null;
41
43
  /** WebSocket connection */
@@ -75,7 +77,8 @@ class TradierClient {
75
77
  this.apiBaseUrl = 'https://api.tradier.com/v1';
76
78
  /** Tradier WebSocket URL */
77
79
  this.wsUrl = 'wss://ws.tradier.com/v1/markets/events';
78
- this.authKey = authKey;
80
+ this.authToken = authToken;
81
+ this.verbose = options?.verbose ?? false;
79
82
  // Initialize event listener maps
80
83
  this.eventListeners.set('tickerUpdate', new Set());
81
84
  this.eventListeners.set('optionUpdate', new Set());
@@ -173,7 +176,7 @@ class TradierClient {
173
176
  const response = await fetch(url, {
174
177
  method: 'GET',
175
178
  headers: {
176
- 'Authorization': `Bearer ${this.authKey}`,
179
+ 'Authorization': `Bearer ${this.authToken}`,
177
180
  'Accept': 'application/json',
178
181
  },
179
182
  });
@@ -237,6 +240,9 @@ class TradierClient {
237
240
  if (symbols.has(item.symbol)) {
238
241
  // Store base open interest for live OI calculation (t=0 reference)
239
242
  this.baseOpenInterest.set(item.symbol, item.open_interest);
243
+ if (this.verbose) {
244
+ console.log(`[Tradier:OI] Base OI set for ${item.symbol}: ${item.open_interest}`);
245
+ }
240
246
  // Initialize cumulative OI change if not already set
241
247
  if (!this.cumulativeOIChange.has(item.symbol)) {
242
248
  this.cumulativeOIChange.set(item.symbol, 0);
@@ -348,7 +354,7 @@ class TradierClient {
348
354
  const response = await fetch(`${this.apiBaseUrl}/markets/events/session`, {
349
355
  method: 'POST',
350
356
  headers: {
351
- 'Authorization': `Bearer ${this.authKey}`,
357
+ 'Authorization': `Bearer ${this.authToken}`,
352
358
  'Accept': 'application/json',
353
359
  },
354
360
  });
@@ -373,6 +379,9 @@ class TradierClient {
373
379
  this.ws.onopen = () => {
374
380
  this.connected = true;
375
381
  this.reconnectAttempts = 0;
382
+ if (this.verbose) {
383
+ console.log('[Tradier:WS] Connected to streaming API');
384
+ }
376
385
  this.emit('connected', undefined);
377
386
  // Subscribe to any queued symbols
378
387
  if (this.subscribedSymbols.size > 0 && this.streamSession) {
@@ -411,6 +420,9 @@ class TradierClient {
411
420
  }
412
421
  this.reconnectAttempts++;
413
422
  const delay = this.baseReconnectDelay * Math.pow(2, this.reconnectAttempts - 1);
423
+ if (this.verbose) {
424
+ console.log(`[Tradier:WS] Reconnection attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts} in ${delay}ms`);
425
+ }
414
426
  await this.sleep(delay);
415
427
  try {
416
428
  await this.connect();
@@ -652,6 +664,11 @@ class TradierClient {
652
664
  // Update cumulative OI change
653
665
  const currentChange = this.cumulativeOIChange.get(occSymbol) ?? 0;
654
666
  this.cumulativeOIChange.set(occSymbol, currentChange + estimatedOIChange);
667
+ if (this.verbose && estimatedOIChange !== 0) {
668
+ const baseOI = this.baseOpenInterest.get(occSymbol) ?? 0;
669
+ const newLiveOI = Math.max(0, baseOI + currentChange + estimatedOIChange);
670
+ console.log(`[Tradier:OI] ${occSymbol} trade: price=${last.toFixed(2)}, size=${size}, aggressor=${aggressorSide}, OI change=${estimatedOIChange > 0 ? '+' : ''}${estimatedOIChange}, liveOI=${newLiveOI} (base=${baseOI}, cumulative=${currentChange + estimatedOIChange})`);
671
+ }
655
672
  // Record the trade for analysis
656
673
  const trade = {
657
674
  occSymbol,
package/dist/index.d.ts CHANGED
@@ -16,5 +16,7 @@ export { estimateImpliedProbabilityDistribution, estimateImpliedProbabilityDistr
16
16
  export type { StrikeProbability, ImpliedProbabilityDistribution, ImpliedPDFResult, } from './impliedpdf';
17
17
  export { FloeClient, Broker } from './client/FloeClient';
18
18
  export { TradierClient } from './client/brokers/TradierClient';
19
+ export { TastyTradeClient } from './client/brokers/TastyTradeClient';
20
+ export { TradeStationClient } from './client/brokers/TradeStationClient';
19
21
  export type { AggressorSide, IntradayTrade } from './client/brokers/TradierClient';
20
22
  export { genericAdapter, schwabAdapter, ibkrAdapter, tdaAdapter, brokerAdapters, getAdapter, createOptionChain, } from './adapters';
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.createOptionChain = exports.getAdapter = exports.brokerAdapters = exports.tdaAdapter = exports.ibkrAdapter = exports.schwabAdapter = exports.genericAdapter = exports.TradierClient = exports.Broker = exports.FloeClient = exports.getQuantile = exports.getCumulativeProbability = exports.getProbabilityInRange = exports.estimateImpliedProbabilityDistributions = exports.estimateImpliedProbabilityDistribution = exports.generateOCCSymbolsAroundSpot = exports.generateOCCSymbolsForStrikes = exports.generateStrikesAroundSpot = exports.parseOCCSymbol = exports.buildOCCSymbol = exports.normalPDF = exports.cumulativeNormalDistribution = exports.calculateSharesNeededToCover = exports.calculateGammaVannaCharmExposures = exports.smoothTotalVarianceSmile = exports.getIVForStrike = exports.getIVSurfaces = exports.getTimeToExpirationInYears = exports.getMillisecondsToExpiration = exports.calculateImpliedVolatility = exports.calculateGreeks = exports.blackScholes = void 0;
23
+ exports.createOptionChain = exports.getAdapter = exports.brokerAdapters = exports.tdaAdapter = exports.ibkrAdapter = exports.schwabAdapter = exports.genericAdapter = exports.TradeStationClient = exports.TastyTradeClient = exports.TradierClient = exports.Broker = exports.FloeClient = exports.getQuantile = exports.getCumulativeProbability = exports.getProbabilityInRange = exports.estimateImpliedProbabilityDistributions = exports.estimateImpliedProbabilityDistribution = exports.generateOCCSymbolsAroundSpot = exports.generateOCCSymbolsForStrikes = exports.generateStrikesAroundSpot = exports.parseOCCSymbol = exports.buildOCCSymbol = exports.normalPDF = exports.cumulativeNormalDistribution = exports.calculateSharesNeededToCover = exports.calculateGammaVannaCharmExposures = exports.smoothTotalVarianceSmile = exports.getIVForStrike = exports.getIVSurfaces = exports.getTimeToExpirationInYears = exports.getMillisecondsToExpiration = exports.calculateImpliedVolatility = exports.calculateGreeks = exports.blackScholes = void 0;
24
24
  // Core types
25
25
  __exportStar(require("./types"), exports);
26
26
  // Black-Scholes pricing and Greeks
@@ -65,6 +65,10 @@ Object.defineProperty(exports, "FloeClient", { enumerable: true, get: function (
65
65
  Object.defineProperty(exports, "Broker", { enumerable: true, get: function () { return FloeClient_1.Broker; } });
66
66
  var TradierClient_1 = require("./client/brokers/TradierClient");
67
67
  Object.defineProperty(exports, "TradierClient", { enumerable: true, get: function () { return TradierClient_1.TradierClient; } });
68
+ var TastyTradeClient_1 = require("./client/brokers/TastyTradeClient");
69
+ Object.defineProperty(exports, "TastyTradeClient", { enumerable: true, get: function () { return TastyTradeClient_1.TastyTradeClient; } });
70
+ var TradeStationClient_1 = require("./client/brokers/TradeStationClient");
71
+ Object.defineProperty(exports, "TradeStationClient", { enumerable: true, get: function () { return TradeStationClient_1.TradeStationClient; } });
68
72
  // Broker adapters
69
73
  var adapters_1 = require("./adapters");
70
74
  Object.defineProperty(exports, "genericAdapter", { enumerable: true, get: function () { return adapters_1.genericAdapter; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstackcraftllc/floe",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Production-ready options analytics toolkit. Normalize broker data structures and calculate Black-Scholes, Greeks, and exposures with a clean, type-safe API. Built for trading platforms and fintech applications.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "license": "SEE LICENSE IN LICENSE.md",
33
33
  "repository": {
34
34
  "type": "git",
35
- "url": "https://github.com/FullStackCraft/floe.git"
35
+ "url": "git+https://github.com/FullStackCraft/floe.git"
36
36
  },
37
37
  "bugs": {
38
38
  "url": "https://github.com/FullStackCraft/floe/issues"