w-trade-backtest 1.0.3 → 1.0.4

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/docs/global.html CHANGED
@@ -29,7 +29,7 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#calcOrders">calcOrders</a></li><li><a href="global.html#calcOrdersRatio">calcOrdersRatio</a></li><li><a href="global.html#calcOrdersSummary">calcOrdersSummary</a></li><li><a href="global.html#calcOrdersSummarySimple">calcOrdersSummarySimple</a></li><li><a href="global.html#calcSummary">calcSummary</a></li><li><a href="global.html#closeAndSummaryOrders">closeAndSummaryOrders</a></li><li><a href="global.html#genReport">genReport</a></li><li><a href="global.html#genReportCore">genReportCore</a></li><li><a href="global.html#runStrategies">runStrategies</a></li><li><a href="global.html#runStrategy">runStrategy</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#calcOrders">calcOrders</a></li><li><a href="global.html#calcOrdersRatio">calcOrdersRatio</a></li><li><a href="global.html#calcOrdersSummary">calcOrdersSummary</a></li><li><a href="global.html#calcOrdersSummarySimple">calcOrdersSummarySimple</a></li><li><a href="global.html#calcSummary">calcSummary</a></li><li><a href="global.html#closeAndSummaryOrders">closeAndSummaryOrders</a></li><li><a href="global.html#genReport">genReport</a></li><li><a href="global.html#genReportCore">genReportCore</a></li><li><a href="global.html#runStrategies">runStrategies</a></li><li><a href="global.html#runStrategiesAndBacktest">runStrategiesAndBacktest</a></li><li><a href="global.html#runStrategy">runStrategy</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
@@ -3755,6 +3755,595 @@ console.log(rr.summary.uIni, rr.summary.numTrade, rr.summary.rWin)
3755
3755
 
3756
3756
 
3757
3757
 
3758
+ <h4 class="name" id="runStrategiesAndBacktest"><span class="type-signature type-signature-async">(async) </span>runStrategiesAndBacktest<span class="signature">(ott, fdOhlc, fdParam, strategies, timeStart, timeEnd, fdTest, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
3759
+
3760
+
3761
+
3762
+
3763
+
3764
+
3765
+ <dl class="details">
3766
+
3767
+ <dt class="tag-description">Description:</dt>
3768
+ <dd class="tag-description"><ul class="dummy"><li><p>執行多策略回測並輸出訂單、摘要與報告檔案</p>
3769
+ <p>以w-data-tdprovide讀取fdOhlc與fdParam資料夾數據,建立timeStart至timeEnd範圍之序列查詢函數後執行runStrategies
3770
+ 合併結果命名為'全部策略',並輸出orders.json、summary.json、report.html至fdTest資料夾
3771
+ fdOhlc或fdParam非資料夾、strategies非有效陣列時throw</p>
3772
+ <p>Unit Test: <a href="https://github.com/yuda-lyu/w-trade-backtest/blob/master/test/unit-WTradeBacktest.test.mjs">Github</a></p></li></ul></dd>
3773
+
3774
+
3775
+
3776
+ <dt class="tag-source">Source:</dt>
3777
+ <dd class="tag-source"><ul class="dummy"><li>
3778
+ <a href="runStrategiesAndBacktest.mjs.html">runStrategiesAndBacktest.mjs</a>, <a href="runStrategiesAndBacktest.mjs.html#line74">line 74</a>
3779
+ </li></ul></dd>
3780
+
3781
+
3782
+
3783
+
3784
+
3785
+
3786
+
3787
+
3788
+
3789
+
3790
+
3791
+
3792
+
3793
+
3794
+
3795
+
3796
+
3797
+
3798
+
3799
+
3800
+
3801
+
3802
+
3803
+
3804
+
3805
+
3806
+
3807
+
3808
+
3809
+
3810
+
3811
+ </dl>
3812
+
3813
+
3814
+
3815
+
3816
+
3817
+
3818
+
3819
+
3820
+
3821
+
3822
+
3823
+ <h5 class="h5-examples">Example</h5>
3824
+
3825
+ <pre class="prettyprint"><code>import fs from 'fs'
3758
3826
  { time: '2020-01-01T00:00:00', Open: 100, High: 101, Low: 99, Close: 100 },
3759
3827
  { time: '2020-01-01T04:00:00', Open: 100, High: 106, Low: 100, Close: 105 },
3760
3828
  { time: '2020-01-01T08:00:00', Open: 105, High: 107, Low: 102, Close: 103 },
3761
3829
  { time: '2020-01-01T12:00:00', Open: 103, High: 104, Low: 94, Close: 95 },
3762
3830
  { time: '2020-01-01T16:00:00', Open: 95, High: 98, Low: 92, Close: 93 },
3763
3831
  { time: '2020-01-01T20:00:00', Open: 93, High: 99, Low: 95, Close: 97 },
3764
3832
  { time: '2020-01-01T00:00:00', param: 1 },
3765
3833
  { time: '2020-01-01T04:00:00', param: 0 },
3766
3834
  { time: '2020-01-01T08:00:00', param: 1 },
3767
3835
  { time: '2020-01-01T12:00:00', param: 0 },
3768
3836
  { time: '2020-01-01T16:00:00', param: 0 },
3769
3837
  { time: '2020-01-01T20:00:00', param: 0 },
3770
3838
  { sid: 's1', mode: 'long', keyOhlc: 'btc', conds: [{ key: 'sig', sym: '>', th: 0.5, opr: 'and' }], settings },
3771
3839
  { sid: 's2', mode: 'short', keyOhlc: 'btc', conds: [{ key: 'sig', sym: '&lt;', th: 0.5, opr: 'and' }], settings },
3840
+
3841
+
3842
+
3843
+
3844
+ <h5 class="h5-parameters">Parameters:</h5>
3845
+
3846
+
3847
+ <table class="params">
3848
+ <thead>
3849
+ <tr>
3850
+
3851
+ <th>Name</th>
3852
+
3853
+
3854
+ <th>Type</th>
3855
+
3856
+
3857
+ <th>Attributes</th>
3858
+
3859
+
3860
+
3861
+ <th>Default</th>
3862
+
3863
+
3864
+ <th class="last">Description</th>
3865
+ </tr>
3866
+ </thead>
3867
+
3868
+ <tbody>
3869
+
3870
+
3871
+ <tr>
3872
+
3873
+ <td class="name"><code>ott</code></td>
3874
+
3875
+
3876
+ <td class="type">
3877
+
3878
+
3879
+ <span class="param-type">function</span>
3880
+
3881
+
3882
+
3883
+
3884
+ </td>
3885
+
3886
+
3887
+ <td class="attributes">
3888
+
3889
+
3890
+
3891
+
3892
+
3893
+ </td>
3894
+
3895
+
3896
+
3897
+ <td class="default">
3898
+
3899
+ </td>
3900
+
3901
+
3902
+ <td class="description last"><p>輸入時區時間函數,傳入時間字串回傳dayjs時間物件(可用src/ott.mjs或自行以dayjs包裝)</p></td>
3903
+ </tr>
3904
+
3905
+
3906
+
3907
+ <tr>
3908
+
3909
+ <td class="name"><code>fdOhlc</code></td>
3910
+
3911
+
3912
+ <td class="type">
3913
+
3914
+
3915
+ <span class="param-type">String</span>
3916
+
3917
+
3918
+
3919
+
3920
+ </td>
3921
+
3922
+
3923
+ <td class="attributes">
3924
+
3925
+
3926
+
3927
+
3928
+
3929
+ </td>
3930
+
3931
+
3932
+
3933
+ <td class="default">
3934
+
3935
+ </td>
3936
+
3937
+
3938
+ <td class="description last"><p>輸入儲存K線(ohlc)序列資料夾字串,各序列以<code>${key}.json</code>儲存</p></td>
3939
+ </tr>
3940
+
3941
+
3942
+
3943
+ <tr>
3944
+
3945
+ <td class="name"><code>fdParam</code></td>
3946
+
3947
+
3948
+ <td class="type">
3949
+
3950
+
3951
+ <span class="param-type">String</span>
3952
+
3953
+
3954
+
3955
+
3956
+ </td>
3957
+
3958
+
3959
+ <td class="attributes">
3960
+
3961
+
3962
+
3963
+
3964
+
3965
+ </td>
3966
+
3967
+
3968
+
3969
+ <td class="default">
3970
+
3971
+ </td>
3972
+
3973
+
3974
+ <td class="description last"><p>輸入儲存指標參數序列資料夾字串</p></td>
3975
+ </tr>
3976
+
3977
+
3978
+
3979
+ <tr>
3980
+
3981
+ <td class="name"><code>strategies</code></td>
3982
+
3983
+
3984
+ <td class="type">
3985
+
3986
+
3987
+ <span class="param-type">Array</span>
3988
+
3989
+
3990
+
3991
+
3992
+ </td>
3993
+
3994
+
3995
+ <td class="attributes">
3996
+
3997
+
3998
+
3999
+
4000
+
4001
+ </td>
4002
+
4003
+
4004
+
4005
+ <td class="default">
4006
+
4007
+ </td>
4008
+
4009
+
4010
+ <td class="description last"><p>輸入策略陣列,各元素需含sid與runStrategy之strategy欄位</p></td>
4011
+ </tr>
4012
+
4013
+
4014
+
4015
+ <tr>
4016
+
4017
+ <td class="name"><code>timeStart</code></td>
4018
+
4019
+
4020
+ <td class="type">
4021
+
4022
+
4023
+ <span class="param-type">String</span>
4024
+
4025
+
4026
+
4027
+
4028
+ </td>
4029
+
4030
+
4031
+ <td class="attributes">
4032
+
4033
+
4034
+
4035
+
4036
+
4037
+ </td>
4038
+
4039
+
4040
+
4041
+ <td class="default">
4042
+
4043
+ </td>
4044
+
4045
+
4046
+ <td class="description last"><p>輸入回測起始秒時間字串</p></td>
4047
+ </tr>
4048
+
4049
+
4050
+
4051
+ <tr>
4052
+
4053
+ <td class="name"><code>timeEnd</code></td>
4054
+
4055
+
4056
+ <td class="type">
4057
+
4058
+
4059
+ <span class="param-type">String</span>
4060
+
4061
+
4062
+
4063
+
4064
+ </td>
4065
+
4066
+
4067
+ <td class="attributes">
4068
+
4069
+
4070
+
4071
+
4072
+
4073
+ </td>
4074
+
4075
+
4076
+
4077
+ <td class="default">
4078
+
4079
+ </td>
4080
+
4081
+
4082
+ <td class="description last"><p>輸入回測結束秒時間字串</p></td>
4083
+ </tr>
4084
+
4085
+
4086
+
4087
+ <tr>
4088
+
4089
+ <td class="name"><code>fdTest</code></td>
4090
+
4091
+
4092
+ <td class="type">
4093
+
4094
+
4095
+ <span class="param-type">String</span>
4096
+
4097
+
4098
+
4099
+
4100
+ </td>
4101
+
4102
+
4103
+ <td class="attributes">
4104
+
4105
+
4106
+
4107
+
4108
+
4109
+ </td>
4110
+
4111
+
4112
+
4113
+ <td class="default">
4114
+
4115
+ </td>
4116
+
4117
+
4118
+ <td class="description last"><p>輸入輸出結果資料夾字串</p></td>
4119
+ </tr>
4120
+
4121
+
4122
+
4123
+ <tr>
4124
+
4125
+ <td class="name"><code>opt</code></td>
4126
+
4127
+
4128
+ <td class="type">
4129
+
4130
+
4131
+ <span class="param-type">Object</span>
4132
+
4133
+
4134
+
4135
+
4136
+ </td>
4137
+
4138
+
4139
+ <td class="attributes">
4140
+
4141
+ &lt;optional><br>
4142
+
4143
+
4144
+
4145
+
4146
+
4147
+ </td>
4148
+
4149
+
4150
+
4151
+ <td class="default">
4152
+
4153
+ <code>{}</code>
4154
+
4155
+ </td>
4156
+
4157
+
4158
+ <td class="description last"><p>輸入設定物件,預設{}</p>
4159
+ <h6>Properties</h6>
4160
+
4161
+
4162
+ <table class="params">
4163
+ <thead>
4164
+ <tr>
4165
+
4166
+ <th>Name</th>
4167
+
4168
+
4169
+ <th>Type</th>
4170
+
4171
+
4172
+ <th>Attributes</th>
4173
+
4174
+
4175
+
4176
+ <th>Default</th>
4177
+
4178
+
4179
+ <th class="last">Description</th>
4180
+ </tr>
4181
+ </thead>
4182
+
4183
+ <tbody>
4184
+
4185
+
4186
+ <tr>
4187
+
4188
+ <td class="name"><code>writeOrders</code></td>
4189
+
4190
+
4191
+ <td class="type">
4192
+
4193
+
4194
+ <span class="param-type">Boolean</span>
4195
+
4196
+
4197
+
4198
+
4199
+ </td>
4200
+
4201
+
4202
+ <td class="attributes">
4203
+
4204
+ &lt;optional><br>
4205
+
4206
+
4207
+
4208
+
4209
+
4210
+ </td>
4211
+
4212
+
4213
+
4214
+ <td class="default">
4215
+
4216
+ <code>true</code>
4217
+
4218
+ </td>
4219
+
4220
+
4221
+ <td class="description last"><p>輸入是否輸出orders.json布林值,預設true</p></td>
4222
+ </tr>
4223
+
4224
+
4225
+
4226
+ <tr>
4227
+
4228
+ <td class="name"><code>writeSummary</code></td>
4229
+
4230
+
4231
+ <td class="type">
4232
+
4233
+
4234
+ <span class="param-type">Boolean</span>
4235
+
4236
+
4237
+
4238
+
4239
+ </td>
4240
+
4241
+
4242
+ <td class="attributes">
4243
+
4244
+ &lt;optional><br>
4245
+
4246
+
4247
+
4248
+
4249
+
4250
+ </td>
4251
+
4252
+
4253
+
4254
+ <td class="default">
4255
+
4256
+ <code>true</code>
4257
+
4258
+ </td>
4259
+
4260
+
4261
+ <td class="description last"><p>輸入是否輸出summary.json布林值,預設true</p></td>
4262
+ </tr>
4263
+
4264
+
4265
+
4266
+ <tr>
4267
+
4268
+ <td class="name"><code>writeReport</code></td>
4269
+
4270
+
4271
+ <td class="type">
4272
+
4273
+
4274
+ <span class="param-type">Boolean</span>
4275
+
4276
+
4277
+
4278
+
4279
+ </td>
4280
+
4281
+
4282
+ <td class="attributes">
4283
+
4284
+ &lt;optional><br>
4285
+
4286
+
4287
+
4288
+
4289
+
4290
+ </td>
4291
+
4292
+
4293
+
4294
+ <td class="default">
4295
+
4296
+ <code>true</code>
4297
+
4298
+ </td>
4299
+
4300
+
4301
+ <td class="description last"><p>輸入是否輸出report.html布林值,預設true</p></td>
4302
+ </tr>
4303
+
4304
+
4305
+ </tbody>
4306
+ </table>
4307
+
4308
+ </td>
4309
+ </tr>
4310
+
4311
+
4312
+ </tbody>
4313
+ </table>
4314
+
4315
+
4316
+
4317
+
4318
+
4319
+
4320
+
4321
+
4322
+
4323
+
4324
+
4325
+
4326
+
4327
+
4328
+
4329
+
4330
+ <h5 class="h5-returns">Returns:</h5>
4331
+
4332
+
4333
+ <div class="param-desc">
4334
+ <p>回傳Promise,resolve為{name,orders,summary}物件,另於fdTest輸出結果檔案</p>
4335
+ </div>
4336
+
4337
+
4338
+
4339
+ <dl class="param-type">
4340
+ <dt>
4341
+ Type
4342
+ </dt>
4343
+ <dd>
4344
+
4345
+ <span class="param-type">Promise</span>
4346
+
4347
+
4348
+
4349
+ </dd>
4350
+ </dl>
4351
+
4352
+
4353
+
4354
+
4355
+
4356
+
4357
+
4358
+
4359
+
4360
+
3772
4361
  <h4 class="name" id="runStrategy"><span class="type-signature type-signature-async">(async) </span>runStrategy<span class="signature">(ott, strategy, funGetSeries, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
3773
4362
 
3774
4363
 
@@ -4218,7 +4807,7 @@ console.log(r.summary.numTrade, r.summary.rWin, r.summary.uEquityFinal)
4218
4807
  <br class="clear">
4219
4808
 
4220
4809
  <footer>
4221
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Aug 02 2026 20:09:43 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
4810
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Aug 03 2026 10:26:54 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
4222
4811
  </footer>
4223
4812
 
4224
4813
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -29,7 +29,7 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#calcOrders">calcOrders</a></li><li><a href="global.html#calcOrdersRatio">calcOrdersRatio</a></li><li><a href="global.html#calcOrdersSummary">calcOrdersSummary</a></li><li><a href="global.html#calcOrdersSummarySimple">calcOrdersSummarySimple</a></li><li><a href="global.html#calcSummary">calcSummary</a></li><li><a href="global.html#closeAndSummaryOrders">closeAndSummaryOrders</a></li><li><a href="global.html#genReport">genReport</a></li><li><a href="global.html#genReportCore">genReportCore</a></li><li><a href="global.html#runStrategies">runStrategies</a></li><li><a href="global.html#runStrategy">runStrategy</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#calcOrders">calcOrders</a></li><li><a href="global.html#calcOrdersRatio">calcOrdersRatio</a></li><li><a href="global.html#calcOrdersSummary">calcOrdersSummary</a></li><li><a href="global.html#calcOrdersSummarySimple">calcOrdersSummarySimple</a></li><li><a href="global.html#calcSummary">calcSummary</a></li><li><a href="global.html#closeAndSummaryOrders">closeAndSummaryOrders</a></li><li><a href="global.html#genReport">genReport</a></li><li><a href="global.html#genReportCore">genReportCore</a></li><li><a href="global.html#runStrategies">runStrategies</a></li><li><a href="global.html#runStrategiesAndBacktest">runStrategiesAndBacktest</a></li><li><a href="global.html#runStrategy">runStrategy</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
@@ -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 Sun Aug 02 2026 20:09:43 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Aug 03 2026 10:26:55 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
@@ -29,7 +29,7 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#calcOrders">calcOrders</a></li><li><a href="global.html#calcOrdersRatio">calcOrdersRatio</a></li><li><a href="global.html#calcOrdersSummary">calcOrdersSummary</a></li><li><a href="global.html#calcOrdersSummarySimple">calcOrdersSummarySimple</a></li><li><a href="global.html#calcSummary">calcSummary</a></li><li><a href="global.html#closeAndSummaryOrders">closeAndSummaryOrders</a></li><li><a href="global.html#genReport">genReport</a></li><li><a href="global.html#genReportCore">genReportCore</a></li><li><a href="global.html#runStrategies">runStrategies</a></li><li><a href="global.html#runStrategy">runStrategy</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#calcOrders">calcOrders</a></li><li><a href="global.html#calcOrdersRatio">calcOrdersRatio</a></li><li><a href="global.html#calcOrdersSummary">calcOrdersSummary</a></li><li><a href="global.html#calcOrdersSummarySimple">calcOrdersSummarySimple</a></li><li><a href="global.html#calcSummary">calcSummary</a></li><li><a href="global.html#closeAndSummaryOrders">closeAndSummaryOrders</a></li><li><a href="global.html#genReport">genReport</a></li><li><a href="global.html#genReportCore">genReportCore</a></li><li><a href="global.html#runStrategies">runStrategies</a></li><li><a href="global.html#runStrategiesAndBacktest">runStrategiesAndBacktest</a></li><li><a href="global.html#runStrategy">runStrategy</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
@@ -231,7 +231,7 @@ export default runStrategies
231
231
  <br class="clear">
232
232
 
233
233
  <footer>
234
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Aug 02 2026 20:09:43 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
234
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Aug 03 2026 10:26:54 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
235
235
  </footer>
236
236
 
237
237
  <script>prettyPrint();</script>