sqlmath 2025.12.28 → 2026.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,21 @@
1
1
  # Changelog
2
2
 
3
3
  # Todo
4
- - betadog - Add function taskBacktest() to auto-remove features with low feature-importance.
5
4
  - sqlmath - Re-introduce sliding-discrete-fourier-transform to improve initial guess in sql-function WIN_SINEFIT2().
6
5
  - sqlite - Add similar error-handling from builtin-sql-function PERCENTILE() into custom-sql-function QUANTILE().
7
6
  - none
8
7
 
8
+ # v2026.2.28
9
+ - python-ci - Fix ruff lint-errors.
10
+ - jslint-ci - Update shell-function shCiBase() to check npm-version-support, before running npm-pkg-fix.
11
+
12
+ # v2026.1.31
13
+ - demo - Replace sector and subsector charts with subindustry chart.
14
+ - chart - Make tooltip more transparent, so datapoints behind it are more visible.
15
+ - chart - Cleanup chart _15_tradebot_tech_intra_1_month.
16
+ - chart - Add intraday-technical-indicator tradebot_tech_intra.spy_zcl.
17
+ - chart - Change time-scale of 1-month charts from 1-day to 15-minute/5-minute.
18
+
9
19
  # v2025.12.28
10
20
  - jslint - Upgrade to jslint-v2025.12.28.
11
21
  - sqlmath - Update function dbOpenAsync() with default-prm timeoutBusy=5000.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  # Status
5
- | Branch | [master<br>(v2025.12.28)](https://github.com/sqlmath/sqlmath/tree/master) | [beta<br>(Web Demo)](https://github.com/sqlmath/sqlmath/tree/beta) | [alpha<br>(Development)](https://github.com/sqlmath/sqlmath/tree/alpha) |
5
+ | Branch | [master<br>(v2026.2.28)](https://github.com/sqlmath/sqlmath/tree/master) | [beta<br>(Web Demo)](https://github.com/sqlmath/sqlmath/tree/beta) | [alpha<br>(Development)](https://github.com/sqlmath/sqlmath/tree/alpha) |
6
6
  |--:|:--:|:--:|:--:|
7
7
  | CI | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Amaster) | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=beta)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Abeta) | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=alpha)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Aalpha) |
8
8
  | Coverage | [![coverage](https://sqlmath.github.io/sqlmath/branch-master/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-master/.artifact/coverage/index.html) | [![coverage](https://sqlmath.github.io/sqlmath/branch-beta/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-beta/.artifact/coverage/index.html) | [![coverage](https://sqlmath.github.io/sqlmath/branch-alpha/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-alpha/.artifact/coverage/index.html) |
@@ -121,11 +121,11 @@ PORT=8080 sh jslint_ci.sh shHttpFileServer
121
121
  ```shell
122
122
  python -m build
123
123
  #
124
- twine upload --repository testpypi dist/sqlmath-2025.12.28*
125
- py -m pip install --index-url https://test.pypi.org/simple/ sqlmath==2025.12.28
124
+ twine upload --repository testpypi dist/sqlmath-2026.2.28*
125
+ py -m pip install --index-url https://test.pypi.org/simple/ sqlmath==2026.2.28
126
126
  #
127
- twine upload dist/sqlmath-2025.12.28*
128
- pip install sqlmath==2025.12.28
127
+ twine upload dist/sqlmath-2026.2.28*
128
+ pip install sqlmath==2026.2.28
129
129
  ```
130
130
 
131
131
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/jslint.mjs CHANGED
@@ -163,7 +163,7 @@ let jslint_charset_ascii = (
163
163
  + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
164
164
  + "`abcdefghijklmnopqrstuvwxyz{|}~\u007f"
165
165
  );
166
- let jslint_edition = "v2025.12.28";
166
+ let jslint_edition = "v2026.2.28";
167
167
  let jslint_export; // The jslint object to be exported.
168
168
  let jslint_fudge = 1; // Fudge starting line and starting
169
169
  // ... column to 1.
@@ -8195,7 +8195,7 @@ function jslint_phase4_walk(state) {
8195
8195
  // test_cause:
8196
8196
  // ["aa?true:false", "post_t", "expected_a_b", "?", 3]
8197
8197
 
8198
- warn("expected_a_b", thing, "!!", "?");
8198
+ warn("expected_a_b", thing, "Boolean(...)", "?");
8199
8199
  } else if (
8200
8200
  thing.expression[1].id === "false"
8201
8201
  && thing.expression[2].id === "true"
package/package.json CHANGED
@@ -32,5 +32,5 @@
32
32
  },
33
33
  "shCiArtifactUpload": 1,
34
34
  "shCiPublishNpm": 1,
35
- "version": "2025.12.28"
35
+ "version": "2026.2.28"
36
36
  }
package/sqlmath.mjs CHANGED
@@ -128,7 +128,7 @@ let {
128
128
  let sqlMessageDict = {}; // dict of web-worker-callbacks
129
129
  let sqlMessageId = 0;
130
130
  let sqlWorker;
131
- let version = "v2025.12.28";
131
+ let version = "v2026.2.28";
132
132
 
133
133
  async function assertErrorThrownAsync(asyncFunc, regexp) {
134
134
 
@@ -301,7 +301,7 @@ CREATE TABLE tradebot_intraday_day AS
301
301
  sym,
302
302
  xdate,
303
303
  price
304
- FROM tradebot_intraday_all
304
+ FROM tradebot_intraday
305
305
  WHERE xdate >= (SELECT datemkt0_beg FROM tradebot_state)
306
306
  --
307
307
  UNION ALL
@@ -314,117 +314,94 @@ CREATE TABLE tradebot_intraday_day AS
314
314
  JOIN tradebot_state
315
315
  WHERE tradebot_historical.xdate = datemkt0_lag;
316
316
 
317
- -- table - tradebot_intraday_week - insert
318
- DROP TABLE IF EXISTS tradebot_intraday_week;
319
- CREATE TABLE tradebot_intraday_week AS
317
+ -- table - tradebot_intraday_month - insert
318
+ DROP TABLE IF EXISTS tradebot_intraday_month;
319
+ CREATE TABLE tradebot_intraday_month AS
320
320
  SELECT
321
321
  sym,
322
322
  xdate,
323
323
  price
324
- FROM tradebot_intraday_all
324
+ FROM tradebot_intraday
325
325
  WHERE xdate = xdate2;
326
326
 
327
- -- table - tradebot_technical_day - insert - lmt
328
- DROP TABLE IF EXISTS tradebot_technical_day;
329
- CREATE TABLE tradebot_technical_day(tname TEXT, tt REAL, tval REAL);
330
- INSERT INTO tradebot_technical_day
327
+ -- table - tradebot_tech_intra_day - insert - lmt
328
+ DROP TABLE IF EXISTS tradebot_tech_intra_day;
329
+ CREATE TABLE tradebot_tech_intra_day(
330
+ tname TEXT,
331
+ xdate REAL,
332
+ xdate2 REAL,
333
+ tval REAL
334
+ );
335
+ INSERT INTO tradebot_tech_intra_day
331
336
  SELECT
332
337
  *
333
338
  FROM (
334
339
  SELECT
335
340
  tname,
336
- datemkt0_beg AS tt,
341
+ datemkt0_beg AS xdate,
342
+ datemkt0_beg AS xdate2,
337
343
  stk_beg0 AS tval
338
344
  FROM tradebot_state
339
345
  JOIN (
340
- SELECT '1b_stk_lmt' AS tname
341
- UNION ALL SELECT '1c_stk_pct'
342
- UNION ALL SELECT '1d_stk_lmb'
346
+ SELECT '1a_stk_pct' AS tname
347
+ --
348
+ UNION ALL
349
+ --
350
+ SELECT '1b_stk_lmt' AS tname
343
351
  )
344
352
  --
345
353
  UNION ALL
346
354
  --
347
- SELECT '1a_spy_cls', xdate, spy_cls FROM tradebot_technical_all
348
- --
349
- UNION ALL
350
- --
351
- SELECT '1b_stk_lmt', xdate, stk_lmt FROM tradebot_technical_all
352
- --
353
- UNION ALL
354
- --
355
- SELECT '1c_stk_pct', xdate, stk_pct FROM tradebot_technical_all
356
- --
357
- UNION ALL
358
- --
359
- SELECT '1d_stk_lmb', xdate, stk_lmb FROM tradebot_technical_all
360
- --
361
- UNION ALL
362
- --
363
- SELECT '1e_stk_pnl', xdate, stk_pnl FROM tradebot_technical_all
364
- --
365
- UNION ALL
366
- --
367
- SELECT '2a_spy_sin', xdate, spy_sin FROM tradebot_technical_all
368
- --
369
- UNION ALL
370
- --
371
- SELECT '2b_spy_cos', xdate, spy_cos FROM tradebot_technical_all
372
- )
373
- WHERE tt >= (SELECT datemkt0 FROM tradebot_state);
374
-
375
- -- table - tradebot_technical_week - insert - lmt
376
- DROP TABLE IF EXISTS tradebot_technical_week;
377
- CREATE TABLE tradebot_technical_week(tname TEXT, tt REAL, tval REAL);
378
- INSERT INTO tradebot_technical_week
379
- SELECT
380
- *
381
- FROM (
382
- SELECT
383
- tname,
384
- datemkt0_beg AS tt,
385
- stk_beg0 AS tval
386
- FROM tradebot_state
387
- JOIN (
388
- SELECT '1b_stk_lmt' AS tname
389
- UNION ALL SELECT '1c_stk_pct'
390
- UNION ALL SELECT '1d_stk_lmb'
391
- )
355
+ SELECT '1a_stk_pct', xdate, xdate2, stk_pct FROM tradebot_tech_intra
392
356
  --
393
357
  UNION ALL
394
358
  --
395
- SELECT '1a_spy_cls', xdate, spy_cls FROM tradebot_technical_all
359
+ SELECT '1b_stk_lmt', xdate, xdate2, stk_lmt FROM tradebot_tech_intra
396
360
  --
397
361
  UNION ALL
398
362
  --
399
- SELECT '1b_stk_lmt', xdate, stk_lmt FROM tradebot_technical_all
363
+ SELECT '1c_stk_pnl', xdate, xdate2, stk_pnl FROM tradebot_tech_intra
400
364
  --
401
365
  UNION ALL
402
366
  --
403
- SELECT '1c_stk_pct', xdate, stk_pct FROM tradebot_technical_all
367
+ SELECT '2a_spy_prc', xdate, xdate2, spy_prc FROM tradebot_tech_intra
404
368
  --
405
369
  UNION ALL
406
370
  --
407
- SELECT '1d_stk_lmb', xdate, stk_lmb FROM tradebot_technical_all
371
+ SELECT '2b_spy_cos', xdate, xdate2, spy_cos FROM tradebot_tech_intra
408
372
  --
409
373
  UNION ALL
410
374
  --
411
- SELECT '1e_stk_pnl', xdate, stk_pnl FROM tradebot_technical_all
375
+ SELECT '2c_spy_sin', xdate, xdate2, spy_sin FROM tradebot_tech_intra
412
376
  --
413
377
  UNION ALL
414
378
  --
415
- SELECT '2a_spy_sin', xdate, spy_sin FROM tradebot_technical_all
379
+ SELECT '2d_spy_syy', xdate, xdate2, spy_syy FROM tradebot_tech_intra
416
380
  --
417
381
  UNION ALL
418
382
  --
419
- SELECT '2b_spy_cos', xdate, spy_cos FROM tradebot_technical_all
383
+ SELECT '2e_spy_zcl', xdate, xdate2, spy_zcl FROM tradebot_tech_intra
420
384
  )
421
- WHERE tt;
385
+ WHERE xdate AND tval IS NOT NULL;
386
+
387
+ -- table - tradebot_tech_intra_month - insert - lmt
388
+ DROP TABLE IF EXISTS tradebot_tech_intra_month;
389
+ CREATE TABLE tradebot_tech_intra_month(
390
+ tname TEXT,
391
+ xdate REAL,
392
+ xdate2 REAL,
393
+ tval REAL
394
+ );
395
+ INSERT INTO tradebot_tech_intra_month
396
+ SELECT * FROM tradebot_tech_intra_day WHERE xdate = xdate2;
397
+ DELETE FROM tradebot_tech_intra_day
398
+ WHERE xdate < (SELECT datemkt0 FROM tradebot_state);
399
+ ALTER TABLE tradebot_tech_intra_day DROP COLUMN xdate2;
400
+ ALTER TABLE tradebot_tech_intra_month DROP COLUMN xdate2;
422
401
  `),
423
402
  [
424
403
  "1 day",
425
- "1 week",
426
404
  "1 month",
427
- "6 month",
428
405
  "ytd",
429
406
  "1 year",
430
407
  "5 year",
@@ -436,8 +413,8 @@ INSERT INTO tradebot_technical_week
436
413
  tableData = (
437
414
  dateInterval === "1 day"
438
415
  ? "tradebot_intraday_day"
439
- : dateInterval === "1 week"
440
- ? "tradebot_intraday_week"
416
+ : dateInterval === "1 month"
417
+ ? "tradebot_intraday_month"
441
418
  : "tradebot_historical"
442
419
  );
443
420
  tableChart = (
@@ -462,12 +439,12 @@ INSERT INTO tradebot_technical_week
462
439
  xstep: (
463
440
  dateInterval === "1 day"
464
441
  ? 60
465
- : dateInterval === "1 week"
442
+ : dateInterval === "1 month"
466
443
  ? 15 * 60
467
444
  : 1
468
445
  ),
469
446
  xvalueConvert: (
470
- (dateInterval === "1 day" || dateInterval === "1 week")
447
+ (dateInterval === "1 day" || dateInterval === "1 month")
471
448
  ? "unixepochToTimeutc"
472
449
  : "juliandayToDate"
473
450
  ),
@@ -495,7 +472,7 @@ INSERT INTO ${tableChart} (datatype, options, series_index, series_label)
495
472
  'series_label' AS datatype,
496
473
  JSON_OBJECT(
497
474
  'isDummy', is_dummy,
498
- 'isHidden', NOT sym IN ('11_mybot', 'spy', 'qqq', 'dia')
475
+ 'isHidden', NOT sym IN ('11_mybot', 'spy')
499
476
  ) AS options,
500
477
  rownum AS series_index,
501
478
  sym AS series_label
@@ -683,22 +660,22 @@ UPDATE ${tableChart}
683
660
  UPDATE ${tableChart}
684
661
  SET
685
662
  xx = ${(
686
- (dateInterval === "1 day" || dateInterval === "1 week")
687
- ? "UNIXEPOCH(tt)"
688
- : "JULIANDAY(tt)"
663
+ (dateInterval === "1 day" || dateInterval === "1 month")
664
+ ? "UNIXEPOCH(xdate)"
665
+ : "JULIANDAY(xdate)"
689
666
  )}
690
667
  FROM (
691
668
  --
692
669
  SELECT
693
670
  ${tableChart}.rowid,
694
671
  --
695
- tt
672
+ xdate
696
673
  FROM ${tableChart}
697
674
  --
698
675
  JOIN (
699
676
  SELECT
700
677
  xx,
701
- xx_label AS tt
678
+ xx_label AS xdate
702
679
  FROM ${tableChart}
703
680
  WHERE
704
681
  datatype = 'xx_label'
@@ -728,13 +705,12 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
728
705
  datatype = 'yy_value'
729
706
  )
730
707
  WHERE
731
- ${(dateInterval === "1 day" || dateInterval === "1 week")};
708
+ ${(dateInterval === "1 day" || dateInterval === "1 month")};
732
709
  DELETE FROM ${tableChart} WHERE datatype = 'xx_label';
733
710
  `);
734
711
  }),
735
712
  [
736
- "sector",
737
- "subsector",
713
+ "subindustry",
738
714
  "stock"
739
715
  ].map(function (grouping) {
740
716
  return [
@@ -762,65 +738,12 @@ DELETE FROM ${tableChart} WHERE datatype = 'xx_label';
762
738
  yvalueSuffix: " %"
763
739
  };
764
740
  sqlSelect = (
765
- grouping === "sector"
741
+ grouping === "subindustry"
766
742
  ? (`
767
743
  SELECT
768
744
  (CASE
769
745
  WHEN (category LIKE 'index%') THEN 3
770
- WHEN (category LIKE 'short%') THEN 1
771
- WHEN (grouping = 'sector') THEN 4
772
- ELSE grouping_index
773
- END) AS series_color,
774
- category LIKE '-%' AS is_dummy,
775
- -- 0 AS is_hidden,
776
- grouping IN ('account', 'exchange') AS is_hidden,
777
- printf(
778
- '%05.4f%% - %s - %s',
779
- ${columnData},
780
- grouping,
781
- category
782
- ) AS series_label,
783
- ROW_NUMBER() OVER (
784
- ORDER BY
785
- grouping_index,
786
- category != '----' DESC,
787
- ${columnData} DESC
788
- ) AS xx,
789
- category AS xx_label,
790
- ${columnData} AS yy
791
- FROM (
792
- SELECT
793
- category,
794
- grouping,
795
- grouping_index,
796
- ${columnData},
797
- perc_holding
798
- FROM tradebot_position_category
799
- WHERE
800
- grouping != 'subsector'
801
- --
802
- UNION ALL
803
- --
804
- SELECT
805
- '----' AS category,
806
- '----' AS grouping,
807
- grouping_index,
808
- NULL AS ${columnData},
809
- NULL perc_holding
810
- FROM (
811
- SELECT DISTINCT
812
- grouping,
813
- grouping_index
814
- FROM tradebot_position_category
815
- )
816
- )
817
- `)
818
- : grouping === "subsector"
819
- ? (`
820
- SELECT
821
- (CASE
822
- WHEN (category LIKE 'index%') THEN 3
823
- WHEN (category LIKE 'short%') THEN 1
746
+ WHEN (category LIKE '___-') THEN 1
824
747
  ELSE 5
825
748
  END) AS series_color,
826
749
  category LIKE '-%' AS is_dummy,
@@ -832,7 +755,7 @@ SELECT
832
755
  category != '----' DESC,
833
756
  ${columnData} DESC
834
757
  ) AS xx,
835
- SUBSTR(category, INSTR(category, '____') + 4) AS xx_label,
758
+ category AS xx_label,
836
759
  ${columnData} AS yy
837
760
  FROM (
838
761
  SELECT
@@ -843,14 +766,14 @@ SELECT
843
766
  perc_holding
844
767
  FROM tradebot_position_category
845
768
  WHERE
846
- grouping = 'subsector'
769
+ grouping = 'subindustry'
847
770
  )
848
771
  `)
849
772
  : (`
850
773
  SELECT
851
774
  (CASE
852
- WHEN (sector = 'index') THEN 3
853
- WHEN (sector = 'short') THEN 1
775
+ WHEN (subindustry LIKE '___+') THEN 3
776
+ WHEN (subindustry LIKE '___-') THEN 1
854
777
  ELSE 2
855
778
  END) AS series_color,
856
779
  0 AS is_dummy,
@@ -941,8 +864,8 @@ CREATE TEMP TABLE __tmp1 AS
941
864
  FROM (
942
865
  SELECT
943
866
  (CASE
944
- WHEN (sector LIKE 'index%') THEN 3
945
- WHEN (sector LIKE 'short%') THEN 1
867
+ WHEN (subindustry LIKE '___+') THEN 3
868
+ WHEN (subindustry LIKE '___-') THEN 1
946
869
  ELSE 2
947
870
  END) AS series_color,
948
871
  (
@@ -1018,27 +941,27 @@ INSERT INTO chart._{{ii}}_tradebot_buysell_history (
1018
941
  `),
1019
942
  [
1020
943
  "1 day",
1021
- "1 week"
944
+ "1 month"
1022
945
  ].map(function (dateInterval) {
1023
946
  let optionDict;
1024
947
  let tableChart;
1025
948
  let tableData;
1026
949
  tableData = (
1027
950
  dateInterval === "1 day"
1028
- ? "tradebot_technical_day"
1029
- : dateInterval === "1 week"
1030
- ? "tradebot_technical_week"
1031
- : "tradebot_technical"
951
+ ? "tradebot_tech_intra_day"
952
+ : dateInterval === "1 month"
953
+ ? "tradebot_tech_intra_month"
954
+ : "tradebot_tech_intra"
1032
955
  );
1033
956
  tableChart = (
1034
- "chart._{{ii}}_tradebot_technical_"
957
+ "chart._{{ii}}_tradebot_tech_intra_"
1035
958
  + dateInterval.replace((
1036
959
  /\W/g
1037
960
  ), "_")
1038
961
  );
1039
962
  optionDict = {
1040
963
  title: (
1041
- "tradebot technical - "
964
+ "tradebot technical intraday - "
1042
965
  + dateInterval
1043
966
  + (
1044
967
  dateInterval === "1 day"
@@ -1052,13 +975,12 @@ INSERT INTO chart._{{ii}}_tradebot_buysell_history (
1052
975
  xstep: (
1053
976
  dateInterval === "1 day"
1054
977
  ? 60
1055
- : dateInterval === "1 week"
1056
- ? 60
1057
- // ? 15 * 60
978
+ : dateInterval === "1 month"
979
+ ? 5 * 60
1058
980
  : 1
1059
981
  ),
1060
982
  xvalueConvert: (
1061
- (dateInterval === "1 day" || dateInterval === "1 week")
983
+ (dateInterval === "1 day" || dateInterval === "1 month")
1062
984
  ? "unixepochToTimeutc"
1063
985
  : "juliandayToDate"
1064
986
  ),
@@ -1066,77 +988,9 @@ INSERT INTO chart._{{ii}}_tradebot_buysell_history (
1066
988
  yvalueSuffix: " %"
1067
989
  };
1068
990
  return (`
1069
- -- table - ${tableData} - normalize
1070
991
  UPDATE ${tableData}
1071
992
  SET
1072
- tval = (CASE
1073
- WHEN (tname = '1a_spy_cls') THEN
1074
- (lmt_eee * cls_inv) * (tval - cls_avg) + lmt_avg
1075
- WHEN (tname = '1e_stk_pnl') THEN
1076
- (lmt_eee * pnl_inv) * (tval - pnl_avg) + lmt_avg
1077
- WHEN (tname = '2a_spy_sin') THEN
1078
- (lmt_eee * sin_inv) * (tval - sin_avg) + lmt_avg
1079
- WHEN (tname = '2b_spy_cos') THEN
1080
- (lmt_eee * cos_inv) * (tval - cos_avg) + lmt_avg
1081
- END)
1082
- FROM (
1083
- SELECT
1084
- lmt_avg,
1085
- lmt_eee,
1086
- --
1087
- pnl_avg,
1088
- pnl_inv,
1089
- --
1090
- cls_avg,
1091
- cls_inv,
1092
- --
1093
- cos_avg,
1094
- cos_inv,
1095
- --
1096
- sin_avg,
1097
- sin_inv
1098
- FROM (SELECT 0)
1099
- JOIN (
1100
- SELECT
1101
- MEDIAN(tval) AS cls_avg,
1102
- 1.0 / STDEV(tval) AS cls_inv
1103
- FROM ${tableData}
1104
- WHERE tname = '1a_spy_cls'
1105
- )
1106
- JOIN (
1107
- SELECT
1108
- MEDIAN(tval) AS lmt_avg,
1109
- STDEV(tval) AS lmt_eee
1110
- FROM ${tableData}
1111
- WHERE tname = '1b_stk_lmt'
1112
- )
1113
- JOIN (
1114
- SELECT
1115
- MEDIAN(tval) AS pnl_avg,
1116
- 1.0 / STDEV(tval) AS pnl_inv
1117
- FROM ${tableData}
1118
- WHERE tname = '1e_stk_pnl'
1119
- )
1120
- JOIN (
1121
- SELECT
1122
- MEDIAN(tval) AS cos_avg,
1123
- 1.0 / STDEV(tval) AS cos_inv
1124
- FROM ${tableData}
1125
- WHERE tname = '2a_spy_sin'
1126
- )
1127
- JOIN (
1128
- SELECT
1129
- MEDIAN(tval) AS sin_avg,
1130
- 1.0 / STDEV(tval) AS sin_inv
1131
- FROM ${tableData}
1132
- WHERE tname = '2b_spy_cos'
1133
- )
1134
- ) AS __join1
1135
- WHERE
1136
- tname IN ('1a_spy_cls', '1e_stk_pnl', '2a_spy_sin', '2b_spy_cos');
1137
- UPDATE ${tableData}
1138
- SET
1139
- tt = UNIXEPOCH(tt),
993
+ xdate = UNIXEPOCH(xdate),
1140
994
  tval = ROUNDORZERO(tval, 4);
1141
995
 
1142
996
  -- chart - ${tableChart} - create
@@ -1160,20 +1014,10 @@ INSERT INTO ${tableChart} (datatype, options, series_index, series_label)
1160
1014
  'series_label' AS datatype,
1161
1015
  JSON_OBJECT(
1162
1016
  'isHidden', NOT tname IN (
1163
- '1a_spy_cls', '1b_stk_lmt', '1c_stk_pct'
1164
- ),
1165
- 'seriesColor', (CASE
1166
- WHEN (tname = '1d_stk_lmb') THEN
1167
- '#999'
1168
- ELSE
1169
- NULL
1170
- -- (
1171
- -- '#'
1172
- -- || printf('%x', 12 - 2 * rownum)
1173
- -- || printf('%x', 0 + 2 * rownum)
1174
- -- || printf('%x', 16 - 2 * rownum)
1175
- -- )
1176
- END)
1017
+ -- '1a_stk_pct',
1018
+ -- '1b_stk_lmt',
1019
+ '2a_spy_prc'
1020
+ )
1177
1021
  ) AS options,
1178
1022
  rownum AS series_index,
1179
1023
  tname AS series_label
@@ -1189,12 +1033,12 @@ INSERT INTO ${tableChart} (datatype, xx, xx_label)
1189
1033
  SELECT
1190
1034
  'xx_label' AS datatype,
1191
1035
  rownum AS xx,
1192
- tt AS xx_label
1036
+ xdate AS xx_label
1193
1037
  FROM (
1194
1038
  SELECT
1195
- ROW_NUMBER() OVER (ORDER BY tt) AS rownum,
1196
- tt
1197
- FROM (SELECT DISTINCT tt FROM ${tableData})
1039
+ ROW_NUMBER() OVER (ORDER BY xdate) AS rownum,
1040
+ xdate
1041
+ FROM (SELECT DISTINCT xdate FROM ${tableData})
1198
1042
  );
1199
1043
  INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1200
1044
  SELECT
@@ -1225,25 +1069,12 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1225
1069
  datatype = 'xx_label'
1226
1070
  )
1227
1071
  )
1228
- LEFT JOIN ${tableData} ON tname = series_label AND tt = xx_label;
1072
+ LEFT JOIN ${tableData} ON tname = series_label AND xdate = xx_label;
1229
1073
  DELETE FROM ${tableChart} WHERE datatype = 'xx_label';
1230
- UPDATE ${tableChart}
1231
- SET
1232
- series_label = (CASE
1233
- WHEN (series_label = '1a_spy_cls') THEN '1a spy change'
1234
- WHEN (series_label = '1b_stk_lmt') THEN '1b stk holding ideal'
1235
- WHEN (series_label = '1c_stk_pct') THEN '1c stk holding actual'
1236
- WHEN (series_label = '1d_stk_lmb') THEN '1d stk holding bracket min'
1237
- WHEN (series_label = '1e_stk_pnl') THEN '1e stk gain'
1238
- WHEN (series_label = '2a_spy_sin') THEN '2a spy sine'
1239
- WHEN (series_label = '2b_spy_cos') THEN '2b spy cosine'
1240
- END)
1241
- WHERE
1242
- datatype = 'series_label';
1243
1074
  `);
1244
1075
  }),
1245
1076
  (function () {
1246
- let tableChart = `chart._{{ii}}_tradebot_technical_sinefit`;
1077
+ let tableChart = `chart._{{ii}}_tradebot_tech_hist_1_year`;
1247
1078
  return (`
1248
1079
  CREATE TABLE ${tableChart} (
1249
1080
  datatype TEXT NOT NULL,
@@ -1260,7 +1091,7 @@ INSERT INTO ${tableChart} (datatype, options)
1260
1091
  SELECT
1261
1092
  'options' AS datatype,
1262
1093
  '{
1263
- "title": "tradebot technical - sinusoidal fit of spy",
1094
+ "title": "tradebot technical historical - 1 year",
1264
1095
  "xaxisTitle": "date",
1265
1096
  "xvalueConvert": "juliandayToDate",
1266
1097
  "yaxisTitle": "percent gain",
@@ -1294,7 +1125,10 @@ INSERT INTO ${tableChart} (datatype, xx, xx_label)
1294
1125
  JULIANDAY(xdate) AS xx,
1295
1126
  xdate AS xx_label
1296
1127
  FROM (
1297
- SELECT DISTINCT xdate FROM tradebot_technical_sinefit ORDER BY ttt DESC
1128
+ SELECT DISTINCT
1129
+ xdate
1130
+ FROM tradebot_tech_histo
1131
+ ORDER BY ttt DESC
1298
1132
  );
1299
1133
  INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1300
1134
  SELECT
@@ -1308,7 +1142,7 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1308
1142
  1 AS series_index,
1309
1143
  xdate,
1310
1144
  price_actual AS yy
1311
- FROM tradebot_technical_sinefit
1145
+ FROM tradebot_tech_histo
1312
1146
  --
1313
1147
  UNION ALL
1314
1148
  --
@@ -1316,7 +1150,7 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1316
1150
  2 AS series_index,
1317
1151
  xdate,
1318
1152
  price_linear_02 AS yy
1319
- FROM tradebot_technical_sinefit
1153
+ FROM tradebot_tech_histo
1320
1154
  --
1321
1155
  UNION ALL
1322
1156
  --
@@ -1324,11 +1158,11 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1324
1158
  3 AS series_index,
1325
1159
  xdate,
1326
1160
  price_sine_02 + __offset AS yy
1327
- FROM tradebot_technical_sinefit
1161
+ FROM tradebot_tech_histo
1328
1162
  JOIN (
1329
1163
  SELECT
1330
1164
  price_actual - price_sine_02 AS __offset
1331
- FROM tradebot_technical_sinefit
1165
+ FROM tradebot_tech_histo
1332
1166
  WHERE
1333
1167
  ttt = 1
1334
1168
  )
@@ -1339,7 +1173,7 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1339
1173
  4 AS series_index,
1340
1174
  xdate,
1341
1175
  price_predicted_02 AS yy
1342
- FROM tradebot_technical_sinefit
1176
+ FROM tradebot_tech_histo
1343
1177
  --
1344
1178
  UNION ALL
1345
1179
  --
@@ -1347,7 +1181,7 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1347
1181
  5 AS series_index,
1348
1182
  xdate,
1349
1183
  price_linear_06 AS yy
1350
- FROM tradebot_technical_sinefit
1184
+ FROM tradebot_tech_histo
1351
1185
  --
1352
1186
  UNION ALL
1353
1187
  --
@@ -1355,11 +1189,11 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1355
1189
  6 AS series_index,
1356
1190
  xdate,
1357
1191
  price_sine_06 + __offset AS yy
1358
- FROM tradebot_technical_sinefit
1192
+ FROM tradebot_tech_histo
1359
1193
  JOIN (
1360
1194
  SELECT
1361
1195
  price_actual - price_sine_06 AS __offset
1362
- FROM tradebot_technical_sinefit
1196
+ FROM tradebot_tech_histo
1363
1197
  WHERE
1364
1198
  ttt = 1
1365
1199
  )
@@ -1370,8 +1204,9 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1370
1204
  7 AS series_index,
1371
1205
  xdate,
1372
1206
  price_predicted_06 AS yy
1373
- FROM tradebot_technical_sinefit
1374
- ) ON xdate = xx_label;
1207
+ FROM tradebot_tech_histo
1208
+ ) ON xdate = xx_label
1209
+ WHERE yy IS NOT NULL;
1375
1210
 
1376
1211
  -- table - ${tableChart} - normalize - yy
1377
1212
  UPDATE ${tableChart}
@@ -1380,9 +1215,9 @@ UPDATE ${tableChart}
1380
1215
  FROM (
1381
1216
  SELECT
1382
1217
  100.0 / price_actual AS __inv
1383
- FROM tradebot_technical_sinefit
1218
+ FROM tradebot_tech_histo
1384
1219
  WHERE
1385
- ttt = (SELECT MAX(ttt) FROM tradebot_technical_sinefit)
1220
+ ttt = (SELECT MAX(ttt) FROM tradebot_tech_histo)
1386
1221
  );
1387
1222
  UPDATE ${tableChart}
1388
1223
  SET
@@ -3098,7 +2933,7 @@ SELECT
3098
2933
  <g class="uichartTooltip" visibility="hidden">
3099
2934
  <rect
3100
2935
  class="uichartTooltipBorder"
3101
- fill-opacity="0.8000"
2936
+ fill-opacity="0.6667"
3102
2937
  fill="#fff"
3103
2938
  rx="5"
3104
2939
  ry="5"
@@ -3481,21 +3316,24 @@ SELECT
3481
3316
  // update elemTooltipText
3482
3317
  elemTooltip.setAttribute("visibility", "visible");
3483
3318
  elemTooltipText.innerHTML = (`
3484
- <tspan dy="17" x="6">${stringHtmlSafe(seriesHovered.seriesName)}</tspan>
3485
- <tspan dy="17" x="6">x: ${stringHtmlSafe(xlabel)}</tspan>
3486
3319
  <tspan
3487
- dy="19"
3488
- style="font-size: 14px; font-weight: bold;"
3489
- x="6"
3490
- >y: ${stringHtmlSafe(ylabel)}</tspan>
3320
+ dy="15"
3321
+ style="filter: brightness(75%); font-size: 14px; font-weight: normal;"
3322
+ x="5"
3323
+ >
3324
+ ${stringHtmlSafe(ylabel)} -- ${stringHtmlSafe(xlabel)}
3325
+ </tspan>
3491
3326
  `);
3327
+ svgAttrSet(elemTooltipText, {
3328
+ fill: seriesHovered.seriesColor
3329
+ });
3492
3330
  // update elemTooltipBorder after text-update
3493
3331
  tooltipBbox = elemTooltipText.getBBox();
3494
3332
  tooltipWidth = tooltipBbox.width + 10;
3495
- tooltipHeight = tooltipBbox.height + 10;
3333
+ tooltipHeight = tooltipBbox.height + 0;
3496
3334
  svgAttrSet(elemTooltipBorder, {
3497
3335
  height: tooltipHeight,
3498
- stroke: seriesHovered.seriesColor,
3336
+ // stroke: seriesHovered.seriesColor,
3499
3337
  width: tooltipWidth
3500
3338
  });
3501
3339
  // calculate tooltipX