mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
查询盘口信息得初始化DefaultCodes
This commit is contained in:
13
codes.go
13
codes.go
@@ -3,6 +3,7 @@ package tdx
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/injoyai/conv"
|
"github.com/injoyai/conv"
|
||||||
|
"github.com/injoyai/ios/client"
|
||||||
"github.com/injoyai/logs"
|
"github.com/injoyai/logs"
|
||||||
"github.com/injoyai/tdx/protocol"
|
"github.com/injoyai/tdx/protocol"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
@@ -17,7 +18,17 @@ import (
|
|||||||
// DefaultCodes 增加单例,部分数据需要通过Codes里面的信息计算
|
// DefaultCodes 增加单例,部分数据需要通过Codes里面的信息计算
|
||||||
var DefaultCodes *Codes
|
var DefaultCodes *Codes
|
||||||
|
|
||||||
func NewCodes(c *Client, filename string) (*Codes, error) {
|
func DialCodes(filename string, op ...client.Option) (*Codes, error) {
|
||||||
|
c, err := DialDefault(op...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewCodes(c, filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCodes(c *Client, filenames ...string) (*Codes, error) {
|
||||||
|
|
||||||
|
filename := conv.DefaultString("./codes.db", filenames...)
|
||||||
|
|
||||||
//如果文件夹不存在就创建
|
//如果文件夹不存在就创建
|
||||||
dir, _ := filepath.Split(filename)
|
dir, _ := filepath.Split(filename)
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ func main() {
|
|||||||
c, err := tdx.Dial("124.71.187.122:7709", tdx.WithDebug())
|
c, err := tdx.Dial("124.71.187.122:7709", tdx.WithDebug())
|
||||||
logs.PanicErr(err)
|
logs.PanicErr(err)
|
||||||
|
|
||||||
|
tdx.DefaultCodes, err = tdx.NewCodes(c, "./codes.db")
|
||||||
|
logs.PanicErr(err)
|
||||||
|
|
||||||
_ = c
|
_ = c
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user