@guihz/trading-vue-editor-tes 0.1.16 → 0.1.18
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/lib/assets/{parserTccWorker-hZOaEksy.js → parserTccWorker-CXp94-Z9.js} +44024 -25371
- package/lib/assets/{scriptsRunWorker-DtD7_jXH.js → scriptsRunWorker-BQFRfD9L.js} +23471 -15028
- package/lib/components/editor/v5/parseScript/buildInConstants.d.ts +2 -0
- package/lib/components/editor/v5/parseScript/buildInVarNamespace/strategy.d.ts +0 -3
- package/lib/components/editor/v5/parseScript/parseToJs.d.ts +2 -0
- package/lib/components/editor/v6/config/monarchTokens.d.ts +205 -0
- package/lib/components/editor/v6/constants/contents_zh.d.ts +6 -0
- package/lib/components/editor/v6/constants/index.d.ts +41 -0
- package/lib/components/editor/v6/parseScript/buildInConstants.d.ts +310 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/array.d.ts +109 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/box.d.ts +83 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/chartPoint.d.ts +26 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/color.d.ts +25 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/errorListener.d.ts +9 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/index.d.ts +25 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/input.d.ts +57 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/label.d.ts +66 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/line.d.ts +74 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/linefill.d.ts +36 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/log.d.ts +39 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/map.d.ts +51 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/math.d.ts +49 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/matrix.d.ts +98 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/polyline.d.ts +32 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/runtime.d.ts +10 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/strategy.d.ts +278 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/strategyNew.d.ts +261 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/string.d.ts +55 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/syminfo.d.ts +9 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/ta.d.ts +125 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/table.d.ts +89 -0
- package/lib/components/editor/v6/parseScript/buildInFuncNamespace/timeframe.d.ts +22 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/barstate.d.ts +22 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/chart.d.ts +21 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/dividends.d.ts +8 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/earnings.d.ts +9 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/index.d.ts +9 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/session.d.ts +12 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/strategy.d.ts +144 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/syminfo.d.ts +49 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/ta.d.ts +32 -0
- package/lib/components/editor/v6/parseScript/buildInVarNamespace/timeframe.d.ts +16 -0
- package/lib/components/editor/v6/parseScript/constants.d.ts +135 -0
- package/lib/components/editor/v6/parseScript/constantsRun.d.ts +5 -0
- package/lib/components/editor/v6/parseScript/enum.d.ts +302 -0
- package/lib/components/editor/v6/parseScript/parseToJs.d.ts +78 -0
- package/lib/components/editor/v6/parseScript/parseToLibJs.d.ts +71 -0
- package/lib/components/editor/v6/parseScript/strategyNamespace/closedtrades.d.ts +28 -0
- package/lib/components/editor/v6/parseScript/strategyNamespace/index.d.ts +4 -0
- package/lib/components/editor/v6/parseScript/strategyNamespace/opentrades.d.ts +25 -0
- package/lib/components/editor/v6/parseScript/strategyNamespace/risk.d.ts +22 -0
- package/lib/components/editor/v6/parseScript/type.d.ts +40 -0
- package/lib/components/editor/v6/parseScript/userTypeClass.d.ts +12 -0
- package/lib/components/editor/v6/parseScript/utils.d.ts +25 -0
- package/lib/components/editor/v6/parseScript/visitorParser.d.ts +382 -0
- package/lib/components/editor/v6/parseScript/visitorUtils.d.ts +31 -0
- package/lib/components/editor/v6/parserTccWorker.d.ts +40 -0
- package/lib/components/editor/v6/scriptsRunWorker.d.ts +11 -0
- package/lib/components/editor/v6/tccParser/LexerBase.d.ts +19 -0
- package/lib/components/editor/v6/tccParser/tccScriptParserVisitor.d.ts +507 -0
- package/lib/index-C8vqcsNB.js +61958 -0
- package/lib/{monarchTokens-D-73EVQs.js → monarchTokens-BNkQaBBZ.js} +22 -22
- package/lib/monarchTokens-_UFEzBJ_.js +563 -0
- package/lib/packages/index.d.ts +1 -1
- package/lib/trading-vue-editor.es.packages.js +856 -843
- package/lib/trading-vue-editor.umd.packages.mjs +110 -45
- package/package.json +2 -2
- package/lib/{index-DLIhM_y0.js → index-Clupi1hX.js} +24 -24
@@ -0,0 +1,98 @@
|
|
1
|
+
import { VInsType, VSortOrder } from "../enum";
|
2
|
+
import { IPseudoArray } from "./array";
|
3
|
+
import { TccErrorListener } from '.';
|
4
|
+
interface IMatrixArgs {
|
5
|
+
rows?: number;
|
6
|
+
columns?: number;
|
7
|
+
initial_value?: any;
|
8
|
+
id?: IMatrix;
|
9
|
+
column?: number;
|
10
|
+
row?: number;
|
11
|
+
power?: number;
|
12
|
+
value?: number;
|
13
|
+
id1?: any;
|
14
|
+
id2?: any;
|
15
|
+
from_row?: number;
|
16
|
+
to_row?: number;
|
17
|
+
from_column?: number;
|
18
|
+
to_column?: number;
|
19
|
+
order?: VSortOrder;
|
20
|
+
array_id?: IPseudoArray;
|
21
|
+
row1?: number;
|
22
|
+
row2?: number;
|
23
|
+
column1?: number;
|
24
|
+
column2?: number;
|
25
|
+
type?: string;
|
26
|
+
}
|
27
|
+
export default class BuildInMatrix {
|
28
|
+
private _errorListener;
|
29
|
+
private _array;
|
30
|
+
constructor(errorListener: TccErrorListener);
|
31
|
+
new({ rows, columns, initial_value, type }: IMatrixArgs | undefined, posStr: string): IMatrix;
|
32
|
+
avg({ id }: IMatrixArgs): number | undefined;
|
33
|
+
col({ id, column }: IMatrixArgs, posStr: string): IPseudoArray | undefined;
|
34
|
+
det({ id }: IMatrixArgs): number | undefined;
|
35
|
+
get({ id, row, column }: IMatrixArgs, posStr: string): any;
|
36
|
+
inv({ id }: IMatrixArgs): IMatrix | undefined;
|
37
|
+
max({ id }: IMatrixArgs): any;
|
38
|
+
min({ id }: IMatrixArgs): any;
|
39
|
+
pow({ id, power }: IMatrixArgs): IMatrix | undefined;
|
40
|
+
row({ id, row }: IMatrixArgs, posStr: string): IPseudoArray | undefined;
|
41
|
+
set({ id, row, column, value }: IMatrixArgs, posStr: string): void;
|
42
|
+
private _setArr;
|
43
|
+
sum({ id1, id2 }: IMatrixArgs, posStr: string): IMatrix | undefined;
|
44
|
+
private _verifyColRowLen;
|
45
|
+
copy({ id }: IMatrixArgs): IMatrix | undefined;
|
46
|
+
diff({ id1, id2 }: IMatrixArgs, posStr: string): IMatrix | undefined;
|
47
|
+
rows({ id }: IMatrixArgs): number | undefined;
|
48
|
+
columns({ id }: IMatrixArgs): number | undefined;
|
49
|
+
fill({ id, value, from_row, to_row, from_column, to_column }: IMatrixArgs, posStr: string): void;
|
50
|
+
private _verifyToFrom;
|
51
|
+
kron({ id1, id2 }: IMatrixArgs): IMatrix | undefined;
|
52
|
+
mode({ id }: IMatrixArgs): any;
|
53
|
+
mult({ id1, id2 }: IMatrixArgs, posStr: string): IPseudoArray | IMatrix | undefined;
|
54
|
+
pinv({ id }: IMatrixArgs): IMatrix | undefined;
|
55
|
+
rank({ id }: IMatrixArgs): number | undefined;
|
56
|
+
sort({ id, column, order }: IMatrixArgs, posStr: string): void;
|
57
|
+
trace({ id }: IMatrixArgs): number | undefined;
|
58
|
+
concat({ id1, id2 }: IMatrixArgs, posStr: string): any;
|
59
|
+
median({ id }: IMatrixArgs): any;
|
60
|
+
add_col({ id, column, array_id }: IMatrixArgs, posStr: string): void;
|
61
|
+
add_row({ id, row, array_id }: IMatrixArgs, posStr: string): void;
|
62
|
+
is_zero({ id }: IMatrixArgs): boolean | undefined;
|
63
|
+
reshape({ id, rows, columns }: IMatrixArgs, posStr: string): void;
|
64
|
+
reverse({ id }: IMatrixArgs): void;
|
65
|
+
is_binary({ id }: IMatrixArgs): boolean | undefined;
|
66
|
+
is_square({ id }: IMatrixArgs): boolean | undefined;
|
67
|
+
submatrix({ id, from_row, to_row, from_column, to_column }: IMatrixArgs, posStr: string): IMatrix | undefined;
|
68
|
+
swap_rows({ id, row1, row2 }: IMatrixArgs, posStr: string): void;
|
69
|
+
transpose({ id }: IMatrixArgs): IMatrix | undefined;
|
70
|
+
remove_col({ id, column }: IMatrixArgs): IPseudoArray | undefined;
|
71
|
+
private _removeItem;
|
72
|
+
remove_row({ id, row }: IMatrixArgs): any[] | undefined;
|
73
|
+
eigenvalues({ id }: IMatrixArgs): IPseudoArray | undefined;
|
74
|
+
is_diagonal({ id }: IMatrixArgs): boolean | undefined;
|
75
|
+
is_identity({ id }: IMatrixArgs): boolean | undefined;
|
76
|
+
eigenvectors({ id }: IMatrixArgs): IMatrix | undefined;
|
77
|
+
is_symmetric({ id }: IMatrixArgs): boolean | undefined;
|
78
|
+
swap_columns({ id, column1, column2 }: IMatrixArgs, posStr: string): void;
|
79
|
+
is_stochastic({ id }: IMatrixArgs): boolean | undefined;
|
80
|
+
is_triangular({ id }: IMatrixArgs): boolean | undefined;
|
81
|
+
elements_count({ id }: IMatrixArgs): number | undefined;
|
82
|
+
private _maxCountVerify;
|
83
|
+
is_antidiagonal({ id }: IMatrixArgs): boolean | undefined;
|
84
|
+
is_antisymmetric({ id }: IMatrixArgs): boolean | undefined;
|
85
|
+
private _isUpperTriangular;
|
86
|
+
private _isLowerTriangular;
|
87
|
+
private _newMatrix;
|
88
|
+
private _matrixRank;
|
89
|
+
private _verifyScope;
|
90
|
+
}
|
91
|
+
interface IMatrix {
|
92
|
+
isMatrix: boolean;
|
93
|
+
typeName?: string;
|
94
|
+
type: VInsType;
|
95
|
+
_isNumber: boolean;
|
96
|
+
_value: any[][];
|
97
|
+
}
|
98
|
+
export {};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { TccErrorListener } from "./index";
|
2
|
+
import { BuiltInVariables } from "../buildInVariables";
|
3
|
+
import { VLineStyle, VXloc } from "../enum";
|
4
|
+
import { IDrawComponent } from "../type";
|
5
|
+
import { IKeyObjectValue } from "../../../type";
|
6
|
+
export interface IPolyline {
|
7
|
+
id?: string;
|
8
|
+
points?: IKeyObjectValue;
|
9
|
+
curved?: boolean;
|
10
|
+
closed?: boolean;
|
11
|
+
xloc?: VXloc;
|
12
|
+
line_color?: string;
|
13
|
+
fill_color?: string;
|
14
|
+
line_style?: VLineStyle;
|
15
|
+
line_width?: number;
|
16
|
+
}
|
17
|
+
type TPolylineArgs = Omit<IPolyline, 'id'> & {
|
18
|
+
id: IDrawComponent;
|
19
|
+
};
|
20
|
+
export default class BuildInPolyline {
|
21
|
+
private _variables;
|
22
|
+
private _errorListener;
|
23
|
+
private _defaultPolyline;
|
24
|
+
constructor(variables: BuiltInVariables, errorListener: TccErrorListener);
|
25
|
+
new(args: IPolyline, posStr: string): IDrawComponent;
|
26
|
+
private _verfiyArgs;
|
27
|
+
private _paramVerfiy;
|
28
|
+
updateId(id: IDrawComponent): string;
|
29
|
+
delete({ id }: TPolylineArgs): void;
|
30
|
+
}
|
31
|
+
export declare function createPolyline(key: string, data: IKeyObjectValue): IDrawComponent;
|
32
|
+
export {};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { TccErrorListener } from "./index";
|
2
|
+
interface IRuntimeArgs {
|
3
|
+
message: string;
|
4
|
+
}
|
5
|
+
export declare class Runtime {
|
6
|
+
private _errorListener;
|
7
|
+
constructor(errorListener: TccErrorListener);
|
8
|
+
error({ message }: IRuntimeArgs, posStr: string): void;
|
9
|
+
}
|
10
|
+
export {};
|
@@ -0,0 +1,278 @@
|
|
1
|
+
import { TccErrorListener } from ".";
|
2
|
+
import { IKeyObjectValue } from "../../../type";
|
3
|
+
import { BuiltInVariables } from "../buildInVariables";
|
4
|
+
import { VCommission, VDirection, VFormatType, VOca, VScale, VStrategy } from "../enum";
|
5
|
+
import { Closedtrdes, Opentrades, Risk } from '../strategyNamespace';
|
6
|
+
export interface IStrategy {
|
7
|
+
title?: string;
|
8
|
+
shorttitle?: string;
|
9
|
+
overlay?: boolean;
|
10
|
+
format?: VFormatType;
|
11
|
+
precision?: number;
|
12
|
+
scale?: VScale;
|
13
|
+
pyramiding?: number;
|
14
|
+
calc_on_order_fills?: boolean;
|
15
|
+
calc_on_every_tick?: boolean;
|
16
|
+
max_bars_back?: number;
|
17
|
+
backtest_fill_limits_assumption?: number;
|
18
|
+
default_qty_type?: VStrategy;
|
19
|
+
default_qty_value?: number;
|
20
|
+
initial_capital: number;
|
21
|
+
currency?: string;
|
22
|
+
slippage?: number;
|
23
|
+
commission_type?: VCommission;
|
24
|
+
commission_value?: number;
|
25
|
+
process_orders_on_close?: boolean;
|
26
|
+
close_entries_rule?: CloseEntriesRuleType;
|
27
|
+
margin_long?: number;
|
28
|
+
margin_short?: number;
|
29
|
+
explicit_plot_zorder?: boolean;
|
30
|
+
max_lines_count?: number;
|
31
|
+
max_labels_count?: number;
|
32
|
+
max_boxes_count?: number;
|
33
|
+
calc_bars_count?: number;
|
34
|
+
risk_free_rate?: number;
|
35
|
+
use_bar_magnifier?: boolean;
|
36
|
+
fill_orders_on_standard_ohlc?: boolean;
|
37
|
+
max_polylines_count?: number;
|
38
|
+
scriptType?: string;
|
39
|
+
direction_short_long?: boolean;
|
40
|
+
}
|
41
|
+
interface IArgs {
|
42
|
+
value?: number;
|
43
|
+
fill_price?: number;
|
44
|
+
}
|
45
|
+
interface IOrderArgs {
|
46
|
+
id: string;
|
47
|
+
direction: VDirection;
|
48
|
+
from_entry?: string;
|
49
|
+
qty?: number;
|
50
|
+
limit?: number;
|
51
|
+
loss?: number;
|
52
|
+
stop?: number;
|
53
|
+
oca_name?: string;
|
54
|
+
oca_type?: VOca;
|
55
|
+
comment?: string;
|
56
|
+
alert_message?: string;
|
57
|
+
disable_alert?: false;
|
58
|
+
qty_percent?: number;
|
59
|
+
immediately?: boolean;
|
60
|
+
trail_price?: number;
|
61
|
+
trail_points?: number;
|
62
|
+
trail_offset?: number;
|
63
|
+
profit?: number;
|
64
|
+
comment_profit?: string;
|
65
|
+
comment_loss?: string;
|
66
|
+
comment_trailing?: string;
|
67
|
+
last_commission?: number;
|
68
|
+
createTime?: number;
|
69
|
+
}
|
70
|
+
type PlaceOrderType = 'order' | 'entry' | 'exit' | 'close' | 'close_all' | 'close_all_short' | 'close_all_long';
|
71
|
+
export interface IOrder extends IOrderArgs {
|
72
|
+
isMarketPrice?: boolean;
|
73
|
+
out_id?: string;
|
74
|
+
in_index?: number;
|
75
|
+
out_index?: number;
|
76
|
+
in_price: number;
|
77
|
+
out_price?: number;
|
78
|
+
in_time?: number;
|
79
|
+
out_time?: number;
|
80
|
+
out_qty?: number;
|
81
|
+
out_comment?: string;
|
82
|
+
total_profit?: number;
|
83
|
+
max_profit?: number;
|
84
|
+
trading_loss?: number;
|
85
|
+
place_order_type?: PlaceOrderType;
|
86
|
+
position_close_type?: PlaceOrderType;
|
87
|
+
isDeal?: boolean;
|
88
|
+
exitIds?: string[];
|
89
|
+
active_price?: number;
|
90
|
+
trail_stop_price?: number;
|
91
|
+
hasOrder?: boolean;
|
92
|
+
isMarketPriceLimit?: boolean;
|
93
|
+
isMarketPriceStop?: boolean;
|
94
|
+
isCancel?: boolean;
|
95
|
+
close_qty?: number;
|
96
|
+
profit_percent?: number;
|
97
|
+
max_profit_percent?: number;
|
98
|
+
trading_loss_percent?: number;
|
99
|
+
commission?: number;
|
100
|
+
original_qty?: number;
|
101
|
+
in_low?: number;
|
102
|
+
in_high?: number;
|
103
|
+
out_low?: number;
|
104
|
+
out_high?: number;
|
105
|
+
isTiggerClose?: boolean;
|
106
|
+
entry_time?: number;
|
107
|
+
unid?: string;
|
108
|
+
realQty?: number;
|
109
|
+
isPartClose?: boolean;
|
110
|
+
occupancyQty?: number;
|
111
|
+
exitOrder?: IKeyObjectValue;
|
112
|
+
isEnd?: boolean;
|
113
|
+
}
|
114
|
+
interface IRisk {
|
115
|
+
allow_entry_in?: VDirection;
|
116
|
+
max_cons_loss_days?: number;
|
117
|
+
max_drawdown?: number;
|
118
|
+
max_drawdown_type?: VStrategy;
|
119
|
+
max_intraday_filled_orders?: number;
|
120
|
+
max_intraday_loss?: number;
|
121
|
+
max_intraday_loss_type?: VStrategy;
|
122
|
+
max_position_size?: number;
|
123
|
+
isDisabledOpen?: boolean;
|
124
|
+
lossDays?: number;
|
125
|
+
totalProfit?: number;
|
126
|
+
intradayOrders?: number;
|
127
|
+
isTemporaryBan?: boolean;
|
128
|
+
preNetprofit?: number;
|
129
|
+
}
|
130
|
+
interface IData {
|
131
|
+
close: number;
|
132
|
+
high: number;
|
133
|
+
low: number;
|
134
|
+
open: number;
|
135
|
+
}
|
136
|
+
interface IFillsData {
|
137
|
+
data?: IData;
|
138
|
+
tradeData?: IData;
|
139
|
+
index: number;
|
140
|
+
currentData?: IData;
|
141
|
+
}
|
142
|
+
type CloseEntriesRuleType = 'FIFO' | 'ANY';
|
143
|
+
export default class Strategy {
|
144
|
+
private _variables;
|
145
|
+
private _options;
|
146
|
+
private _totalChangeCapital;
|
147
|
+
private _historyOrder;
|
148
|
+
private _orders;
|
149
|
+
private _exitOrders;
|
150
|
+
private _pendingOrders;
|
151
|
+
private _mintick;
|
152
|
+
private _funcOptions;
|
153
|
+
private _pendingCloseOrders;
|
154
|
+
private _errorListener;
|
155
|
+
private _risk;
|
156
|
+
private _opentrades;
|
157
|
+
private _closedtrades;
|
158
|
+
private _riskNamespace;
|
159
|
+
private _updateOptions;
|
160
|
+
private _id;
|
161
|
+
private _maxDrawdownVerifyIndex;
|
162
|
+
calcOnOrderFillsData: IFillsData;
|
163
|
+
private _cacheArgs;
|
164
|
+
private _useSetArgs;
|
165
|
+
private _closeOrderList;
|
166
|
+
private _historyOrdersShard;
|
167
|
+
private _notCloseHistoryOrders;
|
168
|
+
private _historyOrderLen;
|
169
|
+
constructor(variables: BuiltInVariables, options: IKeyObjectValue, mintick: number, errorListener: TccErrorListener, id: string);
|
170
|
+
get _strategyCacheData(): IKeyObjectValue;
|
171
|
+
set _strategyCacheData(val: IKeyObjectValue);
|
172
|
+
get orders(): IOrder[];
|
173
|
+
get historyOrders(): IOrder[];
|
174
|
+
get _freezeCapital(): number;
|
175
|
+
get opentrades(): Opentrades;
|
176
|
+
get closedtrades(): Closedtrdes;
|
177
|
+
get risk(): Risk;
|
178
|
+
get isCalcOnEveryTick(): boolean | undefined;
|
179
|
+
updateOptions(options?: IStrategy): void;
|
180
|
+
update(): void;
|
181
|
+
calcCurrentOrder(): void;
|
182
|
+
updateRisk(risk: IRisk): void;
|
183
|
+
endExecution(): void;
|
184
|
+
private _maxIntradayLoss;
|
185
|
+
private _maxIntradayFilledOrdersVerify;
|
186
|
+
private _maxConsLossDaysVerify;
|
187
|
+
private _maxDrawdownVerify;
|
188
|
+
private _riskTouchOff;
|
189
|
+
strategy(args: IKeyObjectValue, posStr: string): void;
|
190
|
+
private _updateArgToOptions;
|
191
|
+
order(args: IOrderArgs, posStr: string): void;
|
192
|
+
entry(args: IOrderArgs, posStr: string): void;
|
193
|
+
close(args: IOrder, posStr: string): void;
|
194
|
+
close_all(args: IOrder, posStr: string): void;
|
195
|
+
close_all_long(args: IOrder, posStr: string): void;
|
196
|
+
close_all_short(args: IOrder, posStr: string): void;
|
197
|
+
cancel({ id }: {
|
198
|
+
id: string;
|
199
|
+
}, posStr: string): void;
|
200
|
+
cancel_all(posStr: string): void;
|
201
|
+
exit(args: IOrderArgs, posStr: string): void;
|
202
|
+
convert_to_account({ value }: IArgs, posStr: string): number | undefined;
|
203
|
+
convert_to_symbol({ value }: IArgs, posStr: string): number | undefined;
|
204
|
+
default_entry_qty({ fill_price }: IArgs, posStr: string): number;
|
205
|
+
private _calcDefaultQty;
|
206
|
+
private _calcExitQty;
|
207
|
+
private _getCommQty;
|
208
|
+
private _getLen;
|
209
|
+
private _getCapital;
|
210
|
+
private _calcProfitAndLoss;
|
211
|
+
private _calcProfitAndLossHandle;
|
212
|
+
private _calcOrderPercent;
|
213
|
+
private _calcLiquidate;
|
214
|
+
private _marginCallOrders;
|
215
|
+
private _orderHandle;
|
216
|
+
private _orderOnCloseHandle;
|
217
|
+
private _judgeCapitalEnough;
|
218
|
+
private _getOrderProfit;
|
219
|
+
private _ocaGroupVerify;
|
220
|
+
private _processOrders;
|
221
|
+
private _addPendingOrders;
|
222
|
+
private _orderArgsParse;
|
223
|
+
private _entryHandle;
|
224
|
+
private _entryOnCloseHandle;
|
225
|
+
private _getOrders;
|
226
|
+
private _entryOrder;
|
227
|
+
private _getAvailablePositionSize;
|
228
|
+
private _getEntryOrders;
|
229
|
+
private _addPendingEntry;
|
230
|
+
private _closeAllOrders;
|
231
|
+
private _closeAllPartOrders;
|
232
|
+
private _closeOrders;
|
233
|
+
private _closeOrder;
|
234
|
+
private _exitOrdersHandle;
|
235
|
+
private _updateExitOrders;
|
236
|
+
private _orderInExitHandle;
|
237
|
+
private _executesSort;
|
238
|
+
private _getLimitPrice;
|
239
|
+
private _getStopPrice;
|
240
|
+
private _getTrailStopPrice;
|
241
|
+
private _ordersHandle;
|
242
|
+
private _calcTrailStopPrice;
|
243
|
+
private _pendingOrderHandle;
|
244
|
+
private _pendingOrderSort;
|
245
|
+
private _pendingCloseOrderHandle;
|
246
|
+
private _onCloseOrderHandle;
|
247
|
+
private _entryOrderHandle;
|
248
|
+
private _orderOrderHandle;
|
249
|
+
private _getHisOrderSurplusQty;
|
250
|
+
private _getCloseOrders;
|
251
|
+
private _closeOrderHandle;
|
252
|
+
private _processCloseOrdersFIFO;
|
253
|
+
private _processCloseOrders;
|
254
|
+
private _exitOrderHandle;
|
255
|
+
private _getUnCloseOrders;
|
256
|
+
private _exit;
|
257
|
+
private _updateExitOrder;
|
258
|
+
private _calcUpdateExitOrderQty;
|
259
|
+
private _calcExitOrderQty;
|
260
|
+
private _ordersToExit;
|
261
|
+
private _calcLimitPrice;
|
262
|
+
private _calcStopPrice;
|
263
|
+
private _calcActivePrice;
|
264
|
+
private _stopProfit;
|
265
|
+
private _stopLoss;
|
266
|
+
private _trailStopLoss;
|
267
|
+
private _processExitOnClose;
|
268
|
+
private _processExitOrders;
|
269
|
+
private _processOrder;
|
270
|
+
private _calcPercent;
|
271
|
+
private _getCommission;
|
272
|
+
private _calcCurrentOrder;
|
273
|
+
private _calcOrderFillsHandle;
|
274
|
+
private _isNaN;
|
275
|
+
private _paramVerfiy;
|
276
|
+
_verfiyRequestFunc(posStr: string, name: string): void;
|
277
|
+
}
|
278
|
+
export {};
|
@@ -0,0 +1,261 @@
|
|
1
|
+
import { TccErrorListener } from ".";
|
2
|
+
import { IKeyObjectValue } from "../../../type";
|
3
|
+
import { BuiltInVariables } from "../buildInVariables";
|
4
|
+
import { VCommission, VDirection, VFormatType, VOca, VScale, VStrategy } from "../enum";
|
5
|
+
import { Closedtrdes, Opentrades, Risk } from '../strategyNamespace';
|
6
|
+
export interface IStrategy {
|
7
|
+
title?: string;
|
8
|
+
shorttitle?: string;
|
9
|
+
overlay?: boolean;
|
10
|
+
format?: VFormatType;
|
11
|
+
precision?: number;
|
12
|
+
scale?: VScale;
|
13
|
+
pyramiding?: number;
|
14
|
+
calc_on_order_fills?: boolean;
|
15
|
+
calc_on_every_tick?: boolean;
|
16
|
+
max_bars_back?: number;
|
17
|
+
backtest_fill_limits_assumption?: number;
|
18
|
+
default_qty_type?: VStrategy;
|
19
|
+
default_qty_value?: number;
|
20
|
+
initial_capital: number;
|
21
|
+
currency?: string;
|
22
|
+
slippage?: number;
|
23
|
+
commission_type?: VCommission;
|
24
|
+
commission_value?: number;
|
25
|
+
process_orders_on_close?: boolean;
|
26
|
+
close_entries_rule?: CloseEntriesRuleType;
|
27
|
+
margin_long?: number;
|
28
|
+
margin_short?: number;
|
29
|
+
explicit_plot_zorder?: boolean;
|
30
|
+
max_lines_count?: number;
|
31
|
+
max_labels_count?: number;
|
32
|
+
max_boxes_count?: number;
|
33
|
+
calc_bars_count?: number;
|
34
|
+
risk_free_rate?: number;
|
35
|
+
use_bar_magnifier?: boolean;
|
36
|
+
fill_orders_on_standard_ohlc?: boolean;
|
37
|
+
max_polylines_count?: number;
|
38
|
+
scriptType?: string;
|
39
|
+
direction_short_long?: boolean;
|
40
|
+
}
|
41
|
+
interface IArgs {
|
42
|
+
value?: number;
|
43
|
+
fill_price?: number;
|
44
|
+
}
|
45
|
+
interface IOrderArgs {
|
46
|
+
id: string;
|
47
|
+
direction: VDirection;
|
48
|
+
from_entry?: string;
|
49
|
+
qty?: number;
|
50
|
+
limit?: number;
|
51
|
+
loss?: number;
|
52
|
+
stop?: number;
|
53
|
+
oca_name?: string;
|
54
|
+
oca_type?: VOca;
|
55
|
+
comment?: string;
|
56
|
+
alert_message?: string;
|
57
|
+
disable_alert?: false;
|
58
|
+
qty_percent?: number;
|
59
|
+
immediately?: boolean;
|
60
|
+
trail_price?: number;
|
61
|
+
trail_points?: number;
|
62
|
+
trail_offset?: number;
|
63
|
+
profit?: number;
|
64
|
+
comment_profit?: string;
|
65
|
+
comment_loss?: string;
|
66
|
+
comment_trailing?: string;
|
67
|
+
last_commission?: number;
|
68
|
+
}
|
69
|
+
type PlaceOrderType = 'order' | 'entry' | 'exit' | 'close' | 'close_all' | 'close_all_short' | 'close_all_long';
|
70
|
+
export interface IOrder extends IOrderArgs {
|
71
|
+
isMarketPrice?: boolean;
|
72
|
+
out_id?: string;
|
73
|
+
in_index?: number;
|
74
|
+
out_index?: number;
|
75
|
+
in_price: number;
|
76
|
+
out_price?: number;
|
77
|
+
in_time?: number;
|
78
|
+
out_time?: number;
|
79
|
+
out_qty?: number;
|
80
|
+
out_comment?: string;
|
81
|
+
total_profit?: number;
|
82
|
+
max_profit?: number;
|
83
|
+
trading_loss?: number;
|
84
|
+
place_order_type?: PlaceOrderType;
|
85
|
+
position_close_type?: PlaceOrderType;
|
86
|
+
isDeal?: boolean;
|
87
|
+
exitIds?: string[];
|
88
|
+
active_price?: number;
|
89
|
+
trail_stop_price?: number;
|
90
|
+
hasOrder?: boolean;
|
91
|
+
isMarketPriceLimit?: boolean;
|
92
|
+
isMarketPriceStop?: boolean;
|
93
|
+
isCancel?: boolean;
|
94
|
+
close_qty?: number;
|
95
|
+
profit_percent?: number;
|
96
|
+
max_profit_percent?: number;
|
97
|
+
trading_loss_percent?: number;
|
98
|
+
commission?: number;
|
99
|
+
original_qty?: number;
|
100
|
+
in_low?: number;
|
101
|
+
in_high?: number;
|
102
|
+
out_low?: number;
|
103
|
+
out_high?: number;
|
104
|
+
isTiggerClose?: boolean;
|
105
|
+
entry_time?: number;
|
106
|
+
unid?: string;
|
107
|
+
}
|
108
|
+
interface IRisk {
|
109
|
+
allow_entry_in?: VDirection;
|
110
|
+
max_cons_loss_days?: number;
|
111
|
+
max_drawdown?: number;
|
112
|
+
max_drawdown_type?: VStrategy;
|
113
|
+
max_intraday_filled_orders?: number;
|
114
|
+
max_intraday_loss?: number;
|
115
|
+
max_intraday_loss_type?: VStrategy;
|
116
|
+
max_position_size?: number;
|
117
|
+
isDisabledOpen?: boolean;
|
118
|
+
lossDays?: number;
|
119
|
+
totalProfit?: number;
|
120
|
+
intradayOrders?: number;
|
121
|
+
isTemporaryBan?: boolean;
|
122
|
+
preNetprofit?: number;
|
123
|
+
}
|
124
|
+
interface IData {
|
125
|
+
close: number;
|
126
|
+
high: number;
|
127
|
+
low: number;
|
128
|
+
open: number;
|
129
|
+
}
|
130
|
+
interface IFillsData {
|
131
|
+
data?: IData;
|
132
|
+
tradeData?: IData;
|
133
|
+
index: number;
|
134
|
+
currentData?: IData;
|
135
|
+
}
|
136
|
+
type CloseEntriesRuleType = 'FIFO' | 'ANY';
|
137
|
+
export default class Strategy {
|
138
|
+
private _variables;
|
139
|
+
private _options;
|
140
|
+
private _totalChangeCapital;
|
141
|
+
private _historyOrder;
|
142
|
+
private _orders;
|
143
|
+
private _exitOrders;
|
144
|
+
private _pendingOrders;
|
145
|
+
private _mintick;
|
146
|
+
private _funcOptions;
|
147
|
+
private _pendingCloseOrders;
|
148
|
+
private _errorListener;
|
149
|
+
private _risk;
|
150
|
+
private _opentrades;
|
151
|
+
private _closedtrades;
|
152
|
+
private _riskNamespace;
|
153
|
+
private _updateOptions;
|
154
|
+
private _id;
|
155
|
+
private _maxDrawdownVerifyIndex;
|
156
|
+
calcOnOrderFillsData: IFillsData;
|
157
|
+
private _cacheArgs;
|
158
|
+
private _useSetArgs;
|
159
|
+
private _posOrders;
|
160
|
+
constructor(variables: BuiltInVariables, options: IKeyObjectValue, mintick: number, errorListener: TccErrorListener, id: string);
|
161
|
+
get _strategyCacheData(): IKeyObjectValue;
|
162
|
+
set _strategyCacheData(val: IKeyObjectValue);
|
163
|
+
get orders(): IOrder[];
|
164
|
+
get historyOrders(): IOrder[];
|
165
|
+
get _freezeCapital(): number;
|
166
|
+
get opentrades(): Opentrades;
|
167
|
+
get closedtrades(): Closedtrdes;
|
168
|
+
get risk(): Risk;
|
169
|
+
get isCalcOnEveryTick(): boolean | undefined;
|
170
|
+
updateOptions(options?: IStrategy): void;
|
171
|
+
update(): void;
|
172
|
+
calcCurrentOrder(): void;
|
173
|
+
updateRisk(risk: IRisk): void;
|
174
|
+
endExecution(): void;
|
175
|
+
private _maxIntradayLoss;
|
176
|
+
private _maxIntradayFilledOrdersVerify;
|
177
|
+
private _maxConsLossDaysVerify;
|
178
|
+
private _maxDrawdownVerify;
|
179
|
+
private _riskTouchOff;
|
180
|
+
strategy(args: IKeyObjectValue, posStr: string): void;
|
181
|
+
private _updateArgToOptions;
|
182
|
+
order(args: IOrderArgs, posStr: string): void;
|
183
|
+
entry(args: IOrderArgs, posStr: string): void;
|
184
|
+
close(args: IOrder, posStr: string): void;
|
185
|
+
close_all(args: IOrder, posStr: string): void;
|
186
|
+
close_all_long(args: IOrder, posStr: string): void;
|
187
|
+
close_all_short(args: IOrder, posStr: string): void;
|
188
|
+
cancel({ id }: {
|
189
|
+
id: string;
|
190
|
+
}, posStr: string): void;
|
191
|
+
cancel_all(posStr: string): void;
|
192
|
+
exit(args: IOrderArgs, posStr: string): void;
|
193
|
+
convert_to_account({ value }: IArgs, posStr: string): number | undefined;
|
194
|
+
convert_to_symbol({ value }: IArgs, posStr: string): number | undefined;
|
195
|
+
default_entry_qty({ fill_price }: IArgs, posStr: string): number;
|
196
|
+
private _calcDefaultQty;
|
197
|
+
private _calcExitQty;
|
198
|
+
private _getCommQty;
|
199
|
+
private _getLen;
|
200
|
+
private _getCapital;
|
201
|
+
private _calcProfitAndLoss;
|
202
|
+
private _calcProfitAndLossHandle;
|
203
|
+
private _calcOrderPercent;
|
204
|
+
private _calcLiquidate;
|
205
|
+
private _marginCallOrders;
|
206
|
+
private _orderHandle;
|
207
|
+
private _orderOnCloseHandle;
|
208
|
+
private _judgeCapitalEnough;
|
209
|
+
private _getOrderProfit;
|
210
|
+
private _ocaGroupVerify;
|
211
|
+
private _processOrders;
|
212
|
+
private _addPendingOrders;
|
213
|
+
private _orderArgsParse;
|
214
|
+
private _entryHandle;
|
215
|
+
private _entryOnCloseHandle;
|
216
|
+
private _getOrders;
|
217
|
+
private _entryOrder;
|
218
|
+
private _getAvailablePositionSize;
|
219
|
+
private _getEntryOrders;
|
220
|
+
private _addPendingEntry;
|
221
|
+
private _closeAllOrders;
|
222
|
+
private _closeAllPartOrders;
|
223
|
+
private _closeOrders;
|
224
|
+
private _closeOrder;
|
225
|
+
private _exitOrdersHandle;
|
226
|
+
private _executesSort;
|
227
|
+
private _getLimitPrice;
|
228
|
+
private _getStopPrice;
|
229
|
+
private _getTrailStopPrice;
|
230
|
+
private _ordersHandle;
|
231
|
+
private _calcTrailStopPrice;
|
232
|
+
private _pendingOrderHandle;
|
233
|
+
private _pendingOrderSort;
|
234
|
+
private _pendingCloseOrderHandle;
|
235
|
+
private _onCloseOrderHandle;
|
236
|
+
private _entryOrderHandle;
|
237
|
+
private _orderOrderHandle;
|
238
|
+
private _getCloseOrders;
|
239
|
+
private _closeOrderHandle;
|
240
|
+
private _processCloseOrders;
|
241
|
+
private _exitOrderHandle;
|
242
|
+
private _exit;
|
243
|
+
private _updateExitOrders;
|
244
|
+
private _calcExitOrderQty;
|
245
|
+
private _ordersToExit;
|
246
|
+
private _addExitPendingCloseOrders;
|
247
|
+
private _stopProfit;
|
248
|
+
private _stopLoss;
|
249
|
+
private _trailStopLoss;
|
250
|
+
private _processExitOnClose;
|
251
|
+
private _processExitOrders;
|
252
|
+
private _processOrder;
|
253
|
+
private _calcPercent;
|
254
|
+
private _getCommission;
|
255
|
+
private _calcCurrentOrder;
|
256
|
+
private _calcOrderFillsHandle;
|
257
|
+
private _isNaN;
|
258
|
+
private _paramVerfiy;
|
259
|
+
_verfiyRequestFunc(posStr: string, name: string): void;
|
260
|
+
}
|
261
|
+
export {};
|