@backtest-kit/ui 12.8.0 → 13.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/build/index.cjs +560 -0
- package/build/index.mjs +561 -1
- package/build/modules/frontend/build/assets/{Article-Da78GEhK.js → Article-CcCiTpSc.js} +1 -1
- package/build/modules/frontend/build/assets/{Background-0ACHD5B6.js → Background-DMirKacq.js} +1 -1
- package/build/modules/frontend/build/assets/{IconPhoto-BPAbqALJ.js → IconPhoto-BxDqzGvT.js} +1 -1
- package/build/modules/frontend/build/assets/{KeyboardArrowLeft-YMeBM3Q3.js → KeyboardArrowLeft-Dko7SALS.js} +1 -1
- package/build/modules/frontend/build/assets/{PictureAsPdfOutlined-CA7hIpf4.js → PictureAsPdfOutlined-Dmg5gexr.js} +1 -1
- package/build/modules/frontend/build/assets/{Refresh-CTa-W1su.js → Refresh-CBda8h_u.js} +1 -1
- package/build/modules/frontend/build/assets/emitters-DfGc10Om.js +1 -0
- package/build/modules/frontend/build/assets/{hasRouteMatch-Dz1eRfX0.js → hasRouteMatch-BSKJnbXT.js} +1 -1
- package/build/modules/frontend/build/assets/{html2canvas-CuvtHslW.js → html2canvas-DksZ0g2p.js} +1 -1
- package/build/modules/frontend/build/assets/index-6eAhZo78.js +1 -0
- package/build/modules/frontend/build/assets/{index-fv31BaKN.js → index-B4z69zXs.js} +14 -14
- package/build/modules/frontend/build/assets/{index-C0qezHrv.js → index-BfM_1muQ.js} +1 -1
- package/build/modules/frontend/build/assets/{index-Dye20IcA.js → index-C9jW4IvD.js} +1 -1
- package/build/modules/frontend/build/assets/{index-CGTByLJp.js → index-CAviDo-e.js} +1 -1
- package/build/modules/frontend/build/assets/index-CGJADttI.js +1 -0
- package/build/modules/frontend/build/assets/{index-DO3lwaMI.js → index-CJGWLPLp.js} +1 -1
- package/build/modules/frontend/build/assets/{index-jg7SuL7J.js → index-CeAm-0jJ.js} +1 -1
- package/build/modules/frontend/build/assets/{index-DCkqZSEX.js → index-CikHR8SM.js} +1 -1
- package/build/modules/frontend/build/assets/{index-C19KVXyR.js → index-CnaffmZK.js} +1 -1
- package/build/modules/frontend/build/assets/index-D3OaZoyW.js +1 -0
- package/build/modules/frontend/build/assets/{index-tg1njHyT.js → index-DqktEUrK.js} +1 -1
- package/build/modules/frontend/build/assets/{index--CAl9k-j.js → index-kU3NMO0i.js} +1 -1
- package/build/modules/frontend/build/assets/{index.es-DtUP6yiZ.js → index.es-Q_57HRa4.js} +2 -2
- package/build/modules/frontend/build/assets/{markdownit-Bj4vpJSk.js → markdownit-BiE4Ht5c.js} +1 -1
- package/build/modules/frontend/build/index.html +1 -1
- package/package.json +3 -3
- package/types.d.ts +85 -0
- package/build/modules/frontend/build/assets/emitters-CwOzUPwS.js +0 -1
- package/build/modules/frontend/build/assets/index-C5c7YQ-Q.js +0 -1
- package/build/modules/frontend/build/assets/index-CgLCD4kl.js +0 -1
- package/build/modules/frontend/build/assets/index-EnF3Est3.js +0 -1
package/build/index.cjs
CHANGED
|
@@ -108,6 +108,7 @@ const mockServices$1 = {
|
|
|
108
108
|
environmentMockService: Symbol("environmentMockService"),
|
|
109
109
|
setupMockService: Symbol("setupMockService"),
|
|
110
110
|
runtimeMockService: Symbol("runtimeMockService"),
|
|
111
|
+
controlMockService: Symbol("controlMockService"),
|
|
111
112
|
};
|
|
112
113
|
const viewServices$1 = {
|
|
113
114
|
notificationViewService: Symbol("notificationViewService"),
|
|
@@ -123,6 +124,7 @@ const viewServices$1 = {
|
|
|
123
124
|
environmentViewService: Symbol("environmentViewService"),
|
|
124
125
|
setupViewService: Symbol("setupViewService"),
|
|
125
126
|
runtimeViewService: Symbol("runtimeViewService"),
|
|
127
|
+
controlViewService: Symbol("controlViewService"),
|
|
126
128
|
};
|
|
127
129
|
const TYPES = {
|
|
128
130
|
...baseServices$1,
|
|
@@ -2197,6 +2199,222 @@ class RuntimeViewService {
|
|
|
2197
2199
|
}
|
|
2198
2200
|
}
|
|
2199
2201
|
|
|
2202
|
+
const MOCK_STRATEGY_PATH = "./mock/strategy.json";
|
|
2203
|
+
const MOCK_STRATEGY_INFO_PATH = "./mock/strategy-info.json";
|
|
2204
|
+
const READ_STRATEGY_FN = functoolsKit.singleshot(async () => {
|
|
2205
|
+
const data = await fs.readFile(MOCK_STRATEGY_PATH, "utf-8");
|
|
2206
|
+
return JSON.parse(data);
|
|
2207
|
+
});
|
|
2208
|
+
const READ_STRATEGY_INFO_FN = functoolsKit.singleshot(async () => {
|
|
2209
|
+
const data = await fs.readFile(MOCK_STRATEGY_INFO_PATH, "utf-8");
|
|
2210
|
+
return JSON.parse(data);
|
|
2211
|
+
});
|
|
2212
|
+
class ControlMockService {
|
|
2213
|
+
constructor() {
|
|
2214
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
2215
|
+
this.getStatus = async (symbol, context) => {
|
|
2216
|
+
this.loggerService.log("controlMockService getStatus", {
|
|
2217
|
+
symbol,
|
|
2218
|
+
context,
|
|
2219
|
+
});
|
|
2220
|
+
const strategyInfo = await READ_STRATEGY_INFO_FN();
|
|
2221
|
+
const pendingSignal = await READ_STRATEGY_FN();
|
|
2222
|
+
const currentPrice = pendingSignal?.pnl?.priceClose ?? pendingSignal?.priceOpen ?? 0;
|
|
2223
|
+
return { strategyInfo, pendingSignal, currentPrice };
|
|
2224
|
+
};
|
|
2225
|
+
this.getAveragePrice = async (symbol, context) => {
|
|
2226
|
+
this.loggerService.log("controlMockService getAveragePrice", {
|
|
2227
|
+
symbol,
|
|
2228
|
+
context,
|
|
2229
|
+
});
|
|
2230
|
+
const pendingSignal = await READ_STRATEGY_FN();
|
|
2231
|
+
return pendingSignal?.pnl?.priceClose ?? pendingSignal?.priceOpen ?? 0;
|
|
2232
|
+
};
|
|
2233
|
+
this.commitOpenPending = async (symbol, context, dto) => {
|
|
2234
|
+
this.loggerService.log("controlMockService commitOpenPending", {
|
|
2235
|
+
symbol,
|
|
2236
|
+
context,
|
|
2237
|
+
dto,
|
|
2238
|
+
});
|
|
2239
|
+
};
|
|
2240
|
+
this.commitAverageBuy = async (symbol, context, dto) => {
|
|
2241
|
+
this.loggerService.log("controlMockService commitAverageBuy", {
|
|
2242
|
+
symbol,
|
|
2243
|
+
context,
|
|
2244
|
+
dto,
|
|
2245
|
+
});
|
|
2246
|
+
};
|
|
2247
|
+
this.commitClosePending = async (symbol, context, dto) => {
|
|
2248
|
+
this.loggerService.log("controlMockService commitClosePending", {
|
|
2249
|
+
symbol,
|
|
2250
|
+
context,
|
|
2251
|
+
dto,
|
|
2252
|
+
});
|
|
2253
|
+
};
|
|
2254
|
+
this.commitBreakeven = async (symbol, context) => {
|
|
2255
|
+
this.loggerService.log("controlMockService commitBreakeven", {
|
|
2256
|
+
symbol,
|
|
2257
|
+
context,
|
|
2258
|
+
});
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
class ControlViewService {
|
|
2264
|
+
constructor() {
|
|
2265
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
2266
|
+
this.controlMockService = inject(TYPES.controlMockService);
|
|
2267
|
+
this.getStatus = async (symbol, context) => {
|
|
2268
|
+
this.loggerService.log("controlViewService getStatus", {
|
|
2269
|
+
symbol,
|
|
2270
|
+
context,
|
|
2271
|
+
});
|
|
2272
|
+
if (CC_ENABLE_MOCK) {
|
|
2273
|
+
return await this.controlMockService.getStatus(symbol, context);
|
|
2274
|
+
}
|
|
2275
|
+
const liveList = await BacktestKit.Live.list();
|
|
2276
|
+
const liveTarget = liveList.find((live) => live.symbol === symbol);
|
|
2277
|
+
if (liveTarget) {
|
|
2278
|
+
const currentPrice = await BacktestKit.Exchange.getAveragePrice(symbol, {
|
|
2279
|
+
exchangeName: liveTarget.exchangeName,
|
|
2280
|
+
});
|
|
2281
|
+
const strategy = await BacktestKit.Live.getStrategyStatus(symbol, context);
|
|
2282
|
+
const pending = await BacktestKit.Live.getPendingSignal(symbol, currentPrice, context);
|
|
2283
|
+
return { strategyInfo: strategy, pendingSignal: pending, currentPrice };
|
|
2284
|
+
}
|
|
2285
|
+
throw new Error("ControlViewService getStatus live target not found");
|
|
2286
|
+
};
|
|
2287
|
+
this.getAveragePrice = async (symbol, context) => {
|
|
2288
|
+
this.loggerService.log("controlViewService getAveragePrice", {
|
|
2289
|
+
symbol,
|
|
2290
|
+
context,
|
|
2291
|
+
});
|
|
2292
|
+
if (CC_ENABLE_MOCK) {
|
|
2293
|
+
return await this.controlMockService.getAveragePrice(symbol, context);
|
|
2294
|
+
}
|
|
2295
|
+
const liveList = await BacktestKit.Live.list();
|
|
2296
|
+
const liveTarget = liveList.find((live) => live.symbol === symbol);
|
|
2297
|
+
if (liveTarget) {
|
|
2298
|
+
return await BacktestKit.Exchange.getAveragePrice(symbol, {
|
|
2299
|
+
exchangeName: liveTarget.exchangeName,
|
|
2300
|
+
});
|
|
2301
|
+
}
|
|
2302
|
+
throw new Error("ControlViewService getAveragePrice live target not found");
|
|
2303
|
+
};
|
|
2304
|
+
this.commitOpenPending = async (symbol, context, dto) => {
|
|
2305
|
+
this.loggerService.log("controlViewService commitOpenPending", {
|
|
2306
|
+
symbol,
|
|
2307
|
+
context,
|
|
2308
|
+
dto,
|
|
2309
|
+
});
|
|
2310
|
+
if (CC_ENABLE_MOCK) {
|
|
2311
|
+
return await this.controlMockService.commitOpenPending(symbol, context, dto);
|
|
2312
|
+
}
|
|
2313
|
+
const liveList = await BacktestKit.Live.list();
|
|
2314
|
+
const liveTarget = liveList.find((live) => live.symbol === symbol);
|
|
2315
|
+
if (liveTarget) {
|
|
2316
|
+
const currentPrice = await BacktestKit.Exchange.getAveragePrice(symbol, {
|
|
2317
|
+
exchangeName: liveTarget.exchangeName,
|
|
2318
|
+
});
|
|
2319
|
+
const pending = await BacktestKit.Live.getPendingSignal(symbol, currentPrice, context);
|
|
2320
|
+
const config = BacktestKit.getConfig();
|
|
2321
|
+
if (pending) {
|
|
2322
|
+
throw new Error("ControlViewService commitOpenPending already have pending signal");
|
|
2323
|
+
}
|
|
2324
|
+
return await BacktestKit.Live.commitCreateSignal(symbol, context, {
|
|
2325
|
+
...BacktestKit.Position.moonbag({
|
|
2326
|
+
position: dto.position,
|
|
2327
|
+
currentPrice,
|
|
2328
|
+
percentStopLoss: config.CC_MAX_STOPLOSS_DISTANCE_PERCENT
|
|
2329
|
+
}),
|
|
2330
|
+
cost: dto.cost,
|
|
2331
|
+
note: dto.note,
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
throw new Error("ControlViewService commitOpenPending live target not found");
|
|
2335
|
+
};
|
|
2336
|
+
this.commitAverageBuy = async (symbol, context, dto) => {
|
|
2337
|
+
this.loggerService.log("controlViewService commitAverageBuy", {
|
|
2338
|
+
symbol,
|
|
2339
|
+
context,
|
|
2340
|
+
dto,
|
|
2341
|
+
});
|
|
2342
|
+
if (CC_ENABLE_MOCK) {
|
|
2343
|
+
return await this.controlMockService.commitAverageBuy(symbol, context, dto);
|
|
2344
|
+
}
|
|
2345
|
+
const liveList = await BacktestKit.Live.list();
|
|
2346
|
+
const liveTarget = liveList.find((live) => live.symbol === symbol);
|
|
2347
|
+
if (liveTarget) {
|
|
2348
|
+
const currentPrice = await BacktestKit.Exchange.getAveragePrice(symbol, {
|
|
2349
|
+
exchangeName: liveTarget.exchangeName,
|
|
2350
|
+
});
|
|
2351
|
+
const pending = await BacktestKit.Live.getPendingSignal(symbol, currentPrice, context);
|
|
2352
|
+
if (!pending) {
|
|
2353
|
+
throw new Error("ControlViewService commitAverageBuy has no pending signal");
|
|
2354
|
+
}
|
|
2355
|
+
const isOk = await BacktestKit.Live.commitAverageBuy(symbol, currentPrice, context, dto.cost);
|
|
2356
|
+
if (!isOk) {
|
|
2357
|
+
throw new Error("ControlViewService commitAverageBuy failed");
|
|
2358
|
+
}
|
|
2359
|
+
return;
|
|
2360
|
+
}
|
|
2361
|
+
throw new Error("ControlViewService commitAverageBuy live target not found");
|
|
2362
|
+
};
|
|
2363
|
+
this.commitClosePending = async (symbol, context, dto) => {
|
|
2364
|
+
this.loggerService.log("controlViewService commitClosePending", {
|
|
2365
|
+
symbol,
|
|
2366
|
+
context,
|
|
2367
|
+
dto,
|
|
2368
|
+
});
|
|
2369
|
+
if (CC_ENABLE_MOCK) {
|
|
2370
|
+
return await this.controlMockService.commitClosePending(symbol, context, dto);
|
|
2371
|
+
}
|
|
2372
|
+
const liveList = await BacktestKit.Live.list();
|
|
2373
|
+
const liveTarget = liveList.find((live) => live.symbol === symbol);
|
|
2374
|
+
if (liveTarget) {
|
|
2375
|
+
const currentPrice = await BacktestKit.Exchange.getAveragePrice(symbol, {
|
|
2376
|
+
exchangeName: liveTarget.exchangeName,
|
|
2377
|
+
});
|
|
2378
|
+
const pending = await BacktestKit.Live.getPendingSignal(symbol, currentPrice, context);
|
|
2379
|
+
if (!pending) {
|
|
2380
|
+
throw new Error("ControlViewService commitClosePending has no pending signal");
|
|
2381
|
+
}
|
|
2382
|
+
return await BacktestKit.Live.commitClosePending(symbol, context, {
|
|
2383
|
+
id: pending.id,
|
|
2384
|
+
note: dto.note,
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
throw new Error("ControlViewService commitClosePending live target not found");
|
|
2388
|
+
};
|
|
2389
|
+
this.commitBreakeven = async (symbol, context) => {
|
|
2390
|
+
this.loggerService.log("controlViewService commitBreakeven", {
|
|
2391
|
+
symbol,
|
|
2392
|
+
context,
|
|
2393
|
+
});
|
|
2394
|
+
if (CC_ENABLE_MOCK) {
|
|
2395
|
+
return await this.controlMockService.commitBreakeven(symbol, context);
|
|
2396
|
+
}
|
|
2397
|
+
const liveList = await BacktestKit.Live.list();
|
|
2398
|
+
const liveTarget = liveList.find((live) => live.symbol === symbol);
|
|
2399
|
+
if (liveTarget) {
|
|
2400
|
+
const currentPrice = await BacktestKit.Exchange.getAveragePrice(symbol, {
|
|
2401
|
+
exchangeName: liveTarget.exchangeName,
|
|
2402
|
+
});
|
|
2403
|
+
const pending = await BacktestKit.Live.getPendingSignal(symbol, currentPrice, context);
|
|
2404
|
+
if (!pending) {
|
|
2405
|
+
throw new Error("ControlViewService commitBreakeven has no pending signal");
|
|
2406
|
+
}
|
|
2407
|
+
const isOk = await BacktestKit.Live.commitBreakeven(symbol, currentPrice, context);
|
|
2408
|
+
if (!isOk) {
|
|
2409
|
+
throw new Error("ControlViewService commitBreakeven failed");
|
|
2410
|
+
}
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
throw new Error("ControlViewService commitBreakeven live target not found");
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2200
2418
|
{
|
|
2201
2419
|
provide(TYPES.loggerService, () => new LoggerService());
|
|
2202
2420
|
provide(TYPES.exchangeService, () => new ExchangeService());
|
|
@@ -2224,6 +2442,7 @@ class RuntimeViewService {
|
|
|
2224
2442
|
provide(TYPES.environmentMockService, () => new EnvironmentMockService());
|
|
2225
2443
|
provide(TYPES.setupMockService, () => new SetupMockService());
|
|
2226
2444
|
provide(TYPES.runtimeMockService, () => new RuntimeMockService());
|
|
2445
|
+
provide(TYPES.controlMockService, () => new ControlMockService());
|
|
2227
2446
|
}
|
|
2228
2447
|
{
|
|
2229
2448
|
provide(TYPES.notificationViewService, () => new NotificationViewService());
|
|
@@ -2239,6 +2458,7 @@ class RuntimeViewService {
|
|
|
2239
2458
|
provide(TYPES.environmentViewService, () => new EnvironmentViewService());
|
|
2240
2459
|
provide(TYPES.setupViewService, () => new SetupViewService());
|
|
2241
2460
|
provide(TYPES.runtimeViewService, () => new RuntimeViewService());
|
|
2461
|
+
provide(TYPES.controlViewService, () => new ControlViewService());
|
|
2242
2462
|
}
|
|
2243
2463
|
|
|
2244
2464
|
const baseServices = {
|
|
@@ -2268,6 +2488,7 @@ const mockServices = {
|
|
|
2268
2488
|
environmentMockService: inject(TYPES.environmentMockService),
|
|
2269
2489
|
setupMockService: inject(TYPES.setupMockService),
|
|
2270
2490
|
runtimeMockService: inject(TYPES.runtimeMockService),
|
|
2491
|
+
controlMockService: inject(TYPES.controlMockService),
|
|
2271
2492
|
};
|
|
2272
2493
|
const viewServices = {
|
|
2273
2494
|
notificationViewService: inject(TYPES.notificationViewService),
|
|
@@ -2283,6 +2504,7 @@ const viewServices = {
|
|
|
2283
2504
|
environmentViewService: inject(TYPES.environmentViewService),
|
|
2284
2505
|
setupViewService: inject(TYPES.setupViewService),
|
|
2285
2506
|
runtimeViewService: inject(TYPES.runtimeViewService),
|
|
2507
|
+
controlViewService: inject(TYPES.controlViewService),
|
|
2286
2508
|
};
|
|
2287
2509
|
const ioc = {
|
|
2288
2510
|
...baseServices,
|
|
@@ -2851,6 +3073,175 @@ router$b.post("/api/v1/mock/status_one/:id", async (req, res) => {
|
|
|
2851
3073
|
});
|
|
2852
3074
|
}
|
|
2853
3075
|
});
|
|
3076
|
+
// ControlMockService endpoints
|
|
3077
|
+
router$b.post("/api/v1/mock/control_status", async (req, res) => {
|
|
3078
|
+
try {
|
|
3079
|
+
const request = await micro.json(req);
|
|
3080
|
+
const { symbol, context, requestId, serviceName } = request;
|
|
3081
|
+
const data = await ioc.controlMockService.getStatus(symbol, context);
|
|
3082
|
+
const result = {
|
|
3083
|
+
data,
|
|
3084
|
+
status: "ok",
|
|
3085
|
+
error: "",
|
|
3086
|
+
requestId,
|
|
3087
|
+
serviceName,
|
|
3088
|
+
};
|
|
3089
|
+
ioc.loggerService.log("/api/v1/mock/control_status ok", {
|
|
3090
|
+
request,
|
|
3091
|
+
result: omit(result, "data"),
|
|
3092
|
+
});
|
|
3093
|
+
return await micro.send(res, 200, result);
|
|
3094
|
+
}
|
|
3095
|
+
catch (error) {
|
|
3096
|
+
ioc.loggerService.log("/api/v1/mock/control_status error", {
|
|
3097
|
+
error: functoolsKit.errorData(error),
|
|
3098
|
+
});
|
|
3099
|
+
return await micro.send(res, 200, {
|
|
3100
|
+
status: "error",
|
|
3101
|
+
error: functoolsKit.getErrorMessage(error),
|
|
3102
|
+
});
|
|
3103
|
+
}
|
|
3104
|
+
});
|
|
3105
|
+
router$b.post("/api/v1/mock/control_average_price", async (req, res) => {
|
|
3106
|
+
try {
|
|
3107
|
+
const request = await micro.json(req);
|
|
3108
|
+
const { symbol, context, requestId, serviceName } = request;
|
|
3109
|
+
const data = await ioc.controlMockService.getAveragePrice(symbol, context);
|
|
3110
|
+
const result = {
|
|
3111
|
+
data,
|
|
3112
|
+
status: "ok",
|
|
3113
|
+
error: "",
|
|
3114
|
+
requestId,
|
|
3115
|
+
serviceName,
|
|
3116
|
+
};
|
|
3117
|
+
ioc.loggerService.log("/api/v1/mock/control_average_price ok", {
|
|
3118
|
+
request,
|
|
3119
|
+
result: omit(result, "data"),
|
|
3120
|
+
});
|
|
3121
|
+
return await micro.send(res, 200, result);
|
|
3122
|
+
}
|
|
3123
|
+
catch (error) {
|
|
3124
|
+
ioc.loggerService.log("/api/v1/mock/control_average_price error", {
|
|
3125
|
+
error: functoolsKit.errorData(error),
|
|
3126
|
+
});
|
|
3127
|
+
return await micro.send(res, 200, {
|
|
3128
|
+
status: "error",
|
|
3129
|
+
error: functoolsKit.getErrorMessage(error),
|
|
3130
|
+
});
|
|
3131
|
+
}
|
|
3132
|
+
});
|
|
3133
|
+
router$b.post("/api/v1/mock/control_open_pending", async (req, res) => {
|
|
3134
|
+
try {
|
|
3135
|
+
const request = await micro.json(req);
|
|
3136
|
+
const { symbol, context, dto, requestId, serviceName } = request;
|
|
3137
|
+
const data = await ioc.controlMockService.commitOpenPending(symbol, context, dto);
|
|
3138
|
+
const result = {
|
|
3139
|
+
data,
|
|
3140
|
+
status: "ok",
|
|
3141
|
+
error: "",
|
|
3142
|
+
requestId,
|
|
3143
|
+
serviceName,
|
|
3144
|
+
};
|
|
3145
|
+
ioc.loggerService.log("/api/v1/mock/control_open_pending ok", {
|
|
3146
|
+
request,
|
|
3147
|
+
result: omit(result, "data"),
|
|
3148
|
+
});
|
|
3149
|
+
return await micro.send(res, 200, result);
|
|
3150
|
+
}
|
|
3151
|
+
catch (error) {
|
|
3152
|
+
ioc.loggerService.log("/api/v1/mock/control_open_pending error", {
|
|
3153
|
+
error: functoolsKit.errorData(error),
|
|
3154
|
+
});
|
|
3155
|
+
return await micro.send(res, 200, {
|
|
3156
|
+
status: "error",
|
|
3157
|
+
error: functoolsKit.getErrorMessage(error),
|
|
3158
|
+
});
|
|
3159
|
+
}
|
|
3160
|
+
});
|
|
3161
|
+
router$b.post("/api/v1/mock/control_average_buy", async (req, res) => {
|
|
3162
|
+
try {
|
|
3163
|
+
const request = await micro.json(req);
|
|
3164
|
+
const { symbol, context, dto, requestId, serviceName } = request;
|
|
3165
|
+
const data = await ioc.controlMockService.commitAverageBuy(symbol, context, dto);
|
|
3166
|
+
const result = {
|
|
3167
|
+
data,
|
|
3168
|
+
status: "ok",
|
|
3169
|
+
error: "",
|
|
3170
|
+
requestId,
|
|
3171
|
+
serviceName,
|
|
3172
|
+
};
|
|
3173
|
+
ioc.loggerService.log("/api/v1/mock/control_average_buy ok", {
|
|
3174
|
+
request,
|
|
3175
|
+
result: omit(result, "data"),
|
|
3176
|
+
});
|
|
3177
|
+
return await micro.send(res, 200, result);
|
|
3178
|
+
}
|
|
3179
|
+
catch (error) {
|
|
3180
|
+
ioc.loggerService.log("/api/v1/mock/control_average_buy error", {
|
|
3181
|
+
error: functoolsKit.errorData(error),
|
|
3182
|
+
});
|
|
3183
|
+
return await micro.send(res, 200, {
|
|
3184
|
+
status: "error",
|
|
3185
|
+
error: functoolsKit.getErrorMessage(error),
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
});
|
|
3189
|
+
router$b.post("/api/v1/mock/control_close_pending", async (req, res) => {
|
|
3190
|
+
try {
|
|
3191
|
+
const request = await micro.json(req);
|
|
3192
|
+
const { symbol, context, dto, requestId, serviceName } = request;
|
|
3193
|
+
const data = await ioc.controlMockService.commitClosePending(symbol, context, dto);
|
|
3194
|
+
const result = {
|
|
3195
|
+
data,
|
|
3196
|
+
status: "ok",
|
|
3197
|
+
error: "",
|
|
3198
|
+
requestId,
|
|
3199
|
+
serviceName,
|
|
3200
|
+
};
|
|
3201
|
+
ioc.loggerService.log("/api/v1/mock/control_close_pending ok", {
|
|
3202
|
+
request,
|
|
3203
|
+
result: omit(result, "data"),
|
|
3204
|
+
});
|
|
3205
|
+
return await micro.send(res, 200, result);
|
|
3206
|
+
}
|
|
3207
|
+
catch (error) {
|
|
3208
|
+
ioc.loggerService.log("/api/v1/mock/control_close_pending error", {
|
|
3209
|
+
error: functoolsKit.errorData(error),
|
|
3210
|
+
});
|
|
3211
|
+
return await micro.send(res, 200, {
|
|
3212
|
+
status: "error",
|
|
3213
|
+
error: functoolsKit.getErrorMessage(error),
|
|
3214
|
+
});
|
|
3215
|
+
}
|
|
3216
|
+
});
|
|
3217
|
+
router$b.post("/api/v1/mock/control_breakeven", async (req, res) => {
|
|
3218
|
+
try {
|
|
3219
|
+
const request = await micro.json(req);
|
|
3220
|
+
const { symbol, context, requestId, serviceName } = request;
|
|
3221
|
+
const data = await ioc.controlMockService.commitBreakeven(symbol, context);
|
|
3222
|
+
const result = {
|
|
3223
|
+
data,
|
|
3224
|
+
status: "ok",
|
|
3225
|
+
error: "",
|
|
3226
|
+
requestId,
|
|
3227
|
+
serviceName,
|
|
3228
|
+
};
|
|
3229
|
+
ioc.loggerService.log("/api/v1/mock/control_breakeven ok", {
|
|
3230
|
+
request,
|
|
3231
|
+
result: omit(result, "data"),
|
|
3232
|
+
});
|
|
3233
|
+
return await micro.send(res, 200, result);
|
|
3234
|
+
}
|
|
3235
|
+
catch (error) {
|
|
3236
|
+
ioc.loggerService.log("/api/v1/mock/control_breakeven error", {
|
|
3237
|
+
error: functoolsKit.errorData(error),
|
|
3238
|
+
});
|
|
3239
|
+
return await micro.send(res, 200, {
|
|
3240
|
+
status: "error",
|
|
3241
|
+
error: functoolsKit.getErrorMessage(error),
|
|
3242
|
+
});
|
|
3243
|
+
}
|
|
3244
|
+
});
|
|
2854
3245
|
// HeatMockService endpoints
|
|
2855
3246
|
router$b.post("/api/v1/mock/heat_data", async (req, res) => {
|
|
2856
3247
|
try {
|
|
@@ -3610,6 +4001,175 @@ router$a.post("/api/v1/view/status_one/:id", async (req, res) => {
|
|
|
3610
4001
|
});
|
|
3611
4002
|
}
|
|
3612
4003
|
});
|
|
4004
|
+
// ControlViewService endpoints
|
|
4005
|
+
router$a.post("/api/v1/view/control_status", async (req, res) => {
|
|
4006
|
+
try {
|
|
4007
|
+
const request = await micro.json(req);
|
|
4008
|
+
const { symbol, context, requestId, serviceName } = request;
|
|
4009
|
+
const data = await ioc.controlViewService.getStatus(symbol, context);
|
|
4010
|
+
const result = {
|
|
4011
|
+
data,
|
|
4012
|
+
status: "ok",
|
|
4013
|
+
error: "",
|
|
4014
|
+
requestId,
|
|
4015
|
+
serviceName,
|
|
4016
|
+
};
|
|
4017
|
+
ioc.loggerService.log("/api/v1/view/control_status ok", {
|
|
4018
|
+
request,
|
|
4019
|
+
result: omit(result, "data"),
|
|
4020
|
+
});
|
|
4021
|
+
return await micro.send(res, 200, result);
|
|
4022
|
+
}
|
|
4023
|
+
catch (error) {
|
|
4024
|
+
ioc.loggerService.log("/api/v1/view/control_status error", {
|
|
4025
|
+
error: functoolsKit.errorData(error),
|
|
4026
|
+
});
|
|
4027
|
+
return await micro.send(res, 200, {
|
|
4028
|
+
status: "error",
|
|
4029
|
+
error: functoolsKit.getErrorMessage(error),
|
|
4030
|
+
});
|
|
4031
|
+
}
|
|
4032
|
+
});
|
|
4033
|
+
router$a.post("/api/v1/view/control_average_price", async (req, res) => {
|
|
4034
|
+
try {
|
|
4035
|
+
const request = await micro.json(req);
|
|
4036
|
+
const { symbol, context, requestId, serviceName } = request;
|
|
4037
|
+
const data = await ioc.controlViewService.getAveragePrice(symbol, context);
|
|
4038
|
+
const result = {
|
|
4039
|
+
data,
|
|
4040
|
+
status: "ok",
|
|
4041
|
+
error: "",
|
|
4042
|
+
requestId,
|
|
4043
|
+
serviceName,
|
|
4044
|
+
};
|
|
4045
|
+
ioc.loggerService.log("/api/v1/view/control_average_price ok", {
|
|
4046
|
+
request,
|
|
4047
|
+
result: omit(result, "data"),
|
|
4048
|
+
});
|
|
4049
|
+
return await micro.send(res, 200, result);
|
|
4050
|
+
}
|
|
4051
|
+
catch (error) {
|
|
4052
|
+
ioc.loggerService.log("/api/v1/view/control_average_price error", {
|
|
4053
|
+
error: functoolsKit.errorData(error),
|
|
4054
|
+
});
|
|
4055
|
+
return await micro.send(res, 200, {
|
|
4056
|
+
status: "error",
|
|
4057
|
+
error: functoolsKit.getErrorMessage(error),
|
|
4058
|
+
});
|
|
4059
|
+
}
|
|
4060
|
+
});
|
|
4061
|
+
router$a.post("/api/v1/view/control_open_pending", async (req, res) => {
|
|
4062
|
+
try {
|
|
4063
|
+
const request = await micro.json(req);
|
|
4064
|
+
const { symbol, context, dto, requestId, serviceName } = request;
|
|
4065
|
+
const data = await ioc.controlViewService.commitOpenPending(symbol, context, dto);
|
|
4066
|
+
const result = {
|
|
4067
|
+
data,
|
|
4068
|
+
status: "ok",
|
|
4069
|
+
error: "",
|
|
4070
|
+
requestId,
|
|
4071
|
+
serviceName,
|
|
4072
|
+
};
|
|
4073
|
+
ioc.loggerService.log("/api/v1/view/control_open_pending ok", {
|
|
4074
|
+
request,
|
|
4075
|
+
result: omit(result, "data"),
|
|
4076
|
+
});
|
|
4077
|
+
return await micro.send(res, 200, result);
|
|
4078
|
+
}
|
|
4079
|
+
catch (error) {
|
|
4080
|
+
ioc.loggerService.log("/api/v1/view/control_open_pending error", {
|
|
4081
|
+
error: functoolsKit.errorData(error),
|
|
4082
|
+
});
|
|
4083
|
+
return await micro.send(res, 200, {
|
|
4084
|
+
status: "error",
|
|
4085
|
+
error: functoolsKit.getErrorMessage(error),
|
|
4086
|
+
});
|
|
4087
|
+
}
|
|
4088
|
+
});
|
|
4089
|
+
router$a.post("/api/v1/view/control_average_buy", async (req, res) => {
|
|
4090
|
+
try {
|
|
4091
|
+
const request = await micro.json(req);
|
|
4092
|
+
const { symbol, context, dto, requestId, serviceName } = request;
|
|
4093
|
+
const data = await ioc.controlViewService.commitAverageBuy(symbol, context, dto);
|
|
4094
|
+
const result = {
|
|
4095
|
+
data,
|
|
4096
|
+
status: "ok",
|
|
4097
|
+
error: "",
|
|
4098
|
+
requestId,
|
|
4099
|
+
serviceName,
|
|
4100
|
+
};
|
|
4101
|
+
ioc.loggerService.log("/api/v1/view/control_average_buy ok", {
|
|
4102
|
+
request,
|
|
4103
|
+
result: omit(result, "data"),
|
|
4104
|
+
});
|
|
4105
|
+
return await micro.send(res, 200, result);
|
|
4106
|
+
}
|
|
4107
|
+
catch (error) {
|
|
4108
|
+
ioc.loggerService.log("/api/v1/view/control_average_buy error", {
|
|
4109
|
+
error: functoolsKit.errorData(error),
|
|
4110
|
+
});
|
|
4111
|
+
return await micro.send(res, 200, {
|
|
4112
|
+
status: "error",
|
|
4113
|
+
error: functoolsKit.getErrorMessage(error),
|
|
4114
|
+
});
|
|
4115
|
+
}
|
|
4116
|
+
});
|
|
4117
|
+
router$a.post("/api/v1/view/control_close_pending", async (req, res) => {
|
|
4118
|
+
try {
|
|
4119
|
+
const request = await micro.json(req);
|
|
4120
|
+
const { symbol, context, dto, requestId, serviceName } = request;
|
|
4121
|
+
const data = await ioc.controlViewService.commitClosePending(symbol, context, dto);
|
|
4122
|
+
const result = {
|
|
4123
|
+
data,
|
|
4124
|
+
status: "ok",
|
|
4125
|
+
error: "",
|
|
4126
|
+
requestId,
|
|
4127
|
+
serviceName,
|
|
4128
|
+
};
|
|
4129
|
+
ioc.loggerService.log("/api/v1/view/control_close_pending ok", {
|
|
4130
|
+
request,
|
|
4131
|
+
result: omit(result, "data"),
|
|
4132
|
+
});
|
|
4133
|
+
return await micro.send(res, 200, result);
|
|
4134
|
+
}
|
|
4135
|
+
catch (error) {
|
|
4136
|
+
ioc.loggerService.log("/api/v1/view/control_close_pending error", {
|
|
4137
|
+
error: functoolsKit.errorData(error),
|
|
4138
|
+
});
|
|
4139
|
+
return await micro.send(res, 200, {
|
|
4140
|
+
status: "error",
|
|
4141
|
+
error: functoolsKit.getErrorMessage(error),
|
|
4142
|
+
});
|
|
4143
|
+
}
|
|
4144
|
+
});
|
|
4145
|
+
router$a.post("/api/v1/view/control_breakeven", async (req, res) => {
|
|
4146
|
+
try {
|
|
4147
|
+
const request = await micro.json(req);
|
|
4148
|
+
const { symbol, context, requestId, serviceName } = request;
|
|
4149
|
+
const data = await ioc.controlViewService.commitBreakeven(symbol, context);
|
|
4150
|
+
const result = {
|
|
4151
|
+
data,
|
|
4152
|
+
status: "ok",
|
|
4153
|
+
error: "",
|
|
4154
|
+
requestId,
|
|
4155
|
+
serviceName,
|
|
4156
|
+
};
|
|
4157
|
+
ioc.loggerService.log("/api/v1/view/control_breakeven ok", {
|
|
4158
|
+
request,
|
|
4159
|
+
result: omit(result, "data"),
|
|
4160
|
+
});
|
|
4161
|
+
return await micro.send(res, 200, result);
|
|
4162
|
+
}
|
|
4163
|
+
catch (error) {
|
|
4164
|
+
ioc.loggerService.log("/api/v1/view/control_breakeven error", {
|
|
4165
|
+
error: functoolsKit.errorData(error),
|
|
4166
|
+
});
|
|
4167
|
+
return await micro.send(res, 200, {
|
|
4168
|
+
status: "error",
|
|
4169
|
+
error: functoolsKit.getErrorMessage(error),
|
|
4170
|
+
});
|
|
4171
|
+
}
|
|
4172
|
+
});
|
|
3613
4173
|
// HeatViewService endpoints
|
|
3614
4174
|
router$a.post("/api/v1/view/heat_data", async (req, res) => {
|
|
3615
4175
|
try {
|