@backtest-kit/ui 6.15.0 → 6.16.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.
Files changed (41) hide show
  1. package/build/index.cjs +108 -14
  2. package/build/index.mjs +109 -15
  3. package/build/modules/frontend/build/3rdparty/qfchart_0.8.7/echarts.min.js +45 -0
  4. package/build/modules/frontend/build/3rdparty/qfchart_0.8.7/pinets.js +21534 -0
  5. package/build/modules/frontend/build/3rdparty/qfchart_0.8.7/qfchart.js +3997 -0
  6. package/build/modules/frontend/build/assets/Article-DYhWfFAi.js +1 -0
  7. package/build/modules/frontend/build/assets/Background-COpkJTP-.js +1 -0
  8. package/build/modules/frontend/build/assets/{IconPhoto-CNX0t203.js → IconPhoto-DUgsqsYP.js} +1 -1
  9. package/build/modules/frontend/build/assets/{KeyboardArrowLeft-5ogjRzwF.js → KeyboardArrowLeft-BlwcBPHn.js} +1 -1
  10. package/build/modules/frontend/build/assets/Refresh-aWduZclR.js +1 -0
  11. package/build/modules/frontend/build/assets/emitters-CSLNlyHG.js +1 -0
  12. package/build/modules/frontend/build/assets/hasRouteMatch-CImjW4Jf.js +1 -0
  13. package/build/modules/frontend/build/assets/{html2canvas-BnarC1H-.js → html2canvas-Do8zi4tS.js} +1 -1
  14. package/build/modules/frontend/build/assets/index-7wQuV9F_.js +1 -0
  15. package/build/modules/frontend/build/assets/index-B_46G-d8.js +1 -0
  16. package/build/modules/frontend/build/assets/index-BfiWEbdc.js +1 -0
  17. package/build/modules/frontend/build/assets/index-Bmqo1dsM.js +1 -0
  18. package/build/modules/frontend/build/assets/index-CETLG42q.js +1 -0
  19. package/build/modules/frontend/build/assets/index-Cb4CVVwH.js +1 -0
  20. package/build/modules/frontend/build/assets/{index-BMzg4t4L.js → index-Ce2sQITf.js} +7 -7
  21. package/build/modules/frontend/build/assets/{index-CYHbLqvS.js → index-CjymMd2D.js} +1 -1
  22. package/build/modules/frontend/build/assets/{index-DLH5bivm.js → index-D6YeBcAB.js} +1 -1
  23. package/build/modules/frontend/build/assets/index-WhalaOXd.js +1 -0
  24. package/build/modules/frontend/build/assets/{index-eYCKhqo-.js → index-kQ_oUmTQ.js} +1 -1
  25. package/build/modules/frontend/build/assets/{index-BY7xx8Qo.js → index-lZGMPvrT.js} +1 -1
  26. package/build/modules/frontend/build/assets/{index.es-XkghWdRJ.js → index.es-Cel98f_u.js} +1 -1
  27. package/build/modules/frontend/build/assets/{markdownit-CFUj-lOk.js → markdownit-22RgFULT.js} +1 -1
  28. package/build/modules/frontend/build/index.html +4 -1
  29. package/package.json +3 -3
  30. package/types.d.ts +11 -2
  31. package/build/modules/frontend/build/assets/Article-BFiJ1grS.js +0 -1
  32. package/build/modules/frontend/build/assets/Background-C4tJEFCD.js +0 -1
  33. package/build/modules/frontend/build/assets/Refresh-DPMpKmUf.js +0 -1
  34. package/build/modules/frontend/build/assets/emitters-BxM0853t.js +0 -1
  35. package/build/modules/frontend/build/assets/hasRouteMatch-DvMTRSzL.js +0 -1
  36. package/build/modules/frontend/build/assets/index-2cnF0R3L.js +0 -1
  37. package/build/modules/frontend/build/assets/index-B9jcFvZN.js +0 -1
  38. package/build/modules/frontend/build/assets/index-C-XjS3CF.js +0 -1
  39. package/build/modules/frontend/build/assets/index-C1SBiwRD.js +0 -1
  40. package/build/modules/frontend/build/assets/index-C5kEItX6.js +0 -1
  41. package/build/modules/frontend/build/assets/index-Dl9D9lt4.js +0 -1
package/build/index.cjs CHANGED
@@ -170,6 +170,18 @@ class ExchangeService {
170
170
  exchangeName: dto.exchangeName,
171
171
  });
172
172
  };
173
+ this.getRawCandles = async (dto) => {
174
+ this.loggerService.log("exchangeService getRawCandles", {
175
+ dto,
176
+ });
177
+ const [exchange = null] = await backtestKit.listExchangeSchema();
178
+ if (exchange === null) {
179
+ throw new Error("exchangeService getRawCandles no exchange registered");
180
+ }
181
+ return await backtestKit.Exchange.getRawCandles(dto.symbol, dto.interval, {
182
+ exchangeName: exchange.exchangeName,
183
+ }, dto.limit, dto.sDate, dto.eDate);
184
+ };
173
185
  }
174
186
  }
175
187
 
@@ -503,6 +515,8 @@ class StatusMockService {
503
515
  positionLevels,
504
516
  positionEntries,
505
517
  positionPartials,
518
+ _peak: status._peak,
519
+ _fall: status._fall,
506
520
  };
507
521
  };
508
522
  }
@@ -797,6 +811,10 @@ class NotificationViewService {
797
811
  if (CC_ENABLE_MOCK) {
798
812
  return await this.notificationMockService.findByFilter(filterData, limit, offset);
799
813
  }
814
+ if (!backtestKit.Notification.enable.hasValue()) {
815
+ console.warn("@backtest-kit/ui notificationViewService findByFilter notifications not enabled");
816
+ return [];
817
+ }
800
818
  const iter = functoolsKit.pickDocuments(limit, offset);
801
819
  const filterList = CREATE_FILTER_LIST_FN$1(filterData);
802
820
  for (const notification of await this.getList()) {
@@ -818,6 +836,10 @@ class NotificationViewService {
818
836
  if (CC_ENABLE_MOCK) {
819
837
  return await this.notificationMockService.getList();
820
838
  }
839
+ if (!backtestKit.Notification.enable.hasValue()) {
840
+ console.warn("@backtest-kit/ui notificationViewService getList notifications not enabled");
841
+ return [];
842
+ }
821
843
  const notificationList = [];
822
844
  for (const notification of await backtestKit.Notification.getData(false)) {
823
845
  notificationList.push(notification);
@@ -847,16 +869,13 @@ class NotificationViewService {
847
869
  if (CC_ENABLE_MOCK) {
848
870
  return await this.notificationMockService.getOne(id);
849
871
  }
872
+ if (!backtestKit.Notification.enable.hasValue()) {
873
+ console.warn("@backtest-kit/ui notificationViewService getOne notifications not enabled");
874
+ return null;
875
+ }
850
876
  const notificationList = await this.getList();
851
877
  return notificationList.find((item) => item.id === id) ?? null;
852
878
  };
853
- this.init = functoolsKit.singleshot(async () => {
854
- this.loggerService.log("notificationViewService init");
855
- if (CC_ENABLE_MOCK) {
856
- return;
857
- }
858
- backtestKit.Notification.enable();
859
- });
860
879
  }
861
880
  }
862
881
 
@@ -871,6 +890,10 @@ class StorageViewService {
871
890
  if (CC_ENABLE_MOCK) {
872
891
  return await this.storageMockService.findSignalById(signalId);
873
892
  }
893
+ if (!backtestKit.Storage.enable.hasValue()) {
894
+ console.warn("@backtest-kit/ui storageViewService findSignalById storage not enabled");
895
+ return null;
896
+ }
874
897
  return await backtestKit.Storage.findSignalById(signalId);
875
898
  };
876
899
  this.listSignalLive = async () => {
@@ -878,6 +901,10 @@ class StorageViewService {
878
901
  if (CC_ENABLE_MOCK) {
879
902
  return await this.storageMockService.listSignalLive();
880
903
  }
904
+ if (!backtestKit.Storage.enable.hasValue()) {
905
+ console.warn("@backtest-kit/ui storageViewService listSignalLive storage not enabled");
906
+ return [];
907
+ }
881
908
  const signalList = await backtestKit.Storage.listSignalLive();
882
909
  signalList.sort((a, b) => {
883
910
  const aHasTime = "createdAt" in a;
@@ -899,6 +926,10 @@ class StorageViewService {
899
926
  if (CC_ENABLE_MOCK) {
900
927
  return await this.storageMockService.listSignalBacktest();
901
928
  }
929
+ if (!backtestKit.Storage.enable.hasValue()) {
930
+ console.warn("@backtest-kit/ui storageViewService listSignalBacktest storage not enabled");
931
+ return [];
932
+ }
902
933
  const signalList = await backtestKit.Storage.listSignalBacktest();
903
934
  signalList.sort((a, b) => {
904
935
  const aHasTime = "createdAt" in a;
@@ -915,13 +946,6 @@ class StorageViewService {
915
946
  });
916
947
  return signalList;
917
948
  };
918
- this.init = functoolsKit.singleshot(async () => {
919
- this.loggerService.log("storageViewService init");
920
- if (CC_ENABLE_MOCK) {
921
- return;
922
- }
923
- backtestKit.Storage.enable();
924
- });
925
949
  }
926
950
  }
927
951
 
@@ -1170,6 +1194,8 @@ class StatusViewService {
1170
1194
  positionEntries,
1171
1195
  positionLevels,
1172
1196
  positionPartials,
1197
+ _peak: pendingSignal._peak,
1198
+ _fall: pendingSignal._fall,
1173
1199
  };
1174
1200
  };
1175
1201
  this.getStatusInfo = async () => {
@@ -1952,6 +1978,40 @@ router$a.post("/api/v1/mock/candles_point", async (req, res) => {
1952
1978
  });
1953
1979
  }
1954
1980
  });
1981
+ router$a.post("/api/v1/mock/candles_range", async (req, res) => {
1982
+ try {
1983
+ const request = await micro.json(req);
1984
+ const { symbol, interval, limit, sDate, eDate, requestId, serviceName } = request;
1985
+ const data = await ioc.exchangeService.getRawCandles({
1986
+ symbol,
1987
+ interval,
1988
+ limit,
1989
+ sDate,
1990
+ eDate,
1991
+ });
1992
+ const result = {
1993
+ data,
1994
+ status: "ok",
1995
+ error: "",
1996
+ requestId,
1997
+ serviceName,
1998
+ };
1999
+ ioc.loggerService.log("/api/v1/mock/candles_range ok", {
2000
+ request,
2001
+ result: omit(result, "data"),
2002
+ });
2003
+ return await micro.send(res, 200, result);
2004
+ }
2005
+ catch (error) {
2006
+ ioc.loggerService.log("/api/v1/mock/candles_range error", {
2007
+ error: functoolsKit.errorData(error),
2008
+ });
2009
+ return await micro.send(res, 200, {
2010
+ status: "error",
2011
+ error: functoolsKit.getErrorMessage(error),
2012
+ });
2013
+ }
2014
+ });
1955
2015
  // NotificationMockService endpoints
1956
2016
  router$a.post("/api/v1/mock/notification_list", async (req, res) => {
1957
2017
  try {
@@ -2533,6 +2593,40 @@ router$9.post("/api/v1/view/candles_point", async (req, res) => {
2533
2593
  });
2534
2594
  }
2535
2595
  });
2596
+ router$9.post("/api/v1/view/candles_range", async (req, res) => {
2597
+ try {
2598
+ const request = await micro.json(req);
2599
+ const { symbol, interval, limit, sDate, eDate, requestId, serviceName } = request;
2600
+ const data = await ioc.exchangeService.getRawCandles({
2601
+ symbol,
2602
+ interval,
2603
+ limit,
2604
+ sDate,
2605
+ eDate,
2606
+ });
2607
+ const result = {
2608
+ data,
2609
+ status: "ok",
2610
+ error: "",
2611
+ requestId,
2612
+ serviceName,
2613
+ };
2614
+ ioc.loggerService.log("/api/v1/view/candles_range ok", {
2615
+ request,
2616
+ result: omit(result, "data"),
2617
+ });
2618
+ return await micro.send(res, 200, result);
2619
+ }
2620
+ catch (error) {
2621
+ ioc.loggerService.log("/api/v1/view/candles_range error", {
2622
+ error: functoolsKit.errorData(error),
2623
+ });
2624
+ return await micro.send(res, 200, {
2625
+ status: "error",
2626
+ error: functoolsKit.getErrorMessage(error),
2627
+ });
2628
+ }
2629
+ });
2536
2630
  router$9.post("/api/v1/view/candles_live", async (req, res) => {
2537
2631
  try {
2538
2632
  const request = await micro.json(req);
package/build/index.mjs CHANGED
@@ -6,7 +6,7 @@ import finalhandler from 'finalhandler';
6
6
  import serveHandler from 'serve-handler';
7
7
  import os from 'os';
8
8
  import { createActivator } from 'di-kit';
9
- import { alignToInterval, Exchange, Backtest, Live, listExchangeSchema, Notification, Storage, Log, lib, Heat, Strategy, Breakeven, Risk, Partial, HighestProfit, MaxDrawdown, Schedule, Performance, Sync, Walker, StorageLive, StorageBacktest } from 'backtest-kit';
9
+ import { alignToInterval, Exchange, listExchangeSchema, Backtest, Live, Notification, Storage, Log, lib, Heat, Strategy, Breakeven, Risk, Partial, HighestProfit, MaxDrawdown, Schedule, Performance, Sync, Walker, StorageLive, StorageBacktest } from 'backtest-kit';
10
10
  import fs, { readdir, readFile } from 'fs/promises';
11
11
  import path, { join, dirname } from 'path';
12
12
  import mime from 'mime-types';
@@ -167,6 +167,18 @@ class ExchangeService {
167
167
  exchangeName: dto.exchangeName,
168
168
  });
169
169
  };
170
+ this.getRawCandles = async (dto) => {
171
+ this.loggerService.log("exchangeService getRawCandles", {
172
+ dto,
173
+ });
174
+ const [exchange = null] = await listExchangeSchema();
175
+ if (exchange === null) {
176
+ throw new Error("exchangeService getRawCandles no exchange registered");
177
+ }
178
+ return await Exchange.getRawCandles(dto.symbol, dto.interval, {
179
+ exchangeName: exchange.exchangeName,
180
+ }, dto.limit, dto.sDate, dto.eDate);
181
+ };
170
182
  }
171
183
  }
172
184
 
@@ -500,6 +512,8 @@ class StatusMockService {
500
512
  positionLevels,
501
513
  positionEntries,
502
514
  positionPartials,
515
+ _peak: status._peak,
516
+ _fall: status._fall,
503
517
  };
504
518
  };
505
519
  }
@@ -794,6 +808,10 @@ class NotificationViewService {
794
808
  if (CC_ENABLE_MOCK) {
795
809
  return await this.notificationMockService.findByFilter(filterData, limit, offset);
796
810
  }
811
+ if (!Notification.enable.hasValue()) {
812
+ console.warn("@backtest-kit/ui notificationViewService findByFilter notifications not enabled");
813
+ return [];
814
+ }
797
815
  const iter = pickDocuments(limit, offset);
798
816
  const filterList = CREATE_FILTER_LIST_FN$1(filterData);
799
817
  for (const notification of await this.getList()) {
@@ -815,6 +833,10 @@ class NotificationViewService {
815
833
  if (CC_ENABLE_MOCK) {
816
834
  return await this.notificationMockService.getList();
817
835
  }
836
+ if (!Notification.enable.hasValue()) {
837
+ console.warn("@backtest-kit/ui notificationViewService getList notifications not enabled");
838
+ return [];
839
+ }
818
840
  const notificationList = [];
819
841
  for (const notification of await Notification.getData(false)) {
820
842
  notificationList.push(notification);
@@ -844,16 +866,13 @@ class NotificationViewService {
844
866
  if (CC_ENABLE_MOCK) {
845
867
  return await this.notificationMockService.getOne(id);
846
868
  }
869
+ if (!Notification.enable.hasValue()) {
870
+ console.warn("@backtest-kit/ui notificationViewService getOne notifications not enabled");
871
+ return null;
872
+ }
847
873
  const notificationList = await this.getList();
848
874
  return notificationList.find((item) => item.id === id) ?? null;
849
875
  };
850
- this.init = singleshot(async () => {
851
- this.loggerService.log("notificationViewService init");
852
- if (CC_ENABLE_MOCK) {
853
- return;
854
- }
855
- Notification.enable();
856
- });
857
876
  }
858
877
  }
859
878
 
@@ -868,6 +887,10 @@ class StorageViewService {
868
887
  if (CC_ENABLE_MOCK) {
869
888
  return await this.storageMockService.findSignalById(signalId);
870
889
  }
890
+ if (!Storage.enable.hasValue()) {
891
+ console.warn("@backtest-kit/ui storageViewService findSignalById storage not enabled");
892
+ return null;
893
+ }
871
894
  return await Storage.findSignalById(signalId);
872
895
  };
873
896
  this.listSignalLive = async () => {
@@ -875,6 +898,10 @@ class StorageViewService {
875
898
  if (CC_ENABLE_MOCK) {
876
899
  return await this.storageMockService.listSignalLive();
877
900
  }
901
+ if (!Storage.enable.hasValue()) {
902
+ console.warn("@backtest-kit/ui storageViewService listSignalLive storage not enabled");
903
+ return [];
904
+ }
878
905
  const signalList = await Storage.listSignalLive();
879
906
  signalList.sort((a, b) => {
880
907
  const aHasTime = "createdAt" in a;
@@ -896,6 +923,10 @@ class StorageViewService {
896
923
  if (CC_ENABLE_MOCK) {
897
924
  return await this.storageMockService.listSignalBacktest();
898
925
  }
926
+ if (!Storage.enable.hasValue()) {
927
+ console.warn("@backtest-kit/ui storageViewService listSignalBacktest storage not enabled");
928
+ return [];
929
+ }
899
930
  const signalList = await Storage.listSignalBacktest();
900
931
  signalList.sort((a, b) => {
901
932
  const aHasTime = "createdAt" in a;
@@ -912,13 +943,6 @@ class StorageViewService {
912
943
  });
913
944
  return signalList;
914
945
  };
915
- this.init = singleshot(async () => {
916
- this.loggerService.log("storageViewService init");
917
- if (CC_ENABLE_MOCK) {
918
- return;
919
- }
920
- Storage.enable();
921
- });
922
946
  }
923
947
  }
924
948
 
@@ -1167,6 +1191,8 @@ class StatusViewService {
1167
1191
  positionEntries,
1168
1192
  positionLevels,
1169
1193
  positionPartials,
1194
+ _peak: pendingSignal._peak,
1195
+ _fall: pendingSignal._fall,
1170
1196
  };
1171
1197
  };
1172
1198
  this.getStatusInfo = async () => {
@@ -1949,6 +1975,40 @@ router$a.post("/api/v1/mock/candles_point", async (req, res) => {
1949
1975
  });
1950
1976
  }
1951
1977
  });
1978
+ router$a.post("/api/v1/mock/candles_range", async (req, res) => {
1979
+ try {
1980
+ const request = await micro.json(req);
1981
+ const { symbol, interval, limit, sDate, eDate, requestId, serviceName } = request;
1982
+ const data = await ioc.exchangeService.getRawCandles({
1983
+ symbol,
1984
+ interval,
1985
+ limit,
1986
+ sDate,
1987
+ eDate,
1988
+ });
1989
+ const result = {
1990
+ data,
1991
+ status: "ok",
1992
+ error: "",
1993
+ requestId,
1994
+ serviceName,
1995
+ };
1996
+ ioc.loggerService.log("/api/v1/mock/candles_range ok", {
1997
+ request,
1998
+ result: omit(result, "data"),
1999
+ });
2000
+ return await micro.send(res, 200, result);
2001
+ }
2002
+ catch (error) {
2003
+ ioc.loggerService.log("/api/v1/mock/candles_range error", {
2004
+ error: errorData(error),
2005
+ });
2006
+ return await micro.send(res, 200, {
2007
+ status: "error",
2008
+ error: getErrorMessage(error),
2009
+ });
2010
+ }
2011
+ });
1952
2012
  // NotificationMockService endpoints
1953
2013
  router$a.post("/api/v1/mock/notification_list", async (req, res) => {
1954
2014
  try {
@@ -2530,6 +2590,40 @@ router$9.post("/api/v1/view/candles_point", async (req, res) => {
2530
2590
  });
2531
2591
  }
2532
2592
  });
2593
+ router$9.post("/api/v1/view/candles_range", async (req, res) => {
2594
+ try {
2595
+ const request = await micro.json(req);
2596
+ const { symbol, interval, limit, sDate, eDate, requestId, serviceName } = request;
2597
+ const data = await ioc.exchangeService.getRawCandles({
2598
+ symbol,
2599
+ interval,
2600
+ limit,
2601
+ sDate,
2602
+ eDate,
2603
+ });
2604
+ const result = {
2605
+ data,
2606
+ status: "ok",
2607
+ error: "",
2608
+ requestId,
2609
+ serviceName,
2610
+ };
2611
+ ioc.loggerService.log("/api/v1/view/candles_range ok", {
2612
+ request,
2613
+ result: omit(result, "data"),
2614
+ });
2615
+ return await micro.send(res, 200, result);
2616
+ }
2617
+ catch (error) {
2618
+ ioc.loggerService.log("/api/v1/view/candles_range error", {
2619
+ error: errorData(error),
2620
+ });
2621
+ return await micro.send(res, 200, {
2622
+ status: "error",
2623
+ error: getErrorMessage(error),
2624
+ });
2625
+ }
2626
+ });
2533
2627
  router$9.post("/api/v1/view/candles_live", async (req, res) => {
2534
2628
  try {
2535
2629
  const request = await micro.json(req);