@guihz/trading-vue-editor-tes 0.0.21 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. package/lib/assets/{parserTccWorker-CVfKSNrL.js → parserTccWorker-B-xIp9MW.js} +15 -15
  2. package/lib/assets/scriptsRunWorker-COxpWbV9.js +66 -0
  3. package/lib/components/editor/parseScript/buildInFuncNamespace/index.d.ts +2 -2
  4. package/lib/components/editor/parseScript/buildInFuncNamespace/input.d.ts +1 -5
  5. package/lib/components/editor/parseScript/buildInFuncNamespace/strategy.d.ts +68 -5
  6. package/lib/components/editor/parseScript/buildInVarNamespace/barstate.d.ts +16 -0
  7. package/lib/components/editor/parseScript/buildInVarNamespace/index.d.ts +5 -0
  8. package/lib/components/editor/parseScript/buildInVarNamespace/session.d.ts +12 -0
  9. package/lib/components/editor/parseScript/buildInVarNamespace/strategy.d.ts +71 -0
  10. package/lib/components/editor/parseScript/buildInVarNamespace/ta.d.ts +28 -0
  11. package/lib/components/editor/parseScript/buildInVarNamespace/timeframe.d.ts +16 -0
  12. package/lib/components/editor/parseScript/constants.d.ts +2 -0
  13. package/lib/components/editor/parseScript/strategyNamespace/closedtrades.d.ts +28 -0
  14. package/lib/components/editor/parseScript/strategyNamespace/index.d.ts +4 -0
  15. package/lib/components/editor/parseScript/strategyNamespace/opentrades.d.ts +23 -0
  16. package/lib/components/editor/parseScript/strategyNamespace/risk.d.ts +20 -0
  17. package/lib/components/editor/parseScript/visitorParser.d.ts +1 -0
  18. package/lib/components/editor/utils/initEditor.d.ts +1 -0
  19. package/lib/trading-vue-editor.js +415 -401
  20. package/lib/trading-vue-editor.umd.cjs +23 -23
  21. package/package.json +1 -1
  22. package/lib/assets/scriptsRunWorker-D2Gv6w1f.js +0 -66
@@ -14,10 +14,10 @@ import BuildInLine, { ILineArgs, Line } from "./line";
14
14
  import BuildInLinefill, { TLinefill, Linefill } from "./linefill";
15
15
  import BuildInBox, { IBoxArgs, Box } from "./box";
16
16
  import BuildInTable, { ITableArgs, Table } from "./table";
17
- import Strategy from './strategy';
17
+ import Strategy, { IOrder, IStrategy } from './strategy';
18
18
  import { Log } from './log';
19
19
  import { Runtime } from './runtime';
20
20
  export { TccErrorListener } from './errorListener';
21
21
  export type { IColorArgs } from './color';
22
22
  export { BuildInArray, BuildInMath, BuildInTa, BuildInInput, BuildInColor, BuildInMatrix, ChartPoint, Point, BuildInTimeframe, BuildInStr, BuildInMap, PseudoArray, VInputType, BuildInLabel, BuildInPolyline, BuildInLine, Label, Polyline, Line, BuildInLinefill, Linefill, BuildInBox, Box, BuildInTable, Table, Log, Runtime, Strategy };
23
- export type { PartialLabelArgs, IPolyline, ILineArgs, TLinefill, IBoxArgs, ITableArgs };
23
+ export type { PartialLabelArgs, IPolyline, ILineArgs, TLinefill, IBoxArgs, ITableArgs, IOrder, IStrategy };
@@ -35,10 +35,6 @@ interface IInputArgs {
35
35
  index?: number;
36
36
  modifyDefval?: TSimpleType;
37
37
  }
38
- interface IGruop {
39
- name?: string;
40
- inputs: IInputArgs[];
41
- }
42
38
  declare class Input {
43
39
  private _cacheData;
44
40
  private _variables;
@@ -64,7 +60,7 @@ declare class Input {
64
60
  private _cacheHandle;
65
61
  private _judgeHistoryInputs;
66
62
  private _displayVerify;
67
- getInputs(): IGruop[];
63
+ getInputs(): IInputArgs[];
68
64
  private _getGroups;
69
65
  }
70
66
  export default Input;
@@ -1,7 +1,9 @@
1
+ import { TccErrorListener } from ".";
1
2
  import { IKeyObjectValue } from "../../type";
2
3
  import { BuiltInVariables } from "../buildInVariables";
3
4
  import { VCommission, VDirection, VFormatType, VOca, VScale, VStrategy } from "../enum";
4
- interface IStrategy {
5
+ import { Closedtrdes, Opentrades, Risk } from '../strategyNamespace';
6
+ export interface IStrategy {
5
7
  title?: string;
6
8
  shorttitle?: string;
7
9
  overlay?: boolean;
@@ -34,6 +36,10 @@ interface IStrategy {
34
36
  fill_orders_on_standard_ohlc?: boolean;
35
37
  max_polylines_count?: number;
36
38
  }
39
+ interface IArgs {
40
+ value?: number;
41
+ fill_price?: number;
42
+ }
37
43
  interface IOrderArgs {
38
44
  id: string;
39
45
  direction: VDirection;
@@ -53,14 +59,21 @@ interface IOrderArgs {
53
59
  trail_points?: number;
54
60
  trail_offset?: number;
55
61
  profit?: number;
62
+ comment_profit?: string;
63
+ comment_loss?: string;
64
+ comment_trailing?: string;
56
65
  }
57
66
  type PlaceOrderType = 'order' | 'entry' | 'exit' | 'close' | 'close_all';
58
- interface IOrder extends IOrderArgs {
67
+ export interface IOrder extends IOrderArgs {
59
68
  isMarketPrice?: boolean;
69
+ out_id?: string;
70
+ in_index?: number;
71
+ out_index?: number;
60
72
  in_price: number;
61
73
  out_price?: number;
62
74
  in_time?: number;
63
75
  out_time?: number;
76
+ out_qty?: number;
64
77
  out_comment?: string;
65
78
  total_profit?: number;
66
79
  max_profit?: number;
@@ -75,6 +88,27 @@ interface IOrder extends IOrderArgs {
75
88
  isMarketPriceStop?: boolean;
76
89
  isCancel?: boolean;
77
90
  close_qty?: number;
91
+ profit_percent?: number;
92
+ max_profit_percent?: number;
93
+ trading_loss_percent?: number;
94
+ commission?: number;
95
+ original_qty?: number;
96
+ }
97
+ interface IRisk {
98
+ allow_entry_in?: VDirection;
99
+ max_cons_loss_days?: number;
100
+ max_drawdown?: number;
101
+ max_drawdown_type?: VStrategy;
102
+ max_intraday_filled_orders?: number;
103
+ max_intraday_loss?: number;
104
+ max_intraday_loss_type?: VStrategy;
105
+ max_position_size?: number;
106
+ isDisabledOpen?: boolean;
107
+ lossDays?: number;
108
+ totalProfit?: number;
109
+ intradayOrders?: number;
110
+ isTemporaryBan?: boolean;
111
+ preNetprofit?: number;
78
112
  }
79
113
  type CloseEntriesRuleType = 'FIFO' | 'ANY';
80
114
  export default class Strategy {
@@ -86,10 +120,28 @@ export default class Strategy {
86
120
  private _pendingOrders;
87
121
  private _mintick;
88
122
  private _funcOptions;
89
- constructor(variables: BuiltInVariables, options: IKeyObjectValue, mintick?: number);
123
+ private _pendingCloseOrders;
124
+ private _errorListener;
125
+ private _risk;
126
+ private _opentrades;
127
+ private _closedtrades;
128
+ private _riskNamespace;
129
+ constructor(variables: BuiltInVariables, options: IKeyObjectValue, mintick: number, errorListener: TccErrorListener);
130
+ get orders(): IOrder[];
131
+ get historyOrders(): IOrder[];
90
132
  get _orderProfit(): number;
91
133
  get _freezeCapital(): number;
92
- updateOptions(options: IStrategy): void;
134
+ get opentrades(): Opentrades;
135
+ get closedtrades(): Closedtrdes;
136
+ get risk(): Risk;
137
+ updateOptions(options?: IStrategy): void;
138
+ updateRisk(risk: IRisk): void;
139
+ endExecution(): void;
140
+ private _maxIntradayLoss;
141
+ private _maxIntradayFilledOrdersVerify;
142
+ private _maxConsLossDaysVerify;
143
+ private _maxDrawdownVerify;
144
+ private _riskTouchOff;
93
145
  strategy(args: IStrategy): void;
94
146
  order(args: IOrderArgs): void;
95
147
  entry(args: IOrderArgs): void;
@@ -99,11 +151,16 @@ export default class Strategy {
99
151
  id: string;
100
152
  }): void;
101
153
  cancel_all(): void;
102
- exit(args: IOrderArgs): void;
154
+ exit(args: IOrderArgs, posStr: string): void;
155
+ convert_to_account({ value }: IArgs): number | undefined;
156
+ convert_to_symbol({ value }: IArgs): number | undefined;
157
+ default_entry_qty({ fill_price }: IArgs): number;
103
158
  private _calcDefaultQty;
104
159
  private _getCapital;
105
160
  private _calcProfitAndLoss;
161
+ private _calcOrderPercent;
106
162
  private _calcLiquidate;
163
+ private _marginCallOrders;
107
164
  private _orderHandle;
108
165
  private _judgeCapitalEnough;
109
166
  private _ocaGroupVerify;
@@ -112,6 +169,7 @@ export default class Strategy {
112
169
  private _orderArgsParse;
113
170
  private _entryHandle;
114
171
  private _entryOrder;
172
+ private _getAvailablePositionSize;
115
173
  private _getEntryOrders;
116
174
  private _addPendingEntry;
117
175
  private _closeAllOrders;
@@ -119,18 +177,23 @@ export default class Strategy {
119
177
  private _closeOrder;
120
178
  private _ordersHandle;
121
179
  private _pendingOrderHandle;
180
+ private _pendingCloseOrderHandle;
122
181
  private _entryOrderHandle;
123
182
  private _orderOrderHandle;
124
183
  private _closeOrderHandle;
125
184
  private _exitOrderHandle;
126
185
  private _exit;
127
186
  private _ordersToExit;
187
+ private _addExitPendingCloseOrders;
128
188
  private _stopProfit;
129
189
  private _stopLoss;
130
190
  private _trailStopLoss;
131
191
  private _processExitOnClose;
132
192
  private _processExitOrders;
133
193
  private _processOrder;
194
+ private _calcPercent;
195
+ private _getCommission;
196
+ private _calcCurrentOrder;
134
197
  private _isNaN;
135
198
  }
136
199
  export {};
@@ -0,0 +1,16 @@
1
+ export declare class Barstate {
2
+ private _isMarketOpen;
3
+ private _currentBarIndex;
4
+ private _totalBarIndex;
5
+ private _isRealTimeBar;
6
+ private _preBarIndex;
7
+ constructor();
8
+ update(currentBarIndex: number, totalBarIndex: number, isRealTimeBar: boolean, isMarketOpen: boolean): void;
9
+ get isnew(): boolean;
10
+ get islast(): boolean;
11
+ get isfirst(): boolean;
12
+ get ishistory(): boolean;
13
+ get isrealtime(): boolean;
14
+ get isconfirmed(): boolean;
15
+ get islastconfirmedhistory(): boolean;
16
+ }
@@ -0,0 +1,5 @@
1
+ export { Barstate } from './barstate';
2
+ export { Session } from './session';
3
+ export { Strategy } from './strategy';
4
+ export { Ta } from './ta';
5
+ export { Timeframe } from './timeframe';
@@ -0,0 +1,12 @@
1
+ import { BuiltInVariables } from "../buildInVariables";
2
+ export declare class Session {
3
+ private _variables;
4
+ constructor(variables: BuiltInVariables);
5
+ get isfirstbar(): boolean;
6
+ get isfirstbar_regular(): boolean;
7
+ get islastbar(): boolean;
8
+ get islastbar_regular(): boolean;
9
+ get ismarket(): boolean;
10
+ get ispostmarket(): boolean;
11
+ get ispremarket(): boolean;
12
+ }
@@ -0,0 +1,71 @@
1
+ import { IOrder, IStrategy } from "../buildInFuncNamespace";
2
+ import { BuiltInVariables } from "../buildInVariables";
3
+ export declare class Strategy {
4
+ private _orders;
5
+ private _historyOrders;
6
+ private _options?;
7
+ private _max_contracts_held_all;
8
+ private _max_contracts_held_long;
9
+ private _max_contracts_held_short;
10
+ private _max_drawdown;
11
+ private _max_runup;
12
+ private _max_runup_percent;
13
+ private _max_drawdown_percent;
14
+ private _variables;
15
+ private _netprofit;
16
+ private _eventrades;
17
+ private _avg_trade_percent?;
18
+ private _closedtrades;
19
+ private _losstrades;
20
+ private _grossloss;
21
+ private _grossloss_percent;
22
+ private _grossprofit;
23
+ private _grossprofit_percent;
24
+ private _wintrades;
25
+ private _opentrades_capital_held;
26
+ private _position_avg_price;
27
+ private _position_size;
28
+ constructor(variables: BuiltInVariables);
29
+ update(): void;
30
+ private _calcMaxDrawdownAndMaxRunup;
31
+ updateOrders(orders: IOrder[]): void;
32
+ private _calcMaxContracts;
33
+ updateHistoryOrders(orders: IOrder[]): void;
34
+ updateStrategyOptions(options: IStrategy): void;
35
+ get long(): string;
36
+ get short(): string;
37
+ get account_currency(): string;
38
+ get closedtrades(): number;
39
+ get opentrades(): number;
40
+ get opentrades_capital_held(): number;
41
+ get avg_losing_trade(): number | undefined;
42
+ get avg_losing_trade_percent(): number | undefined;
43
+ get avg_trade(): number | undefined;
44
+ get equity(): number;
45
+ get netprofit(): number;
46
+ get eventrades(): number;
47
+ get openprofit(): number;
48
+ get avg_trade_percent(): number | undefined;
49
+ get avg_winning_trade(): number | undefined;
50
+ get avg_winning_trade_percent(): number | undefined;
51
+ get initial_capital(): number;
52
+ get losstrades(): number;
53
+ get grossloss(): number;
54
+ get grossloss_percent(): number;
55
+ get grossprofit(): number;
56
+ get grossprofit_percent(): number;
57
+ get wintrades(): number;
58
+ get margin_liquidation_price(): number | undefined;
59
+ get max_contracts_held_all(): number;
60
+ get max_contracts_held_long(): number;
61
+ get max_contracts_held_short(): number;
62
+ get max_drawdown(): number;
63
+ get max_runup(): number;
64
+ get max_runup_percent(): number;
65
+ get max_drawdown_percent(): number;
66
+ get netprofit_percent(): number;
67
+ get openprofit_percent(): number;
68
+ get position_avg_price(): number;
69
+ get position_entry_name(): string | undefined;
70
+ get position_size(): number;
71
+ }
@@ -0,0 +1,28 @@
1
+ import { IKeyObjectValue } from "../../type";
2
+ export declare class Ta {
3
+ private _preAccdist;
4
+ private _preNvi;
5
+ private _prePvi;
6
+ private _preObv;
7
+ private _prePvt;
8
+ private _preWad;
9
+ private _preVwap;
10
+ private _preValue;
11
+ private _currentData;
12
+ private _preData;
13
+ constructor();
14
+ update(currentData: IKeyObjectValue): void;
15
+ get isRealTime(): boolean;
16
+ get accdist(): any;
17
+ get iii(): any;
18
+ get nvi(): any;
19
+ get wvad(): any;
20
+ get obv(): any;
21
+ get pvi(): any;
22
+ get tr(): any;
23
+ get pvt(): any;
24
+ get wad(): any;
25
+ get vwap(): any;
26
+ private _getNvi;
27
+ private _getPvi;
28
+ }
@@ -0,0 +1,16 @@
1
+ export declare class Timeframe {
2
+ private _period;
3
+ private _multiplier;
4
+ private _unit;
5
+ constructor();
6
+ update(period: string): void;
7
+ get isdaily(): boolean;
8
+ get isdwm(): boolean;
9
+ get isintraday(): boolean;
10
+ get isminutes(): boolean;
11
+ get ismonthly(): boolean;
12
+ get isseconds(): boolean;
13
+ get isweekly(): boolean;
14
+ get multiplier(): number;
15
+ get period(): string;
16
+ }
@@ -42,6 +42,8 @@ export declare const ERRORS_TIPS: {
42
42
  modifyGlobalVarErr: string;
43
43
  inputDefvalErr: string;
44
44
  objectIsNaErr: string;
45
+ buidinAssignErr: string;
46
+ buidinVarErr: string;
45
47
  };
46
48
  export declare const WARNING_TIPS: {
47
49
  repeatVar: string;
@@ -0,0 +1,28 @@
1
+ import { Strategy } from "../buildInFuncNamespace";
2
+ interface IArgs {
3
+ trade_num: number;
4
+ }
5
+ declare class Closedtrdes {
6
+ private _strategy;
7
+ constructor(strategy: Strategy);
8
+ commission({ trade_num }: IArgs): number;
9
+ entry_bar_index({ trade_num }: IArgs): number | undefined;
10
+ entry_comment({ trade_num }: IArgs): string;
11
+ entry_id({ trade_num }: IArgs): string;
12
+ entry_price({ trade_num }: IArgs): number | undefined;
13
+ entry_time({ trade_num }: IArgs): number | undefined;
14
+ exit_bar_index({ trade_num }: IArgs): number | undefined;
15
+ exit_comment({ trade_num }: IArgs): string | undefined;
16
+ exit_id({ trade_num }: IArgs): string | undefined;
17
+ exit_price({ trade_num }: IArgs): number | undefined;
18
+ exit_time({ trade_num }: IArgs): number | undefined;
19
+ max_drawdown({ trade_num }: IArgs): number | undefined;
20
+ max_drawdown_percent({ trade_num }: IArgs): number | undefined;
21
+ max_runup({ trade_num }: IArgs): number | undefined;
22
+ max_runup_percent({ trade_num }: IArgs): number | undefined;
23
+ profit({ trade_num }: IArgs): number | undefined;
24
+ profit_percent({ trade_num }: IArgs): number | undefined;
25
+ size({ trade_num }: IArgs): number;
26
+ private _verifyTradeNum;
27
+ }
28
+ export default Closedtrdes;
@@ -0,0 +1,4 @@
1
+ import Closedtrdes from "./closedtrades";
2
+ import Opentrades from "./opentrades";
3
+ import Risk from "./risk";
4
+ export { Closedtrdes, Opentrades, Risk };
@@ -0,0 +1,23 @@
1
+ import { Strategy } from "../buildInFuncNamespace";
2
+ interface IArgs {
3
+ trade_num: number;
4
+ }
5
+ declare class Opentrades {
6
+ private _strategy;
7
+ constructor(strategy: Strategy);
8
+ commission({ trade_num }: IArgs): number;
9
+ entry_bar_index({ trade_num }: IArgs): number | undefined;
10
+ entry_comment({ trade_num }: IArgs): string;
11
+ entry_id({ trade_num }: IArgs): string;
12
+ entry_price({ trade_num }: IArgs): number | undefined;
13
+ entry_time({ trade_num }: IArgs): number | undefined;
14
+ max_drawdown({ trade_num }: IArgs): number | undefined;
15
+ max_drawdown_percent({ trade_num }: IArgs): number | undefined;
16
+ max_runup({ trade_num }: IArgs): number | undefined;
17
+ max_runup_percent({ trade_num }: IArgs): number | undefined;
18
+ profit({ trade_num }: IArgs): number | undefined;
19
+ profit_percent({ trade_num }: IArgs): number | undefined;
20
+ size({ trade_num }: IArgs): number;
21
+ private _verifyTradeNum;
22
+ }
23
+ export default Opentrades;
@@ -0,0 +1,20 @@
1
+ import { Strategy } from "../buildInFuncNamespace";
2
+ import { VStrategy } from "../enum";
3
+ interface IRiskArgs {
4
+ value?: any;
5
+ count?: number;
6
+ alert_message?: string;
7
+ type?: VStrategy;
8
+ contracts?: number;
9
+ }
10
+ declare class Risk {
11
+ private _strategy;
12
+ constructor(strategy: Strategy);
13
+ allow_entry_in({ value }: IRiskArgs): void;
14
+ max_cons_loss_days({ count }: IRiskArgs): void;
15
+ max_drawdown({ value, type }: IRiskArgs): void;
16
+ max_intraday_filled_orders({ count }: IRiskArgs): void;
17
+ max_intraday_loss({ value, type }: IRiskArgs): void;
18
+ max_position_size({ contracts }: IRiskArgs): void;
19
+ }
20
+ export default Risk;
@@ -195,6 +195,7 @@ export default class ParserVisitor extends ParserUtils {
195
195
  private _setUserType;
196
196
  private _againAssignHandle;
197
197
  private _typeCheck;
198
+ private _getBuildVar;
198
199
  private _verifyName;
199
200
  private _judgeGatherValue;
200
201
  private _nameCheck;
@@ -15,6 +15,7 @@ export default class InitEditor {
15
15
  contentHeight: number;
16
16
  lineCount: number | undefined;
17
17
  };
18
+ setEditorLayout(height: number): void;
18
19
  private _init;
19
20
  private _setCursorPosition;
20
21
  private _register;