gitee.com/quant1x/engine@v1.8.4/config/range_session_test.go (about)

     1  package config
     2  
     3  import (
     4  	"fmt"
     5  	"gitee.com/quant1x/gox/api"
     6  	"gitee.com/quant1x/pkg/yaml"
     7  	"testing"
     8  )
     9  
    10  func TestTimeRange(t *testing.T) {
    11  	text := " 09:30:00 ~ 14:56:30 "
    12  	text = " 14:56:30 - 09:30:00 "
    13  	var tr TimeRange
    14  	tr.Parse(text)
    15  	fmt.Println(tr)
    16  	text = "09:15:00~09:26:59,09:15:00~09:19:59,09:25:00~11:29:59,13:00:00~14:59:59,09:00:00~09:14:59"
    17  	var ts TradingSession
    18  	ts.Parse(text)
    19  	fmt.Println(ts)
    20  	fmt.Println(ts.IsTrading())
    21  }
    22  
    23  type tt struct {
    24  	Session    TimeRange `yaml:"session"`
    25  	ChangeRate float64   `yaml:"change_rate" default:"0.01"`
    26  }
    27  
    28  func TestTimeRangeWithParse(t *testing.T) {
    29  	text := `time: "09:50:00~09:50:59,10:50:00~10:50:59"`
    30  	text = `
    31  session: "09:50:00~09:50:59"
    32  name: "buyiwang"
    33  `
    34  	bytes := api.String2Bytes(text)
    35  	v := tt{}
    36  	err := yaml.Unmarshal(bytes, &v)
    37  	fmt.Println(err, v)
    38  }