Skip to content

Commit 5bfa5f4

Browse files
committed
fix RunPolicy Index not update
1 parent c28587b commit 5bfa5f4

File tree

12 files changed

+27
-24
lines changed

12 files changed

+27
-24
lines changed

config/biz.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func ApplyConfig(args *CmdArgs, c *Config) *errs.Error {
390390
}
391391

392392
func ApplyPairPolicy(pairs []string, policies []*RunPolicyConfig) {
393-
staticPairs, fixPairs := initPolicies(policies)
393+
staticPairs, fixPairs := SetRunPolicy(true, policies...)
394394
if len(pairs) > 0 {
395395
staticPairs = true
396396
fixPairs = append(fixPairs, pairs...)
@@ -401,13 +401,17 @@ func ApplyPairPolicy(pairs []string, policies []*RunPolicyConfig) {
401401
Pairs, _ = utils2.UniqueItems(pairs)
402402
}
403403

404-
func initPolicies(policyList []*RunPolicyConfig) (bool, []string) {
405-
if policyList == nil {
406-
policyList = make([]*RunPolicyConfig, 0)
404+
// SetRunPolicy set run_policy and their indexs
405+
func SetRunPolicy(index bool, items ...*RunPolicyConfig) (bool, []string) {
406+
if items == nil {
407+
items = make([]*RunPolicyConfig, 0)
407408
}
408409
var polPairs []string
409410
staticPairs := true
410-
for _, pol := range policyList {
411+
for i, pol := range items {
412+
if index {
413+
pol.Index = i
414+
}
411415
if pol.Params == nil {
412416
pol.Params = make(map[string]float64)
413417
}
@@ -421,7 +425,7 @@ func initPolicies(policyList []*RunPolicyConfig) (bool, []string) {
421425
staticPairs = false
422426
}
423427
}
424-
RunPolicy = policyList
428+
RunPolicy = items
425429
return staticPairs, polPairs
426430
}
427431

core/data.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ var (
4343
MemProfile bool
4444

4545
ConcurNum = 2 // The maximum number of K-line tasks to be downloaded at the same time. If it is too high, a 429 current limit will occur. 最大同时下载K线任务数,过大会出现429限流
46-
Version = "v0.2.14-beta.4"
47-
UIVersion = "v0.2.14-beta.4"
46+
Version = "v0.2.14-beta.5"
47+
UIVersion = "v0.2.14-beta.5"
4848
SysLang string // language code for current system 当前系统语言设置
4949
LogFile string
5050
DevDbPath string

entry/entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func RunBackTest(args *config.CmdArgs) *errs.Error {
4040
policyList := config.RunPolicy
4141
for i, item := range policyList {
4242
log.Info("start backtest", zap.Int("id", i+1), zap.String("name", item.Name))
43-
config.RunPolicy = []*config.RunPolicyConfig{item}
43+
config.SetRunPolicy(true, item)
4444
outDir := runBackTest(fmt.Sprintf("%s%d", args.OutPath, i+1), "")
4545
err_ := utils.CopyDir(outDir, fmt.Sprintf("%s_%d", outDir, i+1))
4646
if err_ != nil {

go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7X
33
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
44
github.com/anyongjin/go-bayesopt v1.0.2 h1:845NHAdxk4x1FxeOS5McoaWO33ZfE2AR434j9lnEHAM=
55
github.com/anyongjin/go-bayesopt v1.0.2/go.mod h1:KB64n3O9sPBql6pPnOKh0w8bnOSG1TIMNb+9c/9iQs0=
6-
github.com/banbox/banexg v0.2.24 h1:/JvL1p9iv4WLzacetDiFMW0yLrup8LL60fDN94dKngI=
7-
github.com/banbox/banexg v0.2.24/go.mod h1:OW31oCQoMsPjetaPgtTgHZvBzn34t2CzYYA4iW3TWIs=
6+
github.com/banbox/banexg v0.2.25 h1:X5FTrqXh2iOlKPkXFMGLIiSfpqV1ybokdj8OiinRdKs=
87
github.com/banbox/banexg v0.2.25/go.mod h1:OW31oCQoMsPjetaPgtTgHZvBzn34t2CzYYA4iW3TWIs=
98
github.com/banbox/banta v0.2.0 h1:fXdPHrPBDi3PQTV14pm84yBKIH2teB/3LQ9BUpTmIhI=
109
github.com/banbox/banta v0.2.0/go.mod h1:+9PG7f4QZtfpJfKpGp7aToOUg2ByatDosHjjvGFjaVc=

opt/backtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ func relayUnFinishOrders(pairTfScores map[string]map[string]float64, forbidJobs
480480
lite := NewBackTestLite(true, nil, nil, nil)
481481
// set policy to run
482482
// 重新加载策略任务
483-
config.RunPolicy = gp.Policies
483+
config.SetRunPolicy(false, gp.Policies...)
484484
warms, _, err := strat.LoadStratJobs(core.Pairs, pairTfScores)
485485
if err != nil {
486486
return err

opt/hyper_opt.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func RunRollBTPicker(args *config.CmdArgs) *errs.Error {
140140
t.curMs += t.runMSecs
141141
continue
142142
}
143-
config.RunPolicy = polList
143+
config.SetRunPolicy(true, polList...)
144144
core.BotRunning = true
145145
t.dateRange.StartMS = t.curMs
146146
t.dateRange.EndMS = t.curMs + t.runMSecs
@@ -225,7 +225,7 @@ Update strategy group parameters using EMA to avoid significant differences in p
225225
*/
226226
func applyOptPolicies(olds, pols []*config.RunPolicyConfig, alpha float64) {
227227
if alpha >= 1 {
228-
config.RunPolicy = pols
228+
config.SetRunPolicy(true, pols...)
229229
return
230230
}
231231
var data = make(map[string]*config.RunPolicyConfig)
@@ -250,7 +250,7 @@ func applyOptPolicies(olds, pols []*config.RunPolicyConfig, alpha float64) {
250250
res = append(res, item)
251251
}
252252
}
253-
config.RunPolicy = res
253+
config.SetRunPolicy(true, res...)
254254
}
255255

256256
func RunOptimize(args *config.CmdArgs) *errs.Error {
@@ -494,7 +494,7 @@ func optForGroup(pol *config.RunPolicyConfig, method, picker string, rounds int,
494494
if minScore > 0 && maxScore > 0 {
495495
// 检查组合的是否优于long/short/both
496496
flog.WriteString("\n========== union long/short ============\n")
497-
config.RunPolicy = []*config.RunPolicyConfig{long, short}
497+
config.SetRunPolicy(true, long, short)
498498
bt, loss := runBTOnce()
499499
line := fmt.Sprintf("loss: %5.2f \t%v\n", loss, bt.BriefLine())
500500
flog.WriteString(line)
@@ -511,7 +511,7 @@ func optForGroup(pol *config.RunPolicyConfig, method, picker string, rounds int,
511511
if minScore < 0 || maxScore > minScore*5 {
512512
// The long and short returns are seriously unbalanced, the parameters with high fixed returns remain unchanged, and the parameters with low returns are fine-tuned to find the best score of the combination
513513
// 多空收益严重不均衡,固定收益高的参数不变,微调收益低的参数,寻找组合最佳分数
514-
config.RunPolicy = []*config.RunPolicyConfig{long, short}
514+
config.SetRunPolicy(true, long, short)
515515
var unionScore float64
516516
if long.Score > short.Score {
517517
optForPol(short, method, picker, rounds, flog)

web/ui/src/lib/order/OrderDetail.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
{#if order.info}
104104
<div class="border rounded-lg p-5">
105105
<h3 class="text-lg font-bold mb-4">{m.additional_info()}</h3>
106-
<pre class="whitespace-pre-wrap bg-base-200 p-4 rounded-lg text-sm">{JSON.stringify(order.info, null, 2)}</pre>
106+
<pre class="whitespace-pre-wrap break-all bg-base-200 p-4 rounded-lg text-sm">{JSON.stringify(order.info, null, 2)}</pre>
107107
</div>
108108
{/if}
109109
</div>

web/ui/src/routes/(dev)/+layout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
</div>
152152

153153
<!-- 日志内容 -->
154-
<pre class="flex-1 overflow-auto whitespace-pre-wrap">{logs}</pre>
154+
<pre class="flex-1 overflow-auto whitespace-pre-wrap break-all">{logs}</pre>
155155
</div>
156156
</div>
157157
</div>

web/ui/src/routes/(dev)/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import {getLocale, localizeHref} from "$lib/paraglide/runtime";
55
import {onMount} from "svelte";
66
import {getApi} from "$lib/netio";
7-
import {redirect} from "@sveltejs/kit";
7+
import {goto} from "$app/navigation";
88
99
let showQRCode = $state(false)
1010
1111
onMount(() => {
1212
// /ping可访问表示处于实时模式,跳转到DashBoard
1313
getApi('/ping').then(rsp => {
14-
redirect(302, localizeHref('/dash'))
14+
goto(localizeHref('/dash'))
1515
})
1616
})
1717
</script>

web/ui/src/routes/dash/log/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
<div class="bg-base-200/50 rounded-lg p-4">
5454
<a class="link link-primary link-hover" onclick={() => loadLogs(false)}>{loadingLogs ? m.loading() : m.load_more()}</a>
55-
<pre class="whitespace-pre-wrap font-mono text-sm text-base-content/80">{logs}</pre>
55+
<pre class="whitespace-pre-wrap break-all font-mono text-sm text-base-content/80">{logs}</pre>
5656
</div>
5757
</div>
5858
</div>

0 commit comments

Comments
 (0)