sqlmath 2025.9.30 → 2026.1.31

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
@@ -5,6 +5,18 @@
5
5
  - sqlite - Add similar error-handling from builtin-sql-function PERCENTILE() into custom-sql-function QUANTILE().
6
6
  - none
7
7
 
8
+ # v2026.1.31
9
+ - demo - Replace sector and subsector charts with subindustry chart.
10
+ - chart - Make tooltip more transparent, so datapoints behind it are more visible.
11
+ - chart - Cleanup chart _15_tradebot_tech_intra_1_month.
12
+ - chart - Add intraday-technical-indicator tradebot_tech_intra.spy_zcl.
13
+ - chart - Change time-scale of 1-month charts from 1-day to 15-minute/5-minute.
14
+
15
+ # v2025.12.28
16
+ - jslint - Upgrade to jslint-v2025.12.28.
17
+ - sqlmath - Update function dbOpenAsync() with default-prm timeoutBusy=5000.
18
+ - ci - Upgrade nodejs used in ci to v24.
19
+
8
20
  # v2025.9.30
9
21
  - sqlmath - Update function dbExecProfile() with additional-arg sqlLength.
10
22
  - sqlmath - Update function dbOpenAsync() with default-filename :memory:.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  # Status
5
- | Branch | [master<br>(v2025.9.30)](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.1.31)](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.9.30*
125
- py -m pip install --index-url https://test.pypi.org/simple/ sqlmath==2025.9.30
124
+ twine upload --repository testpypi dist/sqlmath-2026.1.31*
125
+ py -m pip install --index-url https://test.pypi.org/simple/ sqlmath==2026.1.31
126
126
  #
127
- twine upload dist/sqlmath-2025.9.30*
128
- pip install sqlmath==2025.9.30
127
+ twine upload dist/sqlmath-2026.1.31*
128
+ pip install sqlmath==2026.1.31
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
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.9.1-beta";
166
+ let jslint_edition = "v2025.12.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.
@@ -4674,7 +4674,13 @@ function jslint_phase3_parse(state) {
4674
4674
 
4675
4675
  test_cause("free");
4676
4676
  the_paren.free = true;
4677
- if (the_argument.wrapped === true) {
4677
+ if (
4678
+ the_argument.wrapped === true
4679
+
4680
+ // PR-483 - Allow parenthesis after ellipsis inside a function call.
4681
+
4682
+ && the_argument.ellipsis !== true
4683
+ ) {
4678
4684
 
4679
4685
  // test_cause:
4680
4686
  // ["aa((0))", "infix_lparen", "unexpected_a", "(", 3]
@@ -5158,6 +5164,10 @@ function jslint_phase3_parse(state) {
5158
5164
  the_label.dead = false;
5159
5165
  the_label.init = true;
5160
5166
  the_statement = parse_statement();
5167
+
5168
+ // Issue #458 - Regression - Warn about variable usage before initialization.
5169
+
5170
+ the_label.dead = true;
5161
5171
  functionage.statement_prv = the_statement;
5162
5172
  the_statement.label = the_label;
5163
5173
  the_statement.statement = true;
@@ -5204,9 +5214,13 @@ function jslint_phase3_parse(state) {
5204
5214
  }
5205
5215
  semicolon();
5206
5216
  }
5207
- if (the_label !== undefined) {
5208
- the_label.dead = true;
5209
- }
5217
+
5218
+ // Issue #458 - Regression - Warn about variable usage before initialization.
5219
+
5220
+ // if (the_label !== undefined) {
5221
+ // the_label.dead = true;
5222
+ // }
5223
+
5210
5224
  return the_statement;
5211
5225
  }
5212
5226
 
@@ -6987,8 +7001,16 @@ function jslint_phase3_parse(state) {
6987
7001
  the_variable.names.push(name);
6988
7002
  enroll(name, "variable", mode_const);
6989
7003
  }
6990
- name.dead = false;
7004
+
7005
+ // Issue #458 - Regression - Warn about variable usage before initialization.
7006
+
7007
+ // name.dead = false;
7008
+
6991
7009
  name.init = true;
7010
+
7011
+ // test_cause:
7012
+ // ["const {aa}=bb;\nconst bb=0;", "lookup", "out_of_scope_a", "bb", 12]
7013
+
6992
7014
  if (token_nxt.id === "=") {
6993
7015
 
6994
7016
  // test_cause:
@@ -7039,8 +7061,16 @@ function jslint_phase3_parse(state) {
7039
7061
  advance();
7040
7062
  the_variable.names.push(name);
7041
7063
  enroll(name, "variable", mode_const);
7042
- name.dead = false;
7064
+
7065
+ // Issue #458 - Regression - Warn about variable usage before initialization.
7066
+
7067
+ // name.dead = false;
7068
+
7043
7069
  name.init = true;
7070
+
7071
+ // test_cause:
7072
+ // ["const [aa]=bb;\nconst bb=0;", "lookup", "out_of_scope_a", "bb", 12]
7073
+
7044
7074
  if (ellipsis) {
7045
7075
  name.ellipsis = true;
7046
7076
  break;
@@ -7073,8 +7103,16 @@ function jslint_phase3_parse(state) {
7073
7103
  enroll(name, "variable", mode_const);
7074
7104
  if (token_nxt.id === "=" || mode_const) {
7075
7105
  advance("=");
7076
- name.dead = false;
7106
+
7107
+ // Issue #458 - Regression - Warn about variable usage before initialization.
7108
+
7109
+ // name.dead = false;
7110
+
7077
7111
  name.init = true;
7112
+
7113
+ // test_cause:
7114
+ // ["const aa=bb;\nconst bb=0;", "lookup", "out_of_scope_a", "bb", 10]
7115
+
7078
7116
  name.expression = parse_expression(0);
7079
7117
  }
7080
7118
  the_variable.names.push(name);
package/package.json CHANGED
@@ -32,5 +32,5 @@
32
32
  },
33
33
  "shCiArtifactUpload": 1,
34
34
  "shCiPublishNpm": 1,
35
- "version": "2025.9.30"
35
+ "version": "2026.1.31"
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.9.30";
131
+ let version = "v2026.1.31";
132
132
 
133
133
  async function assertErrorThrownAsync(asyncFunc, regexp) {
134
134
 
@@ -1003,7 +1003,8 @@ async function dbOpenAsync({
1003
1003
  dbData,
1004
1004
  filename = ":memory:",
1005
1005
  flags,
1006
- threadCount = 1
1006
+ threadCount = 1,
1007
+ timeoutBusy = 5000
1007
1008
  }) {
1008
1009
 
1009
1010
  // This function will open and return sqlite-database-connection <db>.
@@ -1057,7 +1058,10 @@ async function dbOpenAsync({
1057
1058
  libLgbm = `${import.meta.dirname}/sqlmath/${libLgbm}`;
1058
1059
  await dbExecAsync({
1059
1060
  db,
1060
- sql: `SELECT LGBM_DLOPEN('${libLgbm}');`
1061
+ sql: (`
1062
+ PRAGMA busy_timeout = ${timeoutBusy};
1063
+ SELECT LGBM_DLOPEN('${libLgbm}');
1064
+ `)
1061
1065
  });
1062
1066
  }
1063
1067
  return db;
@@ -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,102 @@ 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
351
+ --
352
+ UNION ALL
353
+ --
354
+ SELECT '1c_stk_lmb' AS tname
343
355
  )
344
356
  --
345
357
  UNION ALL
346
358
  --
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
359
+ SELECT '1a_stk_pct', xdate, xdate2, stk_pct FROM tradebot_tech_intra
356
360
  --
357
361
  UNION ALL
358
362
  --
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
- )
363
+ SELECT '1b_stk_lmt', xdate, xdate2, stk_lmt FROM tradebot_tech_intra
392
364
  --
393
365
  UNION ALL
394
366
  --
395
- SELECT '1a_spy_cls', xdate, spy_cls FROM tradebot_technical_all
367
+ SELECT '1c_stk_lmb', xdate, xdate2, stk_lmb FROM tradebot_tech_intra
396
368
  --
397
369
  UNION ALL
398
370
  --
399
- SELECT '1b_stk_lmt', xdate, stk_lmt FROM tradebot_technical_all
371
+ SELECT '1d_stk_pnl', xdate, xdate2, stk_pnl FROM tradebot_tech_intra
400
372
  --
401
373
  UNION ALL
402
374
  --
403
- SELECT '1c_stk_pct', xdate, stk_pct FROM tradebot_technical_all
375
+ SELECT '2a_spy_prc', xdate, xdate2, spy_prc FROM tradebot_tech_intra
404
376
  --
405
377
  UNION ALL
406
378
  --
407
- SELECT '1d_stk_lmb', xdate, stk_lmb FROM tradebot_technical_all
379
+ SELECT '2b_spy_cos', xdate, xdate2, spy_cos FROM tradebot_tech_intra
408
380
  --
409
381
  UNION ALL
410
382
  --
411
- SELECT '1e_stk_pnl', xdate, stk_pnl FROM tradebot_technical_all
383
+ SELECT '2c_spy_sin', xdate, xdate2, spy_sin FROM tradebot_tech_intra
412
384
  --
413
385
  UNION ALL
414
386
  --
415
- SELECT '2a_spy_sin', xdate, spy_sin FROM tradebot_technical_all
387
+ SELECT '2d_spy_syy', xdate, xdate2, spy_syy FROM tradebot_tech_intra
416
388
  --
417
389
  UNION ALL
418
390
  --
419
- SELECT '2b_spy_cos', xdate, spy_cos FROM tradebot_technical_all
391
+ SELECT '2e_spy_zcl', xdate, xdate2, spy_zcl FROM tradebot_tech_intra
420
392
  )
421
- WHERE tt;
393
+ WHERE xdate AND tval IS NOT NULL;
394
+
395
+ -- table - tradebot_tech_intra_month - insert - lmt
396
+ DROP TABLE IF EXISTS tradebot_tech_intra_month;
397
+ CREATE TABLE tradebot_tech_intra_month(
398
+ tname TEXT,
399
+ xdate REAL,
400
+ xdate2 REAL,
401
+ tval REAL
402
+ );
403
+ INSERT INTO tradebot_tech_intra_month
404
+ SELECT * FROM tradebot_tech_intra_day WHERE xdate = xdate2;
405
+ DELETE FROM tradebot_tech_intra_day
406
+ WHERE xdate < (SELECT datemkt0 FROM tradebot_state);
407
+ ALTER TABLE tradebot_tech_intra_day DROP COLUMN xdate2;
408
+ ALTER TABLE tradebot_tech_intra_month DROP COLUMN xdate2;
422
409
  `),
423
410
  [
424
411
  "1 day",
425
- "1 week",
426
412
  "1 month",
427
- "6 month",
428
413
  "ytd",
429
414
  "1 year",
430
415
  "5 year",
@@ -436,8 +421,8 @@ INSERT INTO tradebot_technical_week
436
421
  tableData = (
437
422
  dateInterval === "1 day"
438
423
  ? "tradebot_intraday_day"
439
- : dateInterval === "1 week"
440
- ? "tradebot_intraday_week"
424
+ : dateInterval === "1 month"
425
+ ? "tradebot_intraday_month"
441
426
  : "tradebot_historical"
442
427
  );
443
428
  tableChart = (
@@ -462,12 +447,12 @@ INSERT INTO tradebot_technical_week
462
447
  xstep: (
463
448
  dateInterval === "1 day"
464
449
  ? 60
465
- : dateInterval === "1 week"
450
+ : dateInterval === "1 month"
466
451
  ? 15 * 60
467
452
  : 1
468
453
  ),
469
454
  xvalueConvert: (
470
- (dateInterval === "1 day" || dateInterval === "1 week")
455
+ (dateInterval === "1 day" || dateInterval === "1 month")
471
456
  ? "unixepochToTimeutc"
472
457
  : "juliandayToDate"
473
458
  ),
@@ -495,7 +480,7 @@ INSERT INTO ${tableChart} (datatype, options, series_index, series_label)
495
480
  'series_label' AS datatype,
496
481
  JSON_OBJECT(
497
482
  'isDummy', is_dummy,
498
- 'isHidden', NOT sym IN ('11_mybot', 'spy', 'qqq', 'dia')
483
+ 'isHidden', NOT sym IN ('11_mybot', 'spy')
499
484
  ) AS options,
500
485
  rownum AS series_index,
501
486
  sym AS series_label
@@ -683,22 +668,22 @@ UPDATE ${tableChart}
683
668
  UPDATE ${tableChart}
684
669
  SET
685
670
  xx = ${(
686
- (dateInterval === "1 day" || dateInterval === "1 week")
687
- ? "UNIXEPOCH(tt)"
688
- : "JULIANDAY(tt)"
671
+ (dateInterval === "1 day" || dateInterval === "1 month")
672
+ ? "UNIXEPOCH(xdate)"
673
+ : "JULIANDAY(xdate)"
689
674
  )}
690
675
  FROM (
691
676
  --
692
677
  SELECT
693
678
  ${tableChart}.rowid,
694
679
  --
695
- tt
680
+ xdate
696
681
  FROM ${tableChart}
697
682
  --
698
683
  JOIN (
699
684
  SELECT
700
685
  xx,
701
- xx_label AS tt
686
+ xx_label AS xdate
702
687
  FROM ${tableChart}
703
688
  WHERE
704
689
  datatype = 'xx_label'
@@ -728,13 +713,12 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
728
713
  datatype = 'yy_value'
729
714
  )
730
715
  WHERE
731
- ${(dateInterval === "1 day" || dateInterval === "1 week")};
716
+ ${(dateInterval === "1 day" || dateInterval === "1 month")};
732
717
  DELETE FROM ${tableChart} WHERE datatype = 'xx_label';
733
718
  `);
734
719
  }),
735
720
  [
736
- "sector",
737
- "subsector",
721
+ "subindustry",
738
722
  "stock"
739
723
  ].map(function (grouping) {
740
724
  return [
@@ -762,60 +746,7 @@ DELETE FROM ${tableChart} WHERE datatype = 'xx_label';
762
746
  yvalueSuffix: " %"
763
747
  };
764
748
  sqlSelect = (
765
- grouping === "sector"
766
- ? (`
767
- SELECT
768
- (CASE
769
- 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"
749
+ grouping === "subindustry"
819
750
  ? (`
820
751
  SELECT
821
752
  (CASE
@@ -843,14 +774,14 @@ SELECT
843
774
  perc_holding
844
775
  FROM tradebot_position_category
845
776
  WHERE
846
- grouping = 'subsector'
777
+ grouping = 'subindustry'
847
778
  )
848
779
  `)
849
780
  : (`
850
781
  SELECT
851
782
  (CASE
852
- WHEN (sector = 'index') THEN 3
853
- WHEN (sector = 'short') THEN 1
783
+ WHEN (subindustry LIKE '___+') THEN 3
784
+ WHEN (subindustry LIKE '___-') THEN 1
854
785
  ELSE 2
855
786
  END) AS series_color,
856
787
  0 AS is_dummy,
@@ -941,8 +872,8 @@ CREATE TEMP TABLE __tmp1 AS
941
872
  FROM (
942
873
  SELECT
943
874
  (CASE
944
- WHEN (sector LIKE 'index%') THEN 3
945
- WHEN (sector LIKE 'short%') THEN 1
875
+ WHEN (subindustry LIKE '___+') THEN 3
876
+ WHEN (subindustry LIKE '___-') THEN 1
946
877
  ELSE 2
947
878
  END) AS series_color,
948
879
  (
@@ -1018,27 +949,27 @@ INSERT INTO chart._{{ii}}_tradebot_buysell_history (
1018
949
  `),
1019
950
  [
1020
951
  "1 day",
1021
- "1 week"
952
+ "1 month"
1022
953
  ].map(function (dateInterval) {
1023
954
  let optionDict;
1024
955
  let tableChart;
1025
956
  let tableData;
1026
957
  tableData = (
1027
958
  dateInterval === "1 day"
1028
- ? "tradebot_technical_day"
1029
- : dateInterval === "1 week"
1030
- ? "tradebot_technical_week"
1031
- : "tradebot_technical"
959
+ ? "tradebot_tech_intra_day"
960
+ : dateInterval === "1 month"
961
+ ? "tradebot_tech_intra_month"
962
+ : "tradebot_tech_intra"
1032
963
  );
1033
964
  tableChart = (
1034
- "chart._{{ii}}_tradebot_technical_"
965
+ "chart._{{ii}}_tradebot_tech_intra_"
1035
966
  + dateInterval.replace((
1036
967
  /\W/g
1037
968
  ), "_")
1038
969
  );
1039
970
  optionDict = {
1040
971
  title: (
1041
- "tradebot technical - "
972
+ "tradebot technical intraday - "
1042
973
  + dateInterval
1043
974
  + (
1044
975
  dateInterval === "1 day"
@@ -1052,13 +983,12 @@ INSERT INTO chart._{{ii}}_tradebot_buysell_history (
1052
983
  xstep: (
1053
984
  dateInterval === "1 day"
1054
985
  ? 60
1055
- : dateInterval === "1 week"
1056
- ? 60
1057
- // ? 15 * 60
986
+ : dateInterval === "1 month"
987
+ ? 5 * 60
1058
988
  : 1
1059
989
  ),
1060
990
  xvalueConvert: (
1061
- (dateInterval === "1 day" || dateInterval === "1 week")
991
+ (dateInterval === "1 day" || dateInterval === "1 month")
1062
992
  ? "unixepochToTimeutc"
1063
993
  : "juliandayToDate"
1064
994
  ),
@@ -1066,77 +996,9 @@ INSERT INTO chart._{{ii}}_tradebot_buysell_history (
1066
996
  yvalueSuffix: " %"
1067
997
  };
1068
998
  return (`
1069
- -- table - ${tableData} - normalize
1070
- UPDATE ${tableData}
1071
- 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
999
  UPDATE ${tableData}
1138
1000
  SET
1139
- tt = UNIXEPOCH(tt),
1001
+ xdate = UNIXEPOCH(xdate),
1140
1002
  tval = ROUNDORZERO(tval, 4);
1141
1003
 
1142
1004
  -- chart - ${tableChart} - create
@@ -1160,10 +1022,12 @@ INSERT INTO ${tableChart} (datatype, options, series_index, series_label)
1160
1022
  'series_label' AS datatype,
1161
1023
  JSON_OBJECT(
1162
1024
  'isHidden', NOT tname IN (
1163
- '1a_spy_cls', '1b_stk_lmt', '1c_stk_pct'
1025
+ -- '1a_stk_pct',
1026
+ -- '1b_stk_lmt',
1027
+ '2a_spy_prc'
1164
1028
  ),
1165
1029
  'seriesColor', (CASE
1166
- WHEN (tname = '1d_stk_lmb') THEN
1030
+ WHEN (tname = '1c_stk_lmb') THEN
1167
1031
  '#999'
1168
1032
  ELSE
1169
1033
  NULL
@@ -1189,12 +1053,12 @@ INSERT INTO ${tableChart} (datatype, xx, xx_label)
1189
1053
  SELECT
1190
1054
  'xx_label' AS datatype,
1191
1055
  rownum AS xx,
1192
- tt AS xx_label
1056
+ xdate AS xx_label
1193
1057
  FROM (
1194
1058
  SELECT
1195
- ROW_NUMBER() OVER (ORDER BY tt) AS rownum,
1196
- tt
1197
- FROM (SELECT DISTINCT tt FROM ${tableData})
1059
+ ROW_NUMBER() OVER (ORDER BY xdate) AS rownum,
1060
+ xdate
1061
+ FROM (SELECT DISTINCT xdate FROM ${tableData})
1198
1062
  );
1199
1063
  INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1200
1064
  SELECT
@@ -1225,25 +1089,12 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1225
1089
  datatype = 'xx_label'
1226
1090
  )
1227
1091
  )
1228
- LEFT JOIN ${tableData} ON tname = series_label AND tt = xx_label;
1092
+ LEFT JOIN ${tableData} ON tname = series_label AND xdate = xx_label;
1229
1093
  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
1094
  `);
1244
1095
  }),
1245
1096
  (function () {
1246
- let tableChart = `chart._{{ii}}_tradebot_technical_sinefit`;
1097
+ let tableChart = `chart._{{ii}}_tradebot_tech_hist_1_year`;
1247
1098
  return (`
1248
1099
  CREATE TABLE ${tableChart} (
1249
1100
  datatype TEXT NOT NULL,
@@ -1260,7 +1111,7 @@ INSERT INTO ${tableChart} (datatype, options)
1260
1111
  SELECT
1261
1112
  'options' AS datatype,
1262
1113
  '{
1263
- "title": "tradebot technical - sinusoidal fit of spy",
1114
+ "title": "tradebot technical historical - 1 year",
1264
1115
  "xaxisTitle": "date",
1265
1116
  "xvalueConvert": "juliandayToDate",
1266
1117
  "yaxisTitle": "percent gain",
@@ -1294,7 +1145,10 @@ INSERT INTO ${tableChart} (datatype, xx, xx_label)
1294
1145
  JULIANDAY(xdate) AS xx,
1295
1146
  xdate AS xx_label
1296
1147
  FROM (
1297
- SELECT DISTINCT xdate FROM tradebot_technical_sinefit ORDER BY ttt DESC
1148
+ SELECT DISTINCT
1149
+ xdate
1150
+ FROM tradebot_tech_histo
1151
+ ORDER BY ttt DESC
1298
1152
  );
1299
1153
  INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1300
1154
  SELECT
@@ -1308,7 +1162,7 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1308
1162
  1 AS series_index,
1309
1163
  xdate,
1310
1164
  price_actual AS yy
1311
- FROM tradebot_technical_sinefit
1165
+ FROM tradebot_tech_histo
1312
1166
  --
1313
1167
  UNION ALL
1314
1168
  --
@@ -1316,7 +1170,7 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1316
1170
  2 AS series_index,
1317
1171
  xdate,
1318
1172
  price_linear_02 AS yy
1319
- FROM tradebot_technical_sinefit
1173
+ FROM tradebot_tech_histo
1320
1174
  --
1321
1175
  UNION ALL
1322
1176
  --
@@ -1324,11 +1178,11 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1324
1178
  3 AS series_index,
1325
1179
  xdate,
1326
1180
  price_sine_02 + __offset AS yy
1327
- FROM tradebot_technical_sinefit
1181
+ FROM tradebot_tech_histo
1328
1182
  JOIN (
1329
1183
  SELECT
1330
1184
  price_actual - price_sine_02 AS __offset
1331
- FROM tradebot_technical_sinefit
1185
+ FROM tradebot_tech_histo
1332
1186
  WHERE
1333
1187
  ttt = 1
1334
1188
  )
@@ -1339,7 +1193,7 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1339
1193
  4 AS series_index,
1340
1194
  xdate,
1341
1195
  price_predicted_02 AS yy
1342
- FROM tradebot_technical_sinefit
1196
+ FROM tradebot_tech_histo
1343
1197
  --
1344
1198
  UNION ALL
1345
1199
  --
@@ -1347,7 +1201,7 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1347
1201
  5 AS series_index,
1348
1202
  xdate,
1349
1203
  price_linear_06 AS yy
1350
- FROM tradebot_technical_sinefit
1204
+ FROM tradebot_tech_histo
1351
1205
  --
1352
1206
  UNION ALL
1353
1207
  --
@@ -1355,11 +1209,11 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1355
1209
  6 AS series_index,
1356
1210
  xdate,
1357
1211
  price_sine_06 + __offset AS yy
1358
- FROM tradebot_technical_sinefit
1212
+ FROM tradebot_tech_histo
1359
1213
  JOIN (
1360
1214
  SELECT
1361
1215
  price_actual - price_sine_06 AS __offset
1362
- FROM tradebot_technical_sinefit
1216
+ FROM tradebot_tech_histo
1363
1217
  WHERE
1364
1218
  ttt = 1
1365
1219
  )
@@ -1370,8 +1224,9 @@ INSERT INTO ${tableChart} (datatype, series_index, xx, yy)
1370
1224
  7 AS series_index,
1371
1225
  xdate,
1372
1226
  price_predicted_06 AS yy
1373
- FROM tradebot_technical_sinefit
1374
- ) ON xdate = xx_label;
1227
+ FROM tradebot_tech_histo
1228
+ ) ON xdate = xx_label
1229
+ WHERE yy IS NOT NULL;
1375
1230
 
1376
1231
  -- table - ${tableChart} - normalize - yy
1377
1232
  UPDATE ${tableChart}
@@ -1380,9 +1235,9 @@ UPDATE ${tableChart}
1380
1235
  FROM (
1381
1236
  SELECT
1382
1237
  100.0 / price_actual AS __inv
1383
- FROM tradebot_technical_sinefit
1238
+ FROM tradebot_tech_histo
1384
1239
  WHERE
1385
- ttt = (SELECT MAX(ttt) FROM tradebot_technical_sinefit)
1240
+ ttt = (SELECT MAX(ttt) FROM tradebot_tech_histo)
1386
1241
  );
1387
1242
  UPDATE ${tableChart}
1388
1243
  SET
@@ -2046,6 +1901,7 @@ DELETE FROM ${baton.dbtableName} WHERE rowid = ${baton.rowid};
2046
1901
  data = (
2047
1902
  String(`
2048
1903
  -- DROP TABLE __sqlite_table_01;
1904
+ -- IF OBJECT_ID('tempdb..#tmp1') IS NOT NULL DROP TABLE #tmp1;
2049
1905
  -- SELECT * FROM __sqlite_table_01;
2050
1906
  -- ALTER TABLE __sqlite_table_01 RENAME TO __sqlite_table_02;
2051
1907
  -- EXEC sp_rename '__sqlite_table_01', '__sqlite_table_02';
@@ -3097,7 +2953,7 @@ SELECT
3097
2953
  <g class="uichartTooltip" visibility="hidden">
3098
2954
  <rect
3099
2955
  class="uichartTooltipBorder"
3100
- fill-opacity="0.8000"
2956
+ fill-opacity="0.6667"
3101
2957
  fill="#fff"
3102
2958
  rx="5"
3103
2959
  ry="5"
@@ -3480,21 +3336,24 @@ SELECT
3480
3336
  // update elemTooltipText
3481
3337
  elemTooltip.setAttribute("visibility", "visible");
3482
3338
  elemTooltipText.innerHTML = (`
3483
- <tspan dy="17" x="6">${stringHtmlSafe(seriesHovered.seriesName)}</tspan>
3484
- <tspan dy="17" x="6">x: ${stringHtmlSafe(xlabel)}</tspan>
3485
3339
  <tspan
3486
- dy="19"
3487
- style="font-size: 14px; font-weight: bold;"
3488
- x="6"
3489
- >y: ${stringHtmlSafe(ylabel)}</tspan>
3340
+ dy="15"
3341
+ style="filter: brightness(75%); font-size: 14px; font-weight: normal;"
3342
+ x="5"
3343
+ >
3344
+ ${stringHtmlSafe(ylabel)} -- ${stringHtmlSafe(xlabel)}
3345
+ </tspan>
3490
3346
  `);
3347
+ svgAttrSet(elemTooltipText, {
3348
+ fill: seriesHovered.seriesColor
3349
+ });
3491
3350
  // update elemTooltipBorder after text-update
3492
3351
  tooltipBbox = elemTooltipText.getBBox();
3493
3352
  tooltipWidth = tooltipBbox.width + 10;
3494
- tooltipHeight = tooltipBbox.height + 10;
3353
+ tooltipHeight = tooltipBbox.height + 0;
3495
3354
  svgAttrSet(elemTooltipBorder, {
3496
3355
  height: tooltipHeight,
3497
- stroke: seriesHovered.seriesColor,
3356
+ // stroke: seriesHovered.seriesColor,
3498
3357
  width: tooltipWidth
3499
3358
  });
3500
3359
  // calculate tooltipX