@fullstackcraftllc/floe 0.0.4 → 0.0.5
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 +5 -4
- package/dist/client/FloeClient.d.ts +23 -2
- package/dist/client/FloeClient.js +114 -2
- package/dist/client/brokers/SchwabClient.d.ts +448 -0
- package/dist/client/brokers/SchwabClient.js +1052 -0
- package/dist/client/brokers/TastyTradeClient.d.ts +4 -0
- package/dist/client/brokers/TastyTradeClient.js +19 -0
- package/dist/client/brokers/TradeStationClient.d.ts +361 -0
- package/dist/client/brokers/TradeStationClient.js +880 -0
- package/dist/client/brokers/TradierClient.d.ts +7 -1
- package/dist/client/brokers/TradierClient.js +18 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/package.json +2 -2
|
@@ -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
155
|
* @param authKey - Tradier API access 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(authKey: string, options?: {
|
|
160
|
+
verbose?: boolean;
|
|
161
|
+
});
|
|
156
162
|
/**
|
|
157
163
|
* Establishes a streaming connection to Tradier.
|
|
158
164
|
*
|
|
@@ -34,8 +34,10 @@ class TradierClient {
|
|
|
34
34
|
* Creates a new TradierClient instance.
|
|
35
35
|
*
|
|
36
36
|
* @param authKey - Tradier API access 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(authKey, options) {
|
|
39
41
|
/** Current streaming session */
|
|
40
42
|
this.streamSession = null;
|
|
41
43
|
/** WebSocket connection */
|
|
@@ -76,6 +78,7 @@ class TradierClient {
|
|
|
76
78
|
/** Tradier WebSocket URL */
|
|
77
79
|
this.wsUrl = 'wss://ws.tradier.com/v1/markets/events';
|
|
78
80
|
this.authKey = authKey;
|
|
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());
|
|
@@ -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);
|
|
@@ -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.
|
|
3
|
+
"version": "0.0.5",
|
|
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"
|