w-trade-solve 1.0.2 → 1.0.3
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/README.md +15 -11
- package/dist/w-trade-solve.umd.js +4 -4
- package/dist/w-trade-solve.umd.js.map +1 -1
- package/docs/calcFitness.mjs.html +1 -1
- package/docs/calcLevelNumTrade.mjs.html +1 -1
- package/docs/cont.mjs.html +1 -1
- package/docs/estimComps.mjs.html +16 -11
- package/docs/estimFinder.mjs.html +17 -12
- package/docs/estimKeys.mjs.html +53 -34
- package/docs/estimPicks.mjs.html +17 -12
- package/docs/genSid.mjs.html +1 -1
- package/docs/genStrategyFileName.mjs.html +1 -1
- package/docs/genTid.mjs.html +1 -1
- package/docs/global.html +332 -67
- package/docs/index.html +1 -1
- package/docs/ott.mjs.html +1 -1
- package/docs/p2r.mjs.html +1 -1
- package/docs/readStrategies.mjs.html +1 -1
- package/g.mjs +14 -11
- package/package.json +1 -1
- package/src/estimComps.mjs +15 -10
- package/src/estimFinder.mjs +16 -11
- package/src/estimKeys.mjs +52 -33
- package/src/estimPicks.mjs +16 -11
- package/test/unit-estimComps.test.mjs +34 -18
- package/test/unit-estimFinder.test.mjs +33 -20
- package/test/unit-estimKeys.test.mjs +115 -17
- package/test/unit-estimPicks.test.mjs +27 -17
- package/test/unit-setup.mjs +8 -14
package/docs/global.html
CHANGED
|
@@ -610,7 +610,7 @@ console.log(calcLevelNumTrade(8000))
|
|
|
610
610
|
|
|
611
611
|
|
|
612
612
|
|
|
613
|
-
<h4 class="name" id="estimComps"><span class="type-signature type-signature-async">(async) </span>estimComps<span class="signature">(ott,
|
|
613
|
+
<h4 class="name" id="estimComps"><span class="type-signature type-signature-async">(async) </span>estimComps<span class="signature">(ott, name, symbol, interval, fdOhlc, fdParam, timeStart, timeEnd, mode, comps, fdData, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
614
614
|
|
|
615
615
|
|
|
616
616
|
|
|
@@ -630,7 +630,7 @@ comps非3段時throw,其餘檢核與分類邏輯同estimPicks</p>
|
|
|
630
630
|
|
|
631
631
|
<dt class="tag-source">Source:</dt>
|
|
632
632
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
633
|
-
<a href="estimComps.mjs.html">estimComps.mjs</a>, <a href="estimComps.mjs.html#
|
|
633
|
+
<a href="estimComps.mjs.html">estimComps.mjs</a>, <a href="estimComps.mjs.html#line41">line 41</a>
|
|
634
634
|
</li></ul></dd>
|
|
635
635
|
|
|
636
636
|
|
|
@@ -679,14 +679,8 @@ comps非3段時throw,其餘檢核與分類邏輯同estimPicks</p>
|
|
|
679
679
|
|
|
680
680
|
<pre class="prettyprint"><code>import ott from './src/ott.mjs'
|
|
681
681
|
|
|
682
|
-
let st = {
|
|
683
|
-
btc4hr: { name: 'btc', symbol: 'BTCUSDT', interval: '4hr' },
|
|
684
|
-
}
|
|
685
|
-
|
|
686
682
|
//comps='2,1,0', 挑2種一般類、1種指數類與0種成交量類
|
|
687
|
-
await estimComps(ott,
|
|
688
|
-
keySettings: 'btc4hr',
|
|
689
|
-
})</code></pre>
|
|
683
|
+
await estimComps(ott, 'btc', 'BTCUSDT', '4hr', './data/ohlc', './data/param', '2022-07-01T00:00:00', '2025-04-08T00:00:00', 'long', '2,1,0', './data/strategy', {})</code></pre>
|
|
690
684
|
|
|
691
685
|
|
|
692
686
|
|
|
@@ -756,13 +750,85 @@ await estimComps(ott, st, './data/ohlc', './data/param', '2022-07-01T00:00:00',
|
|
|
756
750
|
|
|
757
751
|
<tr>
|
|
758
752
|
|
|
759
|
-
<td class="name"><code>
|
|
753
|
+
<td class="name"><code>name</code></td>
|
|
760
754
|
|
|
761
755
|
|
|
762
756
|
<td class="type">
|
|
763
757
|
|
|
764
758
|
|
|
765
|
-
<span class="param-type">
|
|
759
|
+
<span class="param-type">String</span>
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
</td>
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
<td class="attributes">
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
</td>
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
<td class="default">
|
|
778
|
+
|
|
779
|
+
</td>
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
<td class="description last"><p>輸入幣種名稱字串,例如'btc'</p></td>
|
|
783
|
+
</tr>
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
<tr>
|
|
788
|
+
|
|
789
|
+
<td class="name"><code>symbol</code></td>
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
<td class="type">
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
<span class="param-type">String</span>
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
</td>
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
<td class="attributes">
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
</td>
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
<td class="default">
|
|
814
|
+
|
|
815
|
+
</td>
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
<td class="description last"><p>輸入交易對名稱字串,例如'BTCUSDT'</p></td>
|
|
819
|
+
</tr>
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
<tr>
|
|
824
|
+
|
|
825
|
+
<td class="name"><code>interval</code></td>
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
<td class="type">
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
<span class="param-type">String</span>
|
|
766
832
|
|
|
767
833
|
|
|
768
834
|
|
|
@@ -785,7 +851,7 @@ await estimComps(ott, st, './data/ohlc', './data/param', '2022-07-01T00:00:00',
|
|
|
785
851
|
</td>
|
|
786
852
|
|
|
787
853
|
|
|
788
|
-
<td class="description last"><p
|
|
854
|
+
<td class="description last"><p>輸入K線週期字串,例如'4hr'</p></td>
|
|
789
855
|
</tr>
|
|
790
856
|
|
|
791
857
|
|
|
@@ -1130,7 +1196,7 @@ await estimComps(ott, st, './data/ohlc', './data/param', '2022-07-01T00:00:00',
|
|
|
1130
1196
|
|
|
1131
1197
|
|
|
1132
1198
|
|
|
1133
|
-
<h4 class="name" id="estimFinder"><span class="type-signature type-signature-async">(async) </span>estimFinder<span class="signature">(ott,
|
|
1199
|
+
<h4 class="name" id="estimFinder"><span class="type-signature type-signature-async">(async) </span>estimFinder<span class="signature">(ott, name, symbol, interval, fdOhlc, fdParam, fdData, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
1134
1200
|
|
|
1135
1201
|
|
|
1136
1202
|
|
|
@@ -1143,14 +1209,14 @@ await estimComps(ott, st, './data/ohlc', './data/param', '2022-07-01T00:00:00',
|
|
|
1143
1209
|
<dd class="tag-description"><ul class="dummy"><li><p>以隨機之交易方向與指標組成求解最佳策略</p>
|
|
1144
1210
|
<p>供批次探索用之進入點,未指定時mode由'long'與'short'隨機取一,comps由18種預設組成隨機取一,故重複呼叫即可隨機探索各種策略
|
|
1145
1211
|
未指定時timeStart預設為'2022-07-01T00:00:00',timeEnd則依mode給予不同值: 做多為'2025-04-08T00:00:00'(須涵蓋暴跌數據),做空為'2025-10-06T00:00:00'(須涵蓋暴漲數據),藉此提高率定難度
|
|
1146
|
-
fdOhlc、fdParam與fdData無效時throw</p>
|
|
1212
|
+
name、symbol、interval、fdOhlc、fdParam與fdData無效時throw</p>
|
|
1147
1213
|
<p>Unit Test: <a href="https://github.com/yuda-lyu/w-trade-solve/blob/master/test/unit-estimFinder.test.mjs">Github</a></p></li></ul></dd>
|
|
1148
1214
|
|
|
1149
1215
|
|
|
1150
1216
|
|
|
1151
1217
|
<dt class="tag-source">Source:</dt>
|
|
1152
1218
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1153
|
-
<a href="estimFinder.mjs.html">estimFinder.mjs</a>, <a href="estimFinder.mjs.html#
|
|
1219
|
+
<a href="estimFinder.mjs.html">estimFinder.mjs</a>, <a href="estimFinder.mjs.html#line37">line 37</a>
|
|
1154
1220
|
</li></ul></dd>
|
|
1155
1221
|
|
|
1156
1222
|
|
|
@@ -1199,14 +1265,8 @@ fdOhlc、fdParam與fdData無效時throw</p>
|
|
|
1199
1265
|
|
|
1200
1266
|
<pre class="prettyprint"><code>import ott from './src/ott.mjs'
|
|
1201
1267
|
|
|
1202
|
-
let st = {
|
|
1203
|
-
btc4hr: { name: 'btc', symbol: 'BTCUSDT', interval: '4hr' },
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
1268
|
//mode與comps皆隨機, 適合以迴圈重複呼叫批次探索
|
|
1207
|
-
await estimFinder(ott,
|
|
1208
|
-
keySettings: 'btc4hr',
|
|
1209
|
-
})</code></pre>
|
|
1269
|
+
await estimFinder(ott, 'btc', 'BTCUSDT', '4hr', './data/ohlc', './data/param', './data/strategy', {})</code></pre>
|
|
1210
1270
|
|
|
1211
1271
|
|
|
1212
1272
|
|
|
@@ -1276,13 +1336,49 @@ await estimFinder(ott, st, './data/ohlc', './data/param', './data/strategy', {
|
|
|
1276
1336
|
|
|
1277
1337
|
<tr>
|
|
1278
1338
|
|
|
1279
|
-
<td class="name"><code>
|
|
1339
|
+
<td class="name"><code>name</code></td>
|
|
1280
1340
|
|
|
1281
1341
|
|
|
1282
1342
|
<td class="type">
|
|
1283
1343
|
|
|
1284
1344
|
|
|
1285
|
-
<span class="param-type">
|
|
1345
|
+
<span class="param-type">String</span>
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
</td>
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
<td class="attributes">
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
</td>
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
<td class="default">
|
|
1364
|
+
|
|
1365
|
+
</td>
|
|
1366
|
+
|
|
1367
|
+
|
|
1368
|
+
<td class="description last"><p>輸入幣種名稱字串,例如'btc'</p></td>
|
|
1369
|
+
</tr>
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
|
|
1373
|
+
<tr>
|
|
1374
|
+
|
|
1375
|
+
<td class="name"><code>symbol</code></td>
|
|
1376
|
+
|
|
1377
|
+
|
|
1378
|
+
<td class="type">
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
<span class="param-type">String</span>
|
|
1286
1382
|
|
|
1287
1383
|
|
|
1288
1384
|
|
|
@@ -1305,7 +1401,43 @@ await estimFinder(ott, st, './data/ohlc', './data/param', './data/strategy', {
|
|
|
1305
1401
|
</td>
|
|
1306
1402
|
|
|
1307
1403
|
|
|
1308
|
-
<td class="description last"><p
|
|
1404
|
+
<td class="description last"><p>輸入交易對名稱字串,例如'BTCUSDT'</p></td>
|
|
1405
|
+
</tr>
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
<tr>
|
|
1410
|
+
|
|
1411
|
+
<td class="name"><code>interval</code></td>
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
<td class="type">
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
<span class="param-type">String</span>
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
</td>
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
<td class="attributes">
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
</td>
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
<td class="default">
|
|
1436
|
+
|
|
1437
|
+
</td>
|
|
1438
|
+
|
|
1439
|
+
|
|
1440
|
+
<td class="description last"><p>輸入K線週期字串,例如'4hr'</p></td>
|
|
1309
1441
|
</tr>
|
|
1310
1442
|
|
|
1311
1443
|
|
|
@@ -1696,7 +1828,7 @@ await estimFinder(ott, st, './data/ohlc', './data/param', './data/strategy', {
|
|
|
1696
1828
|
|
|
1697
1829
|
|
|
1698
1830
|
|
|
1699
|
-
<h4 class="name" id="estimKeys"><span class="type-signature type-signature-async">(async) </span>estimKeys<span class="signature">(ott,
|
|
1831
|
+
<h4 class="name" id="estimKeys"><span class="type-signature type-signature-async">(async) </span>estimKeys<span class="signature">(ott, name, symbol, interval, fdOhlc, fdParam, timeStart, timeEnd, mode, keys, fdData, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
1700
1832
|
|
|
1701
1833
|
|
|
1702
1834
|
|
|
@@ -1709,18 +1841,19 @@ await estimFinder(ott, st, './data/ohlc', './data/param', './data/strategy', {
|
|
|
1709
1841
|
<dd class="tag-description"><ul class="dummy"><li><p>針對指定keys率定各key之門檻與止盈止損,求解最佳策略</p>
|
|
1710
1842
|
<p>設計變數為[止損比例, 止盈比例, ...各key之門檻],止損與止盈由opt.thsSl與opt.thsTp給予之百分比清單離散取值
|
|
1711
1843
|
各key門檻取值範圍為[-thLim,thLim]切為thLim<em>20段,並各自平移+vdir與-vdir(vdir=thLim</em>5)為兩組,使解值恆大於0代表'>'條件、恆小於0代表'<'條件,還原時再扣除平移值,故單一設計變數即同時涵蓋大於與小於兩種條件
|
|
1712
|
-
以
|
|
1844
|
+
以w-optimization之最佳化函數求解,由opt.methodOml指定演算法,各次計算皆以w-trade-backtest之runStrategy回測並經calcFitness計算適應值
|
|
1713
1845
|
各次計算結果若同時滿足交易次數、勝率與最終等效年化盈虧三門檻,則以genStrategyFileName產生檔名存入fdData;同tid且同交易次數級距(tkid)已有策略時,僅於最終等效年化盈虧更佳時抽換,並刪除較差者
|
|
1714
|
-
opt
|
|
1715
|
-
|
|
1716
|
-
|
|
1846
|
+
opt除下列各欄位外,其餘欄位皆原樣傳遞至所選之最佳化函數,兩者欄位名稱無重疊,故可一併給予求解設定
|
|
1847
|
+
各演算法共通之設定為NContiguous(最佳解連續未更新次數上限,預設100)、NRepeat、NCore、ModeOutLimit、UseRepeat、UseImmigration、LocalSearchMethod與funGetBetter、funGenerationBefore、funGenerationAfter三接口;族群數與迴圈數之欄位名稱各演算法不同,RGA與DE為Np與Ng、PSO為Np與Nl、HS為Ns與Ni、ACO為Na與Nl;另各演算法有其專屬超參數,如PSO之psoC1Start、RGA之rgaCrossover、DE之deF、HS之hsHMCR與ACO之acoAlphaStart等
|
|
1848
|
+
預設之求解量甚大(單一key約需1萬7千次回測),僅需快速試算時可調小族群數與NContiguous
|
|
1849
|
+
name、symbol、interval、fdOhlc、fdParam、timeStart、timeEnd、keys、fdData無效或mode非'long'或'short'時throw</p>
|
|
1717
1850
|
<p>Unit Test: <a href="https://github.com/yuda-lyu/w-trade-solve/blob/master/test/unit-estimKeys.test.mjs">Github</a></p></li></ul></dd>
|
|
1718
1851
|
|
|
1719
1852
|
|
|
1720
1853
|
|
|
1721
1854
|
<dt class="tag-source">Source:</dt>
|
|
1722
1855
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1723
|
-
<a href="estimKeys.mjs.html">estimKeys.mjs</a>, <a href="estimKeys.mjs.html#
|
|
1856
|
+
<a href="estimKeys.mjs.html">estimKeys.mjs</a>, <a href="estimKeys.mjs.html#line98">line 98</a>
|
|
1724
1857
|
</li></ul></dd>
|
|
1725
1858
|
|
|
1726
1859
|
|
|
@@ -1769,20 +1902,10 @@ fdOhlc、fdParam、timeStart、timeEnd、keys、fdData無效或mode非'long'或'
|
|
|
1769
1902
|
|
|
1770
1903
|
<pre class="prettyprint"><code>import ott from './src/ott.mjs'
|
|
1771
1904
|
|
|
1772
|
-
//st, 各設定以keySettings為鍵儲存
|
|
1773
|
-
let st = {
|
|
1774
|
-
btc4hr: {
|
|
1775
|
-
name: 'btc',
|
|
1776
|
-
symbol: 'BTCUSDT',
|
|
1777
|
-
interval: '4hr',
|
|
1778
|
-
},
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
1905
|
//keys, 待率定門檻之指標key, 各key於fdParam內須有對應之`${key}.json`
|
|
1782
1906
|
let keys = ['btc_price_4hr_ma_1day']
|
|
1783
1907
|
|
|
1784
|
-
let m = await estimKeys(ott,
|
|
1785
|
-
keySettings: 'btc4hr',
|
|
1908
|
+
let m = await estimKeys(ott, 'btc', 'BTCUSDT', '4hr', './data/ohlc', './data/param', '2022-07-01T00:00:00', '2025-04-08T00:00:00', 'long', keys, './data/strategy', {
|
|
1786
1909
|
thsTp: [1, 2, 3],
|
|
1787
1910
|
thsSl: [1, 2, 3],
|
|
1788
1911
|
useShowLog: true,
|
|
@@ -1790,12 +1913,12 @@ let m = await estimKeys(ott, st, './data/ohlc', './data/param', '2022-07-01T00:0
|
|
|
1790
1913
|
console.log(m.bestSolution.fitness)
|
|
1791
1914
|
// => 1.0325
|
|
1792
1915
|
|
|
1793
|
-
|
|
1794
|
-
let mQuick = await estimKeys(ott,
|
|
1795
|
-
keySettings: 'btc4hr',
|
|
1916
|
+
//可指定演算法並一併給予其求解設定, 縮小族群數與NContiguous即可快速試算
|
|
1917
|
+
let mQuick = await estimKeys(ott, 'btc', 'BTCUSDT', '4hr', './data/ohlc', './data/param', '2022-07-01T00:00:00', '2025-04-08T00:00:00', 'long', keys, './data/strategy', {
|
|
1796
1918
|
thsTp: [1, 2, 3],
|
|
1797
1919
|
thsSl: [1, 2, 3],
|
|
1798
|
-
|
|
1920
|
+
methodOml: 'PSO',
|
|
1921
|
+
Np: 8, //PSO之粒子數, 預設40
|
|
1799
1922
|
NContiguous: 5, //最佳解連續未更新次數上限, 預設100
|
|
1800
1923
|
})
|
|
1801
1924
|
console.log(mQuick.stopMode)
|
|
@@ -1871,13 +1994,85 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
1871
1994
|
|
|
1872
1995
|
<tr>
|
|
1873
1996
|
|
|
1874
|
-
<td class="name"><code>
|
|
1997
|
+
<td class="name"><code>name</code></td>
|
|
1875
1998
|
|
|
1876
1999
|
|
|
1877
2000
|
<td class="type">
|
|
1878
2001
|
|
|
1879
2002
|
|
|
1880
|
-
<span class="param-type">
|
|
2003
|
+
<span class="param-type">String</span>
|
|
2004
|
+
|
|
2005
|
+
|
|
2006
|
+
|
|
2007
|
+
|
|
2008
|
+
</td>
|
|
2009
|
+
|
|
2010
|
+
|
|
2011
|
+
<td class="attributes">
|
|
2012
|
+
|
|
2013
|
+
|
|
2014
|
+
|
|
2015
|
+
|
|
2016
|
+
|
|
2017
|
+
</td>
|
|
2018
|
+
|
|
2019
|
+
|
|
2020
|
+
|
|
2021
|
+
<td class="default">
|
|
2022
|
+
|
|
2023
|
+
</td>
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
<td class="description last"><p>輸入幣種名稱字串,例如'btc',用於組出K線序列key(<code>${name}_price_${interval}</code>)與縮寫tid</p></td>
|
|
2027
|
+
</tr>
|
|
2028
|
+
|
|
2029
|
+
|
|
2030
|
+
|
|
2031
|
+
<tr>
|
|
2032
|
+
|
|
2033
|
+
<td class="name"><code>symbol</code></td>
|
|
2034
|
+
|
|
2035
|
+
|
|
2036
|
+
<td class="type">
|
|
2037
|
+
|
|
2038
|
+
|
|
2039
|
+
<span class="param-type">String</span>
|
|
2040
|
+
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
|
|
2044
|
+
</td>
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
<td class="attributes">
|
|
2048
|
+
|
|
2049
|
+
|
|
2050
|
+
|
|
2051
|
+
|
|
2052
|
+
|
|
2053
|
+
</td>
|
|
2054
|
+
|
|
2055
|
+
|
|
2056
|
+
|
|
2057
|
+
<td class="default">
|
|
2058
|
+
|
|
2059
|
+
</td>
|
|
2060
|
+
|
|
2061
|
+
|
|
2062
|
+
<td class="description last"><p>輸入交易對名稱字串,例如'BTCUSDT',僅儲存至策略內供辨識</p></td>
|
|
2063
|
+
</tr>
|
|
2064
|
+
|
|
2065
|
+
|
|
2066
|
+
|
|
2067
|
+
<tr>
|
|
2068
|
+
|
|
2069
|
+
<td class="name"><code>interval</code></td>
|
|
2070
|
+
|
|
2071
|
+
|
|
2072
|
+
<td class="type">
|
|
2073
|
+
|
|
2074
|
+
|
|
2075
|
+
<span class="param-type">String</span>
|
|
1881
2076
|
|
|
1882
2077
|
|
|
1883
2078
|
|
|
@@ -1900,7 +2095,7 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
1900
2095
|
</td>
|
|
1901
2096
|
|
|
1902
2097
|
|
|
1903
|
-
<td class="description last"><p
|
|
2098
|
+
<td class="description last"><p>輸入K線週期字串,例如'4hr'</p></td>
|
|
1904
2099
|
</tr>
|
|
1905
2100
|
|
|
1906
2101
|
|
|
@@ -2192,7 +2387,7 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
2192
2387
|
</td>
|
|
2193
2388
|
|
|
2194
2389
|
|
|
2195
|
-
<td class="description last"><p>輸入設定物件,預設{}
|
|
2390
|
+
<td class="description last"><p>輸入設定物件,預設{},除下列欄位外皆傳遞至所選之最佳化函數,故可另給NContiguous等求解設定</p>
|
|
2196
2391
|
<h6>Properties</h6>
|
|
2197
2392
|
|
|
2198
2393
|
|
|
@@ -2222,7 +2417,7 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
2222
2417
|
|
|
2223
2418
|
<tr>
|
|
2224
2419
|
|
|
2225
|
-
<td class="name"><code>
|
|
2420
|
+
<td class="name"><code>methodOml</code></td>
|
|
2226
2421
|
|
|
2227
2422
|
|
|
2228
2423
|
<td class="type">
|
|
@@ -2238,6 +2433,8 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
2238
2433
|
|
|
2239
2434
|
<td class="attributes">
|
|
2240
2435
|
|
|
2436
|
+
<optional><br>
|
|
2437
|
+
|
|
2241
2438
|
|
|
2242
2439
|
|
|
2243
2440
|
|
|
@@ -2248,10 +2445,12 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
2248
2445
|
|
|
2249
2446
|
<td class="default">
|
|
2250
2447
|
|
|
2448
|
+
<code>'PSO'</code>
|
|
2449
|
+
|
|
2251
2450
|
</td>
|
|
2252
2451
|
|
|
2253
2452
|
|
|
2254
|
-
<td class="description last"><p
|
|
2453
|
+
<td class="description last"><p>輸入最佳化演算法字串,可選'RGA'(實數型基因演算法)、'DE'(差分進化法)、'HS'(和聲搜尋法)、'PSO'(粒子群最佳化)與'ACO'(蟻群最佳化),給予其他值時亦採'PSO',預設'PSO'</p></td>
|
|
2255
2454
|
</tr>
|
|
2256
2455
|
|
|
2257
2456
|
|
|
@@ -2524,7 +2723,7 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
2524
2723
|
|
|
2525
2724
|
|
|
2526
2725
|
<div class="param-desc">
|
|
2527
|
-
<p>回傳Promise,resolve
|
|
2726
|
+
<p>回傳Promise,resolve為求解結果物件,含bestSolution(最佳解,內有ps設計變數陣列與fitness適應值)、stopMode(觸發停止之機制字串)、stopIteration(停止時之迴圈數)與stopExecutions(停止時之核心分析次數)等欄位</p>
|
|
2528
2727
|
</div>
|
|
2529
2728
|
|
|
2530
2729
|
|
|
@@ -2551,7 +2750,7 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
2551
2750
|
|
|
2552
2751
|
|
|
2553
2752
|
|
|
2554
|
-
<h4 class="name" id="estimPicks"><span class="type-signature type-signature-async">(async) </span>estimPicks<span class="signature">(ott,
|
|
2753
|
+
<h4 class="name" id="estimPicks"><span class="type-signature type-signature-async">(async) </span>estimPicks<span class="signature">(ott, name, symbol, interval, fdOhlc, fdParam, timeStart, timeEnd, mode, funPickKeys, fdData, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
2555
2754
|
|
|
2556
2755
|
|
|
2557
2756
|
|
|
@@ -2564,14 +2763,14 @@ console.log(mQuick.stopExecutions) //核心分析次數, 較預設設定大幅
|
|
|
2564
2763
|
<dd class="tag-description"><ul class="dummy"><li><p>由fdParam內全部指標key分類後挑選keys,再率定各key之門檻與止盈止損,求解最佳策略</p>
|
|
2565
2764
|
<p>先由fdParam列舉全部指標key,並依名稱分為3類: 開頭為'index_'者為keysIndex(指數類)、含'<em>vbs</em>'者為keysVolumn(成交量類)、其餘為keysNorm(一般類)
|
|
2566
2765
|
分類後各類可經opt內對應之過濾函數再行篩選,接著呼叫funPickKeys由3類挑出待率定之keys,最後交由estimKeys求解
|
|
2567
|
-
fdOhlc、fdParam、timeStart、timeEnd、fdData無效或mode非'long'或'short'或funPickKeys非函數時throw</p>
|
|
2766
|
+
name、symbol、interval、fdOhlc、fdParam、timeStart、timeEnd、fdData無效或mode非'long'或'short'或funPickKeys非函數時throw</p>
|
|
2568
2767
|
<p>Unit Test: <a href="https://github.com/yuda-lyu/w-trade-solve/blob/master/test/unit-estimPicks.test.mjs">Github</a></p></li></ul></dd>
|
|
2569
2768
|
|
|
2570
2769
|
|
|
2571
2770
|
|
|
2572
2771
|
<dt class="tag-source">Source:</dt>
|
|
2573
2772
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2574
|
-
<a href="estimPicks.mjs.html">estimPicks.mjs</a>, <a href="estimPicks.mjs.html#
|
|
2773
|
+
<a href="estimPicks.mjs.html">estimPicks.mjs</a>, <a href="estimPicks.mjs.html#line46">line 46</a>
|
|
2575
2774
|
</li></ul></dd>
|
|
2576
2775
|
|
|
2577
2776
|
|
|
@@ -2620,18 +2819,12 @@ fdOhlc、fdParam、timeStart、timeEnd、fdData無效或mode非'long'或'short'
|
|
|
2620
2819
|
|
|
2621
2820
|
<pre class="prettyprint"><code>import ott from './src/ott.mjs'
|
|
2622
2821
|
|
|
2623
|
-
let st = {
|
|
2624
|
-
btc4hr: { name: 'btc', symbol: 'BTCUSDT', interval: '4hr' },
|
|
2625
|
-
}
|
|
2626
|
-
|
|
2627
2822
|
//funPickKeys, 由一般類挑第1個key為待率定key
|
|
2628
2823
|
let funPickKeys = ({ keysNorm, keysIndex, keysVolumn }) => {
|
|
2629
2824
|
return [keysNorm[0]]
|
|
2630
2825
|
}
|
|
2631
2826
|
|
|
2632
|
-
await estimPicks(ott,
|
|
2633
|
-
keySettings: 'btc4hr',
|
|
2634
|
-
})</code></pre>
|
|
2827
|
+
await estimPicks(ott, 'btc', 'BTCUSDT', '4hr', './data/ohlc', './data/param', '2022-07-01T00:00:00', '2025-04-08T00:00:00', 'long', funPickKeys, './data/strategy', {})</code></pre>
|
|
2635
2828
|
|
|
2636
2829
|
|
|
2637
2830
|
|
|
@@ -2701,13 +2894,13 @@ await estimPicks(ott, st, './data/ohlc', './data/param', '2022-07-01T00:00:00',
|
|
|
2701
2894
|
|
|
2702
2895
|
<tr>
|
|
2703
2896
|
|
|
2704
|
-
<td class="name"><code>
|
|
2897
|
+
<td class="name"><code>name</code></td>
|
|
2705
2898
|
|
|
2706
2899
|
|
|
2707
2900
|
<td class="type">
|
|
2708
2901
|
|
|
2709
2902
|
|
|
2710
|
-
<span class="param-type">
|
|
2903
|
+
<span class="param-type">String</span>
|
|
2711
2904
|
|
|
2712
2905
|
|
|
2713
2906
|
|
|
@@ -2730,7 +2923,79 @@ await estimPicks(ott, st, './data/ohlc', './data/param', '2022-07-01T00:00:00',
|
|
|
2730
2923
|
</td>
|
|
2731
2924
|
|
|
2732
2925
|
|
|
2733
|
-
<td class="description last"><p
|
|
2926
|
+
<td class="description last"><p>輸入幣種名稱字串,例如'btc'</p></td>
|
|
2927
|
+
</tr>
|
|
2928
|
+
|
|
2929
|
+
|
|
2930
|
+
|
|
2931
|
+
<tr>
|
|
2932
|
+
|
|
2933
|
+
<td class="name"><code>symbol</code></td>
|
|
2934
|
+
|
|
2935
|
+
|
|
2936
|
+
<td class="type">
|
|
2937
|
+
|
|
2938
|
+
|
|
2939
|
+
<span class="param-type">String</span>
|
|
2940
|
+
|
|
2941
|
+
|
|
2942
|
+
|
|
2943
|
+
|
|
2944
|
+
</td>
|
|
2945
|
+
|
|
2946
|
+
|
|
2947
|
+
<td class="attributes">
|
|
2948
|
+
|
|
2949
|
+
|
|
2950
|
+
|
|
2951
|
+
|
|
2952
|
+
|
|
2953
|
+
</td>
|
|
2954
|
+
|
|
2955
|
+
|
|
2956
|
+
|
|
2957
|
+
<td class="default">
|
|
2958
|
+
|
|
2959
|
+
</td>
|
|
2960
|
+
|
|
2961
|
+
|
|
2962
|
+
<td class="description last"><p>輸入交易對名稱字串,例如'BTCUSDT'</p></td>
|
|
2963
|
+
</tr>
|
|
2964
|
+
|
|
2965
|
+
|
|
2966
|
+
|
|
2967
|
+
<tr>
|
|
2968
|
+
|
|
2969
|
+
<td class="name"><code>interval</code></td>
|
|
2970
|
+
|
|
2971
|
+
|
|
2972
|
+
<td class="type">
|
|
2973
|
+
|
|
2974
|
+
|
|
2975
|
+
<span class="param-type">String</span>
|
|
2976
|
+
|
|
2977
|
+
|
|
2978
|
+
|
|
2979
|
+
|
|
2980
|
+
</td>
|
|
2981
|
+
|
|
2982
|
+
|
|
2983
|
+
<td class="attributes">
|
|
2984
|
+
|
|
2985
|
+
|
|
2986
|
+
|
|
2987
|
+
|
|
2988
|
+
|
|
2989
|
+
</td>
|
|
2990
|
+
|
|
2991
|
+
|
|
2992
|
+
|
|
2993
|
+
<td class="default">
|
|
2994
|
+
|
|
2995
|
+
</td>
|
|
2996
|
+
|
|
2997
|
+
|
|
2998
|
+
<td class="description last"><p>輸入K線週期字串,例如'4hr'</p></td>
|
|
2734
2999
|
</tr>
|
|
2735
3000
|
|
|
2736
3001
|
|
|
@@ -4934,7 +5199,7 @@ console.log(readStrategies(fd))
|
|
|
4934
5199
|
<br class="clear">
|
|
4935
5200
|
|
|
4936
5201
|
<footer>
|
|
4937
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 05 2026
|
|
5202
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 05 2026 14:58:22 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
4938
5203
|
</footer>
|
|
4939
5204
|
|
|
4940
5205
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
<br class="clear">
|
|
72
72
|
|
|
73
73
|
<footer>
|
|
74
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 05 2026
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 05 2026 14:58:22 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
75
75
|
</footer>
|
|
76
76
|
|
|
77
77
|
<script>prettyPrint();</script>
|
package/docs/ott.mjs.html
CHANGED
|
@@ -124,7 +124,7 @@ export { ott, nowTpeStr, nowTpeStrp }
|
|
|
124
124
|
<br class="clear">
|
|
125
125
|
|
|
126
126
|
<footer>
|
|
127
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 05 2026
|
|
127
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 05 2026 14:58:22 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
128
128
|
</footer>
|
|
129
129
|
|
|
130
130
|
<script>prettyPrint();</script>
|
package/docs/p2r.mjs.html
CHANGED
|
@@ -98,7 +98,7 @@ export default p2r
|
|
|
98
98
|
<br class="clear">
|
|
99
99
|
|
|
100
100
|
<footer>
|
|
101
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 05 2026
|
|
101
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Wed Aug 05 2026 14:58:22 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
102
102
|
</footer>
|
|
103
103
|
|
|
104
104
|
<script>prettyPrint();</script>
|