sqlmath 2025.12.28 → 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 +7 -1
- package/README.md +5 -5
- package/_sqlmath.cp310-win_amd64.pyd +0 -0
- package/_sqlmath.cp311-win_amd64.pyd +0 -0
- package/_sqlmath.cp312-win_amd64.pyd +0 -0
- package/_sqlmath.cp313-win_amd64.pyd +0 -0
- package/_sqlmath.cp314-win_amd64.pyd +0 -0
- package/_sqlmath.cpython-310-darwin.so +0 -0
- package/_sqlmath.cpython-311-darwin.so +0 -0
- package/_sqlmath.cpython-312-darwin.so +0 -0
- package/_sqlmath.cpython-313-darwin.so +0 -0
- package/_sqlmath.cpython-314-darwin.so +0 -0
- package/_sqlmath.cpython-314t-darwin.so +0 -0
- package/_sqlmath.napi6_darwin_arm64.node +0 -0
- package/_sqlmath.napi6_win32_x64.node +0 -0
- package/_sqlmath.shell_darwin_arm64 +0 -0
- package/_sqlmath.shell_win32_x64.exe +0 -0
- package/package.json +1 -1
- package/sqlmath.mjs +1 -1
- package/sqlmath_browser.mjs +119 -261
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
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.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
|
+
|
|
9
15
|
# v2025.12.28
|
|
10
16
|
- jslint - Upgrade to jslint-v2025.12.28.
|
|
11
17
|
- 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>(
|
|
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 | [](https://github.com/sqlmath/sqlmath/actions?query=branch%3Amaster) | [](https://github.com/sqlmath/sqlmath/actions?query=branch%3Abeta) | [](https://github.com/sqlmath/sqlmath/actions?query=branch%3Aalpha) |
|
|
8
8
|
| Coverage | [](https://sqlmath.github.io/sqlmath/branch-master/.artifact/coverage/index.html) | [](https://sqlmath.github.io/sqlmath/branch-beta/.artifact/coverage/index.html) | [](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-
|
|
125
|
-
py -m pip install --index-url https://test.pypi.org/simple/ sqlmath==
|
|
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-
|
|
128
|
-
pip install sqlmath==
|
|
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/package.json
CHANGED
package/sqlmath.mjs
CHANGED
package/sqlmath_browser.mjs
CHANGED
|
@@ -301,7 +301,7 @@ CREATE TABLE tradebot_intraday_day AS
|
|
|
301
301
|
sym,
|
|
302
302
|
xdate,
|
|
303
303
|
price
|
|
304
|
-
FROM
|
|
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 -
|
|
318
|
-
DROP TABLE IF EXISTS
|
|
319
|
-
CREATE TABLE
|
|
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
|
|
324
|
+
FROM tradebot_intraday
|
|
325
325
|
WHERE xdate = xdate2;
|
|
326
326
|
|
|
327
|
-
-- table -
|
|
328
|
-
DROP TABLE IF EXISTS
|
|
329
|
-
CREATE TABLE
|
|
330
|
-
|
|
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
|
|
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
|
-
|
|
341
|
-
|
|
342
|
-
UNION ALL
|
|
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 '
|
|
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 '
|
|
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 '
|
|
367
|
+
SELECT '1c_stk_lmb', xdate, xdate2, stk_lmb FROM tradebot_tech_intra
|
|
396
368
|
--
|
|
397
369
|
UNION ALL
|
|
398
370
|
--
|
|
399
|
-
SELECT '
|
|
371
|
+
SELECT '1d_stk_pnl', xdate, xdate2, stk_pnl FROM tradebot_tech_intra
|
|
400
372
|
--
|
|
401
373
|
UNION ALL
|
|
402
374
|
--
|
|
403
|
-
SELECT '
|
|
375
|
+
SELECT '2a_spy_prc', xdate, xdate2, spy_prc FROM tradebot_tech_intra
|
|
404
376
|
--
|
|
405
377
|
UNION ALL
|
|
406
378
|
--
|
|
407
|
-
SELECT '
|
|
379
|
+
SELECT '2b_spy_cos', xdate, xdate2, spy_cos FROM tradebot_tech_intra
|
|
408
380
|
--
|
|
409
381
|
UNION ALL
|
|
410
382
|
--
|
|
411
|
-
SELECT '
|
|
383
|
+
SELECT '2c_spy_sin', xdate, xdate2, spy_sin FROM tradebot_tech_intra
|
|
412
384
|
--
|
|
413
385
|
UNION ALL
|
|
414
386
|
--
|
|
415
|
-
SELECT '
|
|
387
|
+
SELECT '2d_spy_syy', xdate, xdate2, spy_syy FROM tradebot_tech_intra
|
|
416
388
|
--
|
|
417
389
|
UNION ALL
|
|
418
390
|
--
|
|
419
|
-
SELECT '
|
|
391
|
+
SELECT '2e_spy_zcl', xdate, xdate2, spy_zcl FROM tradebot_tech_intra
|
|
420
392
|
)
|
|
421
|
-
WHERE
|
|
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
|
|
440
|
-
? "
|
|
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
|
|
450
|
+
: dateInterval === "1 month"
|
|
466
451
|
? 15 * 60
|
|
467
452
|
: 1
|
|
468
453
|
),
|
|
469
454
|
xvalueConvert: (
|
|
470
|
-
(dateInterval === "1 day" || dateInterval === "1
|
|
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'
|
|
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
|
|
687
|
-
? "UNIXEPOCH(
|
|
688
|
-
: "JULIANDAY(
|
|
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
|
-
|
|
680
|
+
xdate
|
|
696
681
|
FROM ${tableChart}
|
|
697
682
|
--
|
|
698
683
|
JOIN (
|
|
699
684
|
SELECT
|
|
700
685
|
xx,
|
|
701
|
-
xx_label AS
|
|
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
|
|
716
|
+
${(dateInterval === "1 day" || dateInterval === "1 month")};
|
|
732
717
|
DELETE FROM ${tableChart} WHERE datatype = 'xx_label';
|
|
733
718
|
`);
|
|
734
719
|
}),
|
|
735
720
|
[
|
|
736
|
-
"
|
|
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 === "
|
|
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 = '
|
|
777
|
+
grouping = 'subindustry'
|
|
847
778
|
)
|
|
848
779
|
`)
|
|
849
780
|
: (`
|
|
850
781
|
SELECT
|
|
851
782
|
(CASE
|
|
852
|
-
WHEN (
|
|
853
|
-
WHEN (
|
|
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 (
|
|
945
|
-
WHEN (
|
|
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
|
|
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
|
-
? "
|
|
1029
|
-
: dateInterval === "1
|
|
1030
|
-
? "
|
|
1031
|
-
: "
|
|
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}}
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
1025
|
+
-- '1a_stk_pct',
|
|
1026
|
+
-- '1b_stk_lmt',
|
|
1027
|
+
'2a_spy_prc'
|
|
1164
1028
|
),
|
|
1165
1029
|
'seriesColor', (CASE
|
|
1166
|
-
WHEN (tname = '
|
|
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
|
-
|
|
1056
|
+
xdate AS xx_label
|
|
1193
1057
|
FROM (
|
|
1194
1058
|
SELECT
|
|
1195
|
-
ROW_NUMBER() OVER (ORDER BY
|
|
1196
|
-
|
|
1197
|
-
FROM (SELECT DISTINCT
|
|
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
|
|
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}}
|
|
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 -
|
|
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
|
|
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
|
|
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
|
|
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
|
|
1181
|
+
FROM tradebot_tech_histo
|
|
1328
1182
|
JOIN (
|
|
1329
1183
|
SELECT
|
|
1330
1184
|
price_actual - price_sine_02 AS __offset
|
|
1331
|
-
FROM
|
|
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
|
|
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
|
|
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
|
|
1212
|
+
FROM tradebot_tech_histo
|
|
1359
1213
|
JOIN (
|
|
1360
1214
|
SELECT
|
|
1361
1215
|
price_actual - price_sine_06 AS __offset
|
|
1362
|
-
FROM
|
|
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
|
|
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
|
|
1238
|
+
FROM tradebot_tech_histo
|
|
1384
1239
|
WHERE
|
|
1385
|
-
ttt = (SELECT MAX(ttt) FROM
|
|
1240
|
+
ttt = (SELECT MAX(ttt) FROM tradebot_tech_histo)
|
|
1386
1241
|
);
|
|
1387
1242
|
UPDATE ${tableChart}
|
|
1388
1243
|
SET
|
|
@@ -3098,7 +2953,7 @@ SELECT
|
|
|
3098
2953
|
<g class="uichartTooltip" visibility="hidden">
|
|
3099
2954
|
<rect
|
|
3100
2955
|
class="uichartTooltipBorder"
|
|
3101
|
-
fill-opacity="0.
|
|
2956
|
+
fill-opacity="0.6667"
|
|
3102
2957
|
fill="#fff"
|
|
3103
2958
|
rx="5"
|
|
3104
2959
|
ry="5"
|
|
@@ -3481,21 +3336,24 @@ SELECT
|
|
|
3481
3336
|
// update elemTooltipText
|
|
3482
3337
|
elemTooltip.setAttribute("visibility", "visible");
|
|
3483
3338
|
elemTooltipText.innerHTML = (`
|
|
3484
|
-
<tspan dy="17" x="6">${stringHtmlSafe(seriesHovered.seriesName)}</tspan>
|
|
3485
|
-
<tspan dy="17" x="6">x: ${stringHtmlSafe(xlabel)}</tspan>
|
|
3486
3339
|
<tspan
|
|
3487
|
-
dy="
|
|
3488
|
-
style="font-size: 14px; font-weight:
|
|
3489
|
-
x="
|
|
3490
|
-
>
|
|
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>
|
|
3491
3346
|
`);
|
|
3347
|
+
svgAttrSet(elemTooltipText, {
|
|
3348
|
+
fill: seriesHovered.seriesColor
|
|
3349
|
+
});
|
|
3492
3350
|
// update elemTooltipBorder after text-update
|
|
3493
3351
|
tooltipBbox = elemTooltipText.getBBox();
|
|
3494
3352
|
tooltipWidth = tooltipBbox.width + 10;
|
|
3495
|
-
tooltipHeight = tooltipBbox.height +
|
|
3353
|
+
tooltipHeight = tooltipBbox.height + 0;
|
|
3496
3354
|
svgAttrSet(elemTooltipBorder, {
|
|
3497
3355
|
height: tooltipHeight,
|
|
3498
|
-
stroke: seriesHovered.seriesColor,
|
|
3356
|
+
// stroke: seriesHovered.seriesColor,
|
|
3499
3357
|
width: tooltipWidth
|
|
3500
3358
|
});
|
|
3501
3359
|
// calculate tooltipX
|