@trade-it/react 0.1.0 → 0.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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +2 -7
- package/dist/index.cjs +16 -20
- package/dist/index.d.cts +47 -73
- package/dist/index.d.ts +47 -73
- package/dist/index.js +11 -21
- package/package.json +17 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@trade-it/react` will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.2.0 - 2026-07-27
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Typed `takeProfit` and `stopLoss` configuration for simple Buy entries
|
|
10
|
+
- `TriggerUnit` and the complete Trade Link parameter enum surface
|
|
11
|
+
- `OrderDirection.Even` support for zero-net options orders
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Serialize multi-leg debit, credit, and even directions into embedded trade URLs
|
|
16
|
+
- Keep the package declarations independent of internal Trade It schemas
|
|
17
|
+
|
|
5
18
|
## 0.1.0 - 2026-02-25
|
|
6
19
|
|
|
7
20
|
Initial public SDK release (v1 foundation).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Trade It, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ Use this package when you want to:
|
|
|
7
7
|
- open the Trade It connect flow in a modal
|
|
8
8
|
- open prefilled trade flows in a modal
|
|
9
9
|
- keep users on your site while they connect brokerages and place trades
|
|
10
|
+
- prefill simple, bracket-exit, and multi-leg options orders with typed configuration
|
|
10
11
|
|
|
11
12
|
## Install
|
|
12
13
|
|
|
@@ -14,11 +15,6 @@ Use this package when you want to:
|
|
|
14
15
|
npm i @trade-it/react
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
Peer dependencies:
|
|
18
|
-
|
|
19
|
-
- `react` (`^18 || ^19`)
|
|
20
|
-
- `react-dom` (`^18 || ^19`)
|
|
21
|
-
|
|
22
18
|
## Documentation
|
|
23
19
|
|
|
24
20
|
Full integration guides, examples, and API references:
|
|
@@ -31,5 +27,4 @@ Full integration guides, examples, and API references:
|
|
|
31
27
|
|
|
32
28
|
## Notes
|
|
33
29
|
|
|
34
|
-
-
|
|
35
|
-
- `@trade-it/react` depends on `@trade-it/core`.
|
|
30
|
+
- Use the Trade It React skill to have your AI agent integrate Trade It: `npx skills add trade-it-inc/react-sdk-skill`
|
package/dist/index.cjs
CHANGED
|
@@ -372,6 +372,7 @@ let OrderType = /* @__PURE__ */ function(OrderType$1) {
|
|
|
372
372
|
let OrderDirection = /* @__PURE__ */ function(OrderDirection$1) {
|
|
373
373
|
OrderDirection$1["Debit"] = "debit";
|
|
374
374
|
OrderDirection$1["Credit"] = "credit";
|
|
375
|
+
OrderDirection$1["Even"] = "even";
|
|
375
376
|
return OrderDirection$1;
|
|
376
377
|
}({});
|
|
377
378
|
let TimeInForce = /* @__PURE__ */ function(TimeInForce$1) {
|
|
@@ -386,6 +387,14 @@ let TradeUnit = /* @__PURE__ */ function(TradeUnit$1) {
|
|
|
386
387
|
TradeUnit$1["Shares"] = "shares";
|
|
387
388
|
return TradeUnit$1;
|
|
388
389
|
}({});
|
|
390
|
+
/** How an exit trigger (take-profit / stop-loss) value is expressed */
|
|
391
|
+
let TriggerUnit = /* @__PURE__ */ function(TriggerUnit$1) {
|
|
392
|
+
/** An absolute price level */
|
|
393
|
+
TriggerUnit$1["Price"] = "$";
|
|
394
|
+
/** A percentage offset from the entry price */
|
|
395
|
+
TriggerUnit$1["Percent"] = "%";
|
|
396
|
+
return TriggerUnit$1;
|
|
397
|
+
}({});
|
|
389
398
|
let LegType = /* @__PURE__ */ function(LegType$1) {
|
|
390
399
|
LegType$1["Option"] = "option";
|
|
391
400
|
LegType$1["Equity"] = "equity";
|
|
@@ -397,25 +406,6 @@ let TradeType = /* @__PURE__ */ function(TradeType$1) {
|
|
|
397
406
|
return TradeType$1;
|
|
398
407
|
}({});
|
|
399
408
|
|
|
400
|
-
//#endregion
|
|
401
|
-
//#region ../../lib/types/src/types/trade-link.types.ts
|
|
402
|
-
/**
|
|
403
|
-
* Short query parameter keys for trade link URLs
|
|
404
|
-
*/
|
|
405
|
-
let TradeLinkParam = /* @__PURE__ */ function(TradeLinkParam$1) {
|
|
406
|
-
TradeLinkParam$1["TradeType"] = "tt";
|
|
407
|
-
TradeLinkParam$1["Action"] = "t";
|
|
408
|
-
TradeLinkParam$1["OrderType"] = "ot";
|
|
409
|
-
TradeLinkParam$1["Amount"] = "a";
|
|
410
|
-
TradeLinkParam$1["Unit"] = "u";
|
|
411
|
-
TradeLinkParam$1["LimitPrice"] = "lp";
|
|
412
|
-
TradeLinkParam$1["StopPrice"] = "sp";
|
|
413
|
-
TradeLinkParam$1["TimeInForce"] = "tif";
|
|
414
|
-
TradeLinkParam$1["UtmReferred"] = "ref";
|
|
415
|
-
TradeLinkParam$1["Legs"] = "legs";
|
|
416
|
-
return TradeLinkParam$1;
|
|
417
|
-
}({});
|
|
418
|
-
|
|
419
409
|
//#endregion
|
|
420
410
|
exports.LegType = LegType;
|
|
421
411
|
exports.OrderDirection = OrderDirection;
|
|
@@ -424,9 +414,15 @@ exports.PositionEffect = PositionEffect;
|
|
|
424
414
|
exports.TimeInForce = TimeInForce;
|
|
425
415
|
exports.TradeAction = TradeAction;
|
|
426
416
|
exports.TradeItModal = TradeItModal;
|
|
427
|
-
exports
|
|
417
|
+
Object.defineProperty(exports, 'TradeLinkParam', {
|
|
418
|
+
enumerable: true,
|
|
419
|
+
get: function () {
|
|
420
|
+
return __trade_it_core.TradeLinkParam;
|
|
421
|
+
}
|
|
422
|
+
});
|
|
428
423
|
exports.TradeType = TradeType;
|
|
429
424
|
exports.TradeUnit = TradeUnit;
|
|
425
|
+
exports.TriggerUnit = TriggerUnit;
|
|
430
426
|
Object.defineProperty(exports, 'getTradeItErrorMessage', {
|
|
431
427
|
enumerable: true,
|
|
432
428
|
get: function () {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as react0 from "react";
|
|
2
|
-
import { z } from "zod";
|
|
3
2
|
|
|
4
3
|
//#region ../../lib/types/src/enums/trading.enums.d.ts
|
|
5
4
|
declare enum TradeAction {
|
|
@@ -19,6 +18,7 @@ declare enum OrderType {
|
|
|
19
18
|
declare enum OrderDirection {
|
|
20
19
|
Debit = "debit",
|
|
21
20
|
Credit = "credit",
|
|
21
|
+
Even = "even",
|
|
22
22
|
}
|
|
23
23
|
declare enum TimeInForce {
|
|
24
24
|
Day = "day",
|
|
@@ -30,6 +30,15 @@ declare enum TradeUnit {
|
|
|
30
30
|
Dollars = "dollars",
|
|
31
31
|
Shares = "shares",
|
|
32
32
|
}
|
|
33
|
+
/** How an exit trigger (take-profit / stop-loss) value is expressed */
|
|
34
|
+
declare enum TriggerUnit {
|
|
35
|
+
/** An absolute price level */
|
|
36
|
+
Price = "$",
|
|
37
|
+
/** A percentage offset from the entry price */
|
|
38
|
+
Percent = "%",
|
|
39
|
+
}
|
|
40
|
+
/** Which exit an attached trigger represents */
|
|
41
|
+
|
|
33
42
|
declare enum LegType {
|
|
34
43
|
Option = "option",
|
|
35
44
|
Equity = "equity",
|
|
@@ -39,93 +48,56 @@ declare enum TradeType {
|
|
|
39
48
|
MultiLeg = 1,
|
|
40
49
|
}
|
|
41
50
|
//#endregion
|
|
42
|
-
//#region
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
type:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
execution_price: z.ZodNullable<z.ZodObject<{
|
|
53
|
-
amount: z.ZodNumber;
|
|
54
|
-
currency: z.ZodString;
|
|
55
|
-
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
amount: number;
|
|
57
|
-
currency: string;
|
|
58
|
-
}, {
|
|
59
|
-
amount: number;
|
|
60
|
-
currency: string;
|
|
61
|
-
}>>;
|
|
62
|
-
}, "execution_price">, "strip", z.ZodTypeAny, {
|
|
63
|
-
type: LegType;
|
|
64
|
-
action: TradeAction;
|
|
65
|
-
position_effect: PositionEffect | null;
|
|
66
|
-
occ: string | null;
|
|
67
|
-
quantity: number;
|
|
68
|
-
}, {
|
|
69
|
-
type: LegType;
|
|
70
|
-
action: TradeAction;
|
|
71
|
-
position_effect: PositionEffect | null;
|
|
72
|
-
occ: string | null;
|
|
73
|
-
quantity: number;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* Full Trade Link Config - stored in database as JSONB
|
|
77
|
-
* Supports both simple trades and multi-leg options trades
|
|
78
|
-
*/
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region ../../lib/types/src/types/misc.types.d.ts
|
|
81
|
-
type SnakeToCamelCase<S extends string> = S extends `${infer P1}_${infer P2}` ? `${P1}${Capitalize<SnakeToCamelCase<P2>>}` : S;
|
|
82
|
-
/** Converts a type's snake_case keys to camelCase keys */
|
|
83
|
-
type Camelize<T> = T extends object ? { [K in keyof T as K extends string ? SnakeToCamelCase<K> : K]: Camelize<T[K]> } : T;
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region ../../lib/types/src/types/trade-link.types.d.ts
|
|
86
|
-
/** Configuration for a leg in a multi-leg trade link */
|
|
87
|
-
type TradeLinkLegConfig = z.infer<typeof zTradeLinkLegConfig>;
|
|
88
|
-
/** Full configuration stored in the trade link */
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Short query parameter keys for trade link URLs
|
|
92
|
-
*/
|
|
51
|
+
//#region ../trade-it-core/src/types.d.ts
|
|
52
|
+
type TradeItEventType = 'tradeit.ready' | 'tradeit.close_requested' | 'tradeit.brokerage_connected' | 'tradeit.trade_submitted' | 'tradeit.trade_executed' | 'tradeit.error' | 'tradeit.login_required';
|
|
53
|
+
interface TradeItEvent<TPayload = Record<string, unknown>> {
|
|
54
|
+
source: 'tradeit';
|
|
55
|
+
version: 1;
|
|
56
|
+
type: TradeItEventType;
|
|
57
|
+
payload?: TPayload;
|
|
58
|
+
}
|
|
59
|
+
type TradeItMode = 'connect' | 'trade';
|
|
60
|
+
/** Compact query keys accepted by Trade It trade URLs. */
|
|
93
61
|
declare enum TradeLinkParam {
|
|
94
62
|
TradeType = "tt",
|
|
95
|
-
// s (simple), m (multi_leg)
|
|
96
63
|
Action = "t",
|
|
97
|
-
|
|
64
|
+
Direction = "dir",
|
|
98
65
|
OrderType = "ot",
|
|
99
|
-
// m, l, st, sl
|
|
100
66
|
Amount = "a",
|
|
101
|
-
// number
|
|
102
67
|
Unit = "u",
|
|
103
|
-
// d, s
|
|
104
68
|
LimitPrice = "lp",
|
|
105
|
-
// number
|
|
106
69
|
StopPrice = "sp",
|
|
107
|
-
// number
|
|
108
70
|
TimeInForce = "tif",
|
|
109
|
-
|
|
71
|
+
TakeProfit = "tp",
|
|
72
|
+
StopLoss = "sl",
|
|
110
73
|
UtmReferred = "ref",
|
|
111
|
-
// string
|
|
112
74
|
Legs = "legs",
|
|
113
75
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
type
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
76
|
+
/** Canonical snake_case leg shape used by Trade Link APIs. */
|
|
77
|
+
interface TradeLinkLegConfig {
|
|
78
|
+
type: LegType;
|
|
79
|
+
action: TradeAction;
|
|
80
|
+
position_effect: PositionEffect | null;
|
|
81
|
+
occ: string | null;
|
|
82
|
+
quantity: number;
|
|
83
|
+
}
|
|
84
|
+
/** User-facing camelCase leg shape accepted by the embedded SDK. */
|
|
85
|
+
interface TradeItMultiLegTradeLegConfig {
|
|
86
|
+
type?: LegType;
|
|
87
|
+
action?: TradeAction;
|
|
88
|
+
positionEffect?: PositionEffect | null;
|
|
89
|
+
occ?: string | null;
|
|
90
|
+
quantity?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Attached take-profit or stop-loss trigger. */
|
|
93
|
+
interface TradeItExitTrigger {
|
|
94
|
+
value: number;
|
|
95
|
+
unit: '$' | '%';
|
|
122
96
|
}
|
|
123
|
-
type TradeItMode = 'connect' | 'trade';
|
|
124
|
-
type TradeItMultiLegTradeLegConfig = Partial<Camelize<TradeLinkLegConfig>>;
|
|
125
97
|
/**
|
|
126
98
|
* Query params accepted by Trade It's /t/[ticker] page.
|
|
127
99
|
* User-facing config uses descriptive keys; core converts them to the short-key
|
|
128
|
-
* query format used by the page parser (tt, t, ot, a, u, lp, sp, tif, ref, legs).
|
|
100
|
+
* query format used by the page parser (tt, t, dir, ot, a, u, lp, sp, tif, tp, sl, ref, legs).
|
|
129
101
|
*/
|
|
130
102
|
interface TradeItTradeConfigBase {
|
|
131
103
|
ticker: string;
|
|
@@ -140,6 +112,8 @@ interface TradeItSimpleTradeConfig extends TradeItTradeConfigBase {
|
|
|
140
112
|
action?: TradeAction;
|
|
141
113
|
amount?: number;
|
|
142
114
|
unit?: TradeUnit;
|
|
115
|
+
takeProfit?: TradeItExitTrigger;
|
|
116
|
+
stopLoss?: TradeItExitTrigger;
|
|
143
117
|
}
|
|
144
118
|
interface TradeItMultiLegTradeConfig extends TradeItTradeConfigBase {
|
|
145
119
|
tradeType: TradeType.MultiLeg;
|
|
@@ -219,4 +193,4 @@ interface UseTradeItReturn {
|
|
|
219
193
|
}
|
|
220
194
|
declare function useTradeIt(defaults?: UseTradeItOptions): UseTradeItReturn;
|
|
221
195
|
//#endregion
|
|
222
|
-
export { LegType, type OpenConnectOptions, type OpenTradeOptions, OrderDirection, OrderType, PositionEffect, TimeInForce, TradeAction, type TradeItConnectLaunch, type TradeItEvent, type TradeItEventType, type TradeItLaunch, TradeItModal, type TradeItModalAppearance, type TradeItModalProps, type TradeItMultiLegTradeConfig, type TradeItMultiLegTradeLegConfig, type TradeItSimpleTradeConfig, type TradeItTradeConfig, type TradeItTradeLaunch, type TradeLinkLegConfig, TradeLinkParam, TradeType, TradeUnit, type UseTradeItOptions, getTradeItErrorMessage, getUrlOrigin, isTradeItEvent, resolveLaunchUrl, useTradeIt };
|
|
196
|
+
export { LegType, type OpenConnectOptions, type OpenTradeOptions, OrderDirection, OrderType, PositionEffect, TimeInForce, TradeAction, type TradeItConnectLaunch, type TradeItEvent, type TradeItEventType, type TradeItExitTrigger, type TradeItLaunch, TradeItModal, type TradeItModalAppearance, type TradeItModalProps, type TradeItMultiLegTradeConfig, type TradeItMultiLegTradeLegConfig, type TradeItSimpleTradeConfig, type TradeItTradeConfig, type TradeItTradeLaunch, type TradeLinkLegConfig, TradeLinkParam, TradeType, TradeUnit, TriggerUnit, type UseTradeItOptions, getTradeItErrorMessage, getUrlOrigin, isTradeItEvent, resolveLaunchUrl, useTradeIt };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as react0 from "react";
|
|
2
|
-
import { z } from "zod";
|
|
3
2
|
|
|
4
3
|
//#region ../../lib/types/src/enums/trading.enums.d.ts
|
|
5
4
|
declare enum TradeAction {
|
|
@@ -19,6 +18,7 @@ declare enum OrderType {
|
|
|
19
18
|
declare enum OrderDirection {
|
|
20
19
|
Debit = "debit",
|
|
21
20
|
Credit = "credit",
|
|
21
|
+
Even = "even",
|
|
22
22
|
}
|
|
23
23
|
declare enum TimeInForce {
|
|
24
24
|
Day = "day",
|
|
@@ -30,6 +30,15 @@ declare enum TradeUnit {
|
|
|
30
30
|
Dollars = "dollars",
|
|
31
31
|
Shares = "shares",
|
|
32
32
|
}
|
|
33
|
+
/** How an exit trigger (take-profit / stop-loss) value is expressed */
|
|
34
|
+
declare enum TriggerUnit {
|
|
35
|
+
/** An absolute price level */
|
|
36
|
+
Price = "$",
|
|
37
|
+
/** A percentage offset from the entry price */
|
|
38
|
+
Percent = "%",
|
|
39
|
+
}
|
|
40
|
+
/** Which exit an attached trigger represents */
|
|
41
|
+
|
|
33
42
|
declare enum LegType {
|
|
34
43
|
Option = "option",
|
|
35
44
|
Equity = "equity",
|
|
@@ -39,93 +48,56 @@ declare enum TradeType {
|
|
|
39
48
|
MultiLeg = 1,
|
|
40
49
|
}
|
|
41
50
|
//#endregion
|
|
42
|
-
//#region
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
type:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
execution_price: z.ZodNullable<z.ZodObject<{
|
|
53
|
-
amount: z.ZodNumber;
|
|
54
|
-
currency: z.ZodString;
|
|
55
|
-
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
amount: number;
|
|
57
|
-
currency: string;
|
|
58
|
-
}, {
|
|
59
|
-
amount: number;
|
|
60
|
-
currency: string;
|
|
61
|
-
}>>;
|
|
62
|
-
}, "execution_price">, "strip", z.ZodTypeAny, {
|
|
63
|
-
type: LegType;
|
|
64
|
-
action: TradeAction;
|
|
65
|
-
position_effect: PositionEffect | null;
|
|
66
|
-
occ: string | null;
|
|
67
|
-
quantity: number;
|
|
68
|
-
}, {
|
|
69
|
-
type: LegType;
|
|
70
|
-
action: TradeAction;
|
|
71
|
-
position_effect: PositionEffect | null;
|
|
72
|
-
occ: string | null;
|
|
73
|
-
quantity: number;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* Full Trade Link Config - stored in database as JSONB
|
|
77
|
-
* Supports both simple trades and multi-leg options trades
|
|
78
|
-
*/
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region ../../lib/types/src/types/misc.types.d.ts
|
|
81
|
-
type SnakeToCamelCase<S extends string> = S extends `${infer P1}_${infer P2}` ? `${P1}${Capitalize<SnakeToCamelCase<P2>>}` : S;
|
|
82
|
-
/** Converts a type's snake_case keys to camelCase keys */
|
|
83
|
-
type Camelize<T> = T extends object ? { [K in keyof T as K extends string ? SnakeToCamelCase<K> : K]: Camelize<T[K]> } : T;
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region ../../lib/types/src/types/trade-link.types.d.ts
|
|
86
|
-
/** Configuration for a leg in a multi-leg trade link */
|
|
87
|
-
type TradeLinkLegConfig = z.infer<typeof zTradeLinkLegConfig>;
|
|
88
|
-
/** Full configuration stored in the trade link */
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Short query parameter keys for trade link URLs
|
|
92
|
-
*/
|
|
51
|
+
//#region ../trade-it-core/src/types.d.ts
|
|
52
|
+
type TradeItEventType = 'tradeit.ready' | 'tradeit.close_requested' | 'tradeit.brokerage_connected' | 'tradeit.trade_submitted' | 'tradeit.trade_executed' | 'tradeit.error' | 'tradeit.login_required';
|
|
53
|
+
interface TradeItEvent<TPayload = Record<string, unknown>> {
|
|
54
|
+
source: 'tradeit';
|
|
55
|
+
version: 1;
|
|
56
|
+
type: TradeItEventType;
|
|
57
|
+
payload?: TPayload;
|
|
58
|
+
}
|
|
59
|
+
type TradeItMode = 'connect' | 'trade';
|
|
60
|
+
/** Compact query keys accepted by Trade It trade URLs. */
|
|
93
61
|
declare enum TradeLinkParam {
|
|
94
62
|
TradeType = "tt",
|
|
95
|
-
// s (simple), m (multi_leg)
|
|
96
63
|
Action = "t",
|
|
97
|
-
|
|
64
|
+
Direction = "dir",
|
|
98
65
|
OrderType = "ot",
|
|
99
|
-
// m, l, st, sl
|
|
100
66
|
Amount = "a",
|
|
101
|
-
// number
|
|
102
67
|
Unit = "u",
|
|
103
|
-
// d, s
|
|
104
68
|
LimitPrice = "lp",
|
|
105
|
-
// number
|
|
106
69
|
StopPrice = "sp",
|
|
107
|
-
// number
|
|
108
70
|
TimeInForce = "tif",
|
|
109
|
-
|
|
71
|
+
TakeProfit = "tp",
|
|
72
|
+
StopLoss = "sl",
|
|
110
73
|
UtmReferred = "ref",
|
|
111
|
-
// string
|
|
112
74
|
Legs = "legs",
|
|
113
75
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
type
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
76
|
+
/** Canonical snake_case leg shape used by Trade Link APIs. */
|
|
77
|
+
interface TradeLinkLegConfig {
|
|
78
|
+
type: LegType;
|
|
79
|
+
action: TradeAction;
|
|
80
|
+
position_effect: PositionEffect | null;
|
|
81
|
+
occ: string | null;
|
|
82
|
+
quantity: number;
|
|
83
|
+
}
|
|
84
|
+
/** User-facing camelCase leg shape accepted by the embedded SDK. */
|
|
85
|
+
interface TradeItMultiLegTradeLegConfig {
|
|
86
|
+
type?: LegType;
|
|
87
|
+
action?: TradeAction;
|
|
88
|
+
positionEffect?: PositionEffect | null;
|
|
89
|
+
occ?: string | null;
|
|
90
|
+
quantity?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Attached take-profit or stop-loss trigger. */
|
|
93
|
+
interface TradeItExitTrigger {
|
|
94
|
+
value: number;
|
|
95
|
+
unit: '$' | '%';
|
|
122
96
|
}
|
|
123
|
-
type TradeItMode = 'connect' | 'trade';
|
|
124
|
-
type TradeItMultiLegTradeLegConfig = Partial<Camelize<TradeLinkLegConfig>>;
|
|
125
97
|
/**
|
|
126
98
|
* Query params accepted by Trade It's /t/[ticker] page.
|
|
127
99
|
* User-facing config uses descriptive keys; core converts them to the short-key
|
|
128
|
-
* query format used by the page parser (tt, t, ot, a, u, lp, sp, tif, ref, legs).
|
|
100
|
+
* query format used by the page parser (tt, t, dir, ot, a, u, lp, sp, tif, tp, sl, ref, legs).
|
|
129
101
|
*/
|
|
130
102
|
interface TradeItTradeConfigBase {
|
|
131
103
|
ticker: string;
|
|
@@ -140,6 +112,8 @@ interface TradeItSimpleTradeConfig extends TradeItTradeConfigBase {
|
|
|
140
112
|
action?: TradeAction;
|
|
141
113
|
amount?: number;
|
|
142
114
|
unit?: TradeUnit;
|
|
115
|
+
takeProfit?: TradeItExitTrigger;
|
|
116
|
+
stopLoss?: TradeItExitTrigger;
|
|
143
117
|
}
|
|
144
118
|
interface TradeItMultiLegTradeConfig extends TradeItTradeConfigBase {
|
|
145
119
|
tradeType: TradeType.MultiLeg;
|
|
@@ -219,4 +193,4 @@ interface UseTradeItReturn {
|
|
|
219
193
|
}
|
|
220
194
|
declare function useTradeIt(defaults?: UseTradeItOptions): UseTradeItReturn;
|
|
221
195
|
//#endregion
|
|
222
|
-
export { LegType, type OpenConnectOptions, type OpenTradeOptions, OrderDirection, OrderType, PositionEffect, TimeInForce, TradeAction, type TradeItConnectLaunch, type TradeItEvent, type TradeItEventType, type TradeItLaunch, TradeItModal, type TradeItModalAppearance, type TradeItModalProps, type TradeItMultiLegTradeConfig, type TradeItMultiLegTradeLegConfig, type TradeItSimpleTradeConfig, type TradeItTradeConfig, type TradeItTradeLaunch, type TradeLinkLegConfig, TradeLinkParam, TradeType, TradeUnit, type UseTradeItOptions, getTradeItErrorMessage, getUrlOrigin, isTradeItEvent, resolveLaunchUrl, useTradeIt };
|
|
196
|
+
export { LegType, type OpenConnectOptions, type OpenTradeOptions, OrderDirection, OrderType, PositionEffect, TimeInForce, TradeAction, type TradeItConnectLaunch, type TradeItEvent, type TradeItEventType, type TradeItExitTrigger, type TradeItLaunch, TradeItModal, type TradeItModalAppearance, type TradeItModalProps, type TradeItMultiLegTradeConfig, type TradeItMultiLegTradeLegConfig, type TradeItSimpleTradeConfig, type TradeItTradeConfig, type TradeItTradeLaunch, type TradeLinkLegConfig, TradeLinkParam, TradeType, TradeUnit, TriggerUnit, type UseTradeItOptions, getTradeItErrorMessage, getUrlOrigin, isTradeItEvent, resolveLaunchUrl, useTradeIt };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getTradeItErrorMessage, getTradeItErrorMessage as getTradeItErrorMessage$1, getUrlOrigin, getUrlOrigin as getUrlOrigin$1, isTradeItEvent, isTradeItEvent as isTradeItEvent$1, resolveLaunchUrl, resolveLaunchUrl as resolveLaunchUrl$1 } from "@trade-it/core";
|
|
1
|
+
import { TradeLinkParam, getTradeItErrorMessage, getTradeItErrorMessage as getTradeItErrorMessage$1, getUrlOrigin, getUrlOrigin as getUrlOrigin$1, isTradeItEvent, isTradeItEvent as isTradeItEvent$1, resolveLaunchUrl, resolveLaunchUrl as resolveLaunchUrl$1 } from "@trade-it/core";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -349,6 +349,7 @@ let OrderType = /* @__PURE__ */ function(OrderType$1) {
|
|
|
349
349
|
let OrderDirection = /* @__PURE__ */ function(OrderDirection$1) {
|
|
350
350
|
OrderDirection$1["Debit"] = "debit";
|
|
351
351
|
OrderDirection$1["Credit"] = "credit";
|
|
352
|
+
OrderDirection$1["Even"] = "even";
|
|
352
353
|
return OrderDirection$1;
|
|
353
354
|
}({});
|
|
354
355
|
let TimeInForce = /* @__PURE__ */ function(TimeInForce$1) {
|
|
@@ -363,6 +364,14 @@ let TradeUnit = /* @__PURE__ */ function(TradeUnit$1) {
|
|
|
363
364
|
TradeUnit$1["Shares"] = "shares";
|
|
364
365
|
return TradeUnit$1;
|
|
365
366
|
}({});
|
|
367
|
+
/** How an exit trigger (take-profit / stop-loss) value is expressed */
|
|
368
|
+
let TriggerUnit = /* @__PURE__ */ function(TriggerUnit$1) {
|
|
369
|
+
/** An absolute price level */
|
|
370
|
+
TriggerUnit$1["Price"] = "$";
|
|
371
|
+
/** A percentage offset from the entry price */
|
|
372
|
+
TriggerUnit$1["Percent"] = "%";
|
|
373
|
+
return TriggerUnit$1;
|
|
374
|
+
}({});
|
|
366
375
|
let LegType = /* @__PURE__ */ function(LegType$1) {
|
|
367
376
|
LegType$1["Option"] = "option";
|
|
368
377
|
LegType$1["Equity"] = "equity";
|
|
@@ -375,23 +384,4 @@ let TradeType = /* @__PURE__ */ function(TradeType$1) {
|
|
|
375
384
|
}({});
|
|
376
385
|
|
|
377
386
|
//#endregion
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Short query parameter keys for trade link URLs
|
|
381
|
-
*/
|
|
382
|
-
let TradeLinkParam = /* @__PURE__ */ function(TradeLinkParam$1) {
|
|
383
|
-
TradeLinkParam$1["TradeType"] = "tt";
|
|
384
|
-
TradeLinkParam$1["Action"] = "t";
|
|
385
|
-
TradeLinkParam$1["OrderType"] = "ot";
|
|
386
|
-
TradeLinkParam$1["Amount"] = "a";
|
|
387
|
-
TradeLinkParam$1["Unit"] = "u";
|
|
388
|
-
TradeLinkParam$1["LimitPrice"] = "lp";
|
|
389
|
-
TradeLinkParam$1["StopPrice"] = "sp";
|
|
390
|
-
TradeLinkParam$1["TimeInForce"] = "tif";
|
|
391
|
-
TradeLinkParam$1["UtmReferred"] = "ref";
|
|
392
|
-
TradeLinkParam$1["Legs"] = "legs";
|
|
393
|
-
return TradeLinkParam$1;
|
|
394
|
-
}({});
|
|
395
|
-
|
|
396
|
-
//#endregion
|
|
397
|
-
export { LegType, OrderDirection, OrderType, PositionEffect, TimeInForce, TradeAction, TradeItModal, TradeLinkParam, TradeType, TradeUnit, getTradeItErrorMessage, getUrlOrigin, isTradeItEvent, resolveLaunchUrl, useTradeIt };
|
|
387
|
+
export { LegType, OrderDirection, OrderType, PositionEffect, TimeInForce, TradeAction, TradeItModal, TradeLinkParam, TradeType, TradeUnit, TriggerUnit, getTradeItErrorMessage, getUrlOrigin, isTradeItEvent, resolveLaunchUrl, useTradeIt };
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trade-it/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "React SDK for embedding Trade It connect and trade experiences
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "React SDK for embedding Trade It connect and trade experiences into a web app.",
|
|
5
|
+
"author": "Trade It, Inc.",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"main": "./dist/index.cjs",
|
|
@@ -17,19 +18,29 @@
|
|
|
17
18
|
"files": [
|
|
18
19
|
"dist",
|
|
19
20
|
"README.md",
|
|
20
|
-
"CHANGELOG.md"
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"LICENSE"
|
|
21
23
|
],
|
|
22
24
|
"sideEffects": false,
|
|
23
25
|
"publishConfig": {
|
|
24
26
|
"access": "public"
|
|
25
27
|
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/trade-it-inc/trade-it.git",
|
|
31
|
+
"directory": "packages/trade-it-react"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://docs.tradeit.app/sdk",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/trade-it-inc/trade-it/issues"
|
|
36
|
+
},
|
|
26
37
|
"scripts": {
|
|
27
38
|
"build": "tsdown src/index.ts --format esm,cjs --dts --out-dir dist && node ../../scripts/fix-trade-it-sdk-dts.mjs dist/index.d.ts dist/index.d.cts",
|
|
28
|
-
"dev": "tsdown src/index.ts --format esm,cjs --dts --out-dir dist --watch"
|
|
39
|
+
"dev": "tsdown src/index.ts --format esm,cjs --dts --out-dir dist --watch",
|
|
40
|
+
"prepublishOnly": "npm run build"
|
|
29
41
|
},
|
|
30
42
|
"dependencies": {
|
|
31
|
-
"@trade-it/core": "
|
|
32
|
-
"zod": "^3.25.67"
|
|
43
|
+
"@trade-it/core": "^0.2.0"
|
|
33
44
|
},
|
|
34
45
|
"peerDependencies": {
|
|
35
46
|
"react": "^18.0.0 || ^19.0.0",
|