@engineering-tf/shared 1.0.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.
@@ -0,0 +1,9 @@
1
+ import { ControlPanelOverviewData, TableFiltersProps } from "../types/shared";
2
+ export declare const CONTROL_PANEL_DATA_INITIAL_DATA: ControlPanelOverviewData;
3
+ export declare const INITIAL_WATCHLIST: string[];
4
+ export declare const getTableFilterDefaultValue: () => TableFiltersProps;
5
+ export declare const TABLEFILTER_DEFAULT_VALUE: TableFiltersProps;
6
+ /**
7
+ * when the symbol value is null in the tableFilter, we set it as SPY when we need one as placeholder
8
+ */
9
+ export declare const DEFAULT_SYMBOL = "SPY";
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SYMBOL = exports.TABLEFILTER_DEFAULT_VALUE = exports.getTableFilterDefaultValue = exports.INITIAL_WATCHLIST = exports.CONTROL_PANEL_DATA_INITIAL_DATA = void 0;
4
+ var shared_1 = require("../types/shared");
5
+ var date_functions_1 = require("../utils/common/date-functions");
6
+ var uuid_1 = require("uuid");
7
+ var DEFAULT_PAGE_SIZE = 100;
8
+ exports.CONTROL_PANEL_DATA_INITIAL_DATA = {
9
+ sentimentData: null,
10
+ openInterestData: null,
11
+ tradeSummaryData: null,
12
+ factSheetMainContent: null,
13
+ overview: null,
14
+ };
15
+ exports.INITIAL_WATCHLIST = ["TSLA:NASDAQ", "AAPL:NASDAQ", "META:NASDAQ", "AMZN:NASDAQ", "MSFT:NASDAQ", "NVDA:NASDAQ"];
16
+ var getTableFilterDefaultValue = function () {
17
+ var _a;
18
+ return ({
19
+ id: (0, uuid_1.v4)(),
20
+ premium: null,
21
+ put_call: null,
22
+ side: null,
23
+ option_activity_type: null,
24
+ itemOptionChainInfo: null,
25
+ market_data: null,
26
+ greek_algo_data: null,
27
+ option_algo_data: null,
28
+ symbol_meta_data: null,
29
+ size: null,
30
+ expiry_days: null,
31
+ is_opening_only: null,
32
+ underlying_type: null,
33
+ symbol: null,
34
+ moneyness: null,
35
+ score: null,
36
+ price: null,
37
+ daily_volume: null,
38
+ oi: null,
39
+ underlying_price: null,
40
+ strike: null,
41
+ strategy_label: null,
42
+ delta: null,
43
+ iv: null,
44
+ dei: null,
45
+ dex: null,
46
+ date_filter: {
47
+ start_date: (0, date_functions_1.getLastTradeDate)(),
48
+ end_date: (0, date_functions_1.getLastTradeDate)(),
49
+ max_trading_date: (0, date_functions_1.getLastTradeDate)(), //this is not accurate, need to update it when neccessary.
50
+ },
51
+ // time_filter: ["09:30:00", "16:00:00"],
52
+ time_filter: null,
53
+ sentiment: null,
54
+ is_recent_earning_only: null,
55
+ pagination: {
56
+ current: 1,
57
+ pageSize: DEFAULT_PAGE_SIZE,
58
+ },
59
+ sorter: {
60
+ columnKey: shared_1.TABLEFILTER_KEY.TIME,
61
+ order: "descend",
62
+ },
63
+ columnsStateMap: (_a = {},
64
+ _a[shared_1.TABLEFILTER_KEY.UNDERLYING_TYPE] = { "show": true, "order": 0 },
65
+ _a[shared_1.TABLEFILTER_KEY.TIME] = { "show": true, "order": 1 },
66
+ _a[shared_1.TABLEFILTER_KEY.EXPIRATION_DATE] = { "show": true, "order": 2 },
67
+ _a[shared_1.TABLEFILTER_KEY.PUT_CALL] = { "show": true, "order": 3 },
68
+ _a[shared_1.TABLEFILTER_KEY.SIDE] = { "show": true, "order": 4 },
69
+ _a[shared_1.TABLEFILTER_KEY.STRIKE] = { "show": true, "order": 5 },
70
+ _a[shared_1.TABLEFILTER_KEY.MONEYNESS] = { "show": true, "order": 6 },
71
+ _a[shared_1.TABLEFILTER_KEY.PREMIUM] = null,
72
+ _a[shared_1.TABLEFILTER_KEY.SIZE] = { "show": true, "order": 8 },
73
+ _a[shared_1.TABLEFILTER_KEY.OI] = { "show": true, "order": 9 },
74
+ _a[shared_1.TABLEFILTER_KEY.OPTION_ACTIVITY_TYPE] = { "show": true, "order": 10 },
75
+ _a[shared_1.TABLEFILTER_KEY.DELTA] = { "show": true, "order": 11 },
76
+ _a[shared_1.TABLEFILTER_KEY.IV] = { "show": true, "order": 12 },
77
+ _a[shared_1.TABLEFILTER_KEY.DEI] = { "show": true, "order": 13 },
78
+ _a[shared_1.TABLEFILTER_KEY.SENTIMENT] = { "show": true, "order": 14 },
79
+ _a[shared_1.TABLEFILTER_KEY.UNDERLYING_PRICE] = { "show": true, "order": 15 },
80
+ _a[shared_1.TABLEFILTER_KEY.SCORE] = { "show": true, "order": 16 },
81
+ _a[shared_1.TABLEFILTER_KEY.PRICE] = { show: true, order: 17 },
82
+ _a[shared_1.TABLEFILTER_KEY.DAILY_VOLUME] = { show: true, order: 18 },
83
+ _a[shared_1.TABLEFILTER_KEY.DEX] = { show: true, order: 19 },
84
+ _a),
85
+ watchlistOnly: false,
86
+ default: true,
87
+ version: "2024-11-01-01",
88
+ });
89
+ };
90
+ exports.getTableFilterDefaultValue = getTableFilterDefaultValue;
91
+ // Keep this for backward compatibility, but it should be deprecated
92
+ exports.TABLEFILTER_DEFAULT_VALUE = (0, exports.getTableFilterDefaultValue)();
93
+ /**
94
+ * when the symbol value is null in the tableFilter, we set it as SPY when we need one as placeholder
95
+ */
96
+ exports.DEFAULT_SYMBOL = "SPY";
@@ -0,0 +1,9 @@
1
+ export * from './types/shared';
2
+ export * from './types/optionTrades';
3
+ export * from './types/optionChain';
4
+ export * from './types/websocketCF';
5
+ export * from './utils/strategy/calculateScoreAndStrategy';
6
+ export * from './utils/common/date-functions';
7
+ export * from './utils/common/math-functions';
8
+ export * from './utils/common/record-function';
9
+ export * from './utils/common/discord-functions';
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types/shared"), exports);
18
+ __exportStar(require("./types/optionTrades"), exports);
19
+ __exportStar(require("./types/optionChain"), exports);
20
+ __exportStar(require("./types/websocketCF"), exports);
21
+ __exportStar(require("./utils/strategy/calculateScoreAndStrategy"), exports);
22
+ __exportStar(require("./utils/common/date-functions"), exports);
23
+ __exportStar(require("./utils/common/math-functions"), exports);
24
+ __exportStar(require("./utils/common/record-function"), exports);
25
+ __exportStar(require("./utils/common/discord-functions"), exports);
@@ -0,0 +1,21 @@
1
+ import { CALL_PUT_TAG } from "./shared";
2
+ export interface TF_OptionChainData {
3
+ option_symbol: string;
4
+ put_call: CALL_PUT_TAG;
5
+ symbol: string;
6
+ bid: number;
7
+ ask: number;
8
+ close: number;
9
+ volume: number;
10
+ delta: number;
11
+ gamma: number;
12
+ theta: number;
13
+ vega: number;
14
+ open_interest: number;
15
+ strike: number;
16
+ iv: number;
17
+ expiration_date: string;
18
+ days_to_expiration: number;
19
+ snapshot_date: string;
20
+ updated_time: string;
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,101 @@
1
+ import { OptionFlowItem, CALL_PUT_TAG, MONEYNESS_LABEL, SENTIMENT_TAG, SIDE_LABEL, UNDERLYING_TYPE_TAG, STRATEGY_LABEL, ItemOptionChainInfo } from "./shared";
2
+ /** raw data from UW
3
+ {
4
+ "ask_vol": 75579,
5
+ "bid_vol": 63966,
6
+ "delta": "0.994228192461621",
7
+ "ewma_nbbo_ask": "1.44",
8
+ "ewma_nbbo_bid": "1.37",
9
+ "exchange": "XPHO",
10
+ "executed_at": 1712951756982,
11
+ "gamma": "0.0295023324215793",
12
+ "id": "7b16cc41-fff1-467d-ba27-2833ed36b8aa",
13
+ "implied_volatility": "0.417829062773295",
14
+ "mid_vol": 15186,
15
+ "multi_vol": 14665,
16
+ "nbbo_ask": "1.44",
17
+ "nbbo_bid": "1.37",
18
+ "no_side_vol": 0,
19
+ "open_interest": 30349,
20
+ "option_symbol": "AAPL240412C00175000",
21
+ "premium": "7050.00",
22
+ "price": "1.41",
23
+ "report_flags": [],
24
+ "rho": "0.0000993041222724721",
25
+ "size": 50,
26
+ "stock_multi_vol": 16,
27
+ "tags": [
28
+ "ask_side",
29
+ "bullish"
30
+ ],
31
+ "theo": "1.401030929199951",
32
+ "theta": "-0.001030929199945518",
33
+ "trade_code": "slan",
34
+ "underlying_price": "176.415",
35
+ "vega": "0.0002189364423635975",
36
+ "volume": 154731
37
+ }
38
+
39
+ */
40
+ /**
41
+ * most popular ones: auto: AutoExecution, Transaction was executed electronically. Prefix appears solely for information; process as a regular transaction.
42
+ * slan: SingLegAuctNonISO, Transaction was the execution of an electronic order which was “stopped” at a price and traded in a two sided auction mechanism that goes through an exposure period. Such auctions mechanisms include and not limited to Price Improvement, Facilitation or Soliciation Mechanism.
43
+ * mlet: MultLegAutoEx, Transaction represents an electronic execution of a multi leg order traded in a complex order book.
44
+ * mlat: MultLegAuct, Transaction was the execution of an electronic multi leg order which was “stopped” at a price and traded in a two sided auction mechanism that goes through an exposure period in a complex order book. Such auctions mechanisms include and not limited to Price Improvement, Facilitation or Solicitation Mechanism.
45
+ * isoi: IntermarketSweep, Transaction was the execution of an order identified as an Intermarket Sweep Order. Process like normal transaction.
46
+ * mesl: MultLegAutoSingLeg, Transaction represents an electronic execution of a multi Leg order traded against single leg orders/ quotes.
47
+ * tlet: Stock Options auto-electronic trade, StkOptAutoEx, Transaction represents an electronic execution of a multi leg stock/options order traded in a complex order book.
48
+ * slft: Single Leg Floor Trade, SingLegFlr, Transaction represents a non-electronic trade executed on a trading floor. Execution of Paired and Non-Paired Auctions and Cross orders on an exchange floor are also included in this category.
49
+ * mlft: Multi Leg auto-electronic trade, MultLegAutoEx, Transaction represents an electronic execution of a multi leg order traded in a complex order book.
50
+ * cbmo: Multi Leg Floor Trade of Proprietary Products, MultLegFlrPropProd, Transaction represents execution of a proprietary product non-electronic multi leg order with at least 3 legs. The trade price may be outside the current NBBO.
51
+ */
52
+ export interface OptionFlowItemBase {
53
+ id: string;
54
+ date: string;
55
+ size: number;
56
+ price: number;
57
+ premium: number;
58
+ bid: number;
59
+ ask: number;
60
+ time: string;
61
+ symbol: string;
62
+ put_call: CALL_PUT_TAG;
63
+ strike: number;
64
+ expiration_date: string;
65
+ underlying_type: UNDERLYING_TYPE_TAG;
66
+ option_activity_type: string;
67
+ oi: number;
68
+ underlying_price: number;
69
+ sentiment: SENTIMENT_TAG;
70
+ expiry_days: number;
71
+ side: SIDE_LABEL;
72
+ moneyness: MONEYNESS_LABEL;
73
+ iv: number;
74
+ delta: number;
75
+ option_symbol: string;
76
+ gamma: number;
77
+ daily_volume: number;
78
+ earning_date: string;
79
+ }
80
+ export interface OptionFlowItemFull extends OptionFlowItemBase {
81
+ dex: number;
82
+ dei: number;
83
+ trade_count: number;
84
+ updated_timestamp: number;
85
+ ask_size: number;
86
+ bid_size: number;
87
+ exchange: string;
88
+ vega: number;
89
+ theta: number;
90
+ rho: number;
91
+ market_cap: number;
92
+ }
93
+ /**
94
+ * calculate the score for web app
95
+ */
96
+ export interface OptionFlowItemFullWebApp extends OptionFlowItemFull {
97
+ score: number;
98
+ strategy_label: STRATEGY_LABEL[];
99
+ itemOptionChainInfo: ItemOptionChainInfo | null;
100
+ }
101
+ export declare function convertOptionFlowItemFullToOptionFlowItem(data: OptionFlowItemFull): OptionFlowItem;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertOptionFlowItemFullToOptionFlowItem = void 0;
4
+ var calculateScoreAndStrategy_1 = require("../utils/strategy/calculateScoreAndStrategy");
5
+ var shared_1 = require("./shared");
6
+ function convertOptionFlowItemFullToOptionFlowItem(data) {
7
+ // Convert OptionFlowItemFull to OptionFlowItem
8
+ var record = {
9
+ id: data.id,
10
+ ticker: data.symbol,
11
+ date_expiration: data.expiration_date,
12
+ strike_price: data.strike,
13
+ put_call: data.put_call,
14
+ date: data.date,
15
+ time: data.time,
16
+ size: data.size,
17
+ price: data.price,
18
+ bid: data.bid,
19
+ ask: data.ask,
20
+ open_interest: data.oi,
21
+ option_activity_type: shared_1.OPTION_ACTIVITY_TYPE.TRADE,
22
+ iv: data.iv,
23
+ delta: data.delta,
24
+ ref: data.underlying_price,
25
+ underlying_type: data.underlying_type,
26
+ cost_basis: data.premium,
27
+ side: data.side,
28
+ sentiment: data.sentiment,
29
+ moneyness: data.moneyness,
30
+ expiry_days: data.expiry_days,
31
+ option_symbol: data.option_symbol,
32
+ gamma: data.gamma,
33
+ volume: data.daily_volume,
34
+ earning: data.earning_date,
35
+ deltaExposure: data.dex,
36
+ deltaImpact: data.dei,
37
+ trade_count: data.trade_count,
38
+ vega: data.vega,
39
+ theta: data.theta,
40
+ updated: data.updated_timestamp,
41
+ score: 0,
42
+ strategy_label: [],
43
+ itemOptionChainInfo: undefined,
44
+ ttl: 0,
45
+ midpoint: 0,
46
+ };
47
+ (0, calculateScoreAndStrategy_1.calculateScoreAndStrategy)(record);
48
+ if (data.option_activity_type === 'AGGREGATED') {
49
+ record.option_activity_type = shared_1.OPTION_ACTIVITY_TYPE.SWEEP;
50
+ }
51
+ return record;
52
+ }
53
+ exports.convertOptionFlowItemFullToOptionFlowItem = convertOptionFlowItemFullToOptionFlowItem;