sv / kdbgo

kdb+ client driver for Go
MIT License
44 stars 29 forks source link

type time.Duration upsert error #3

Closed xuuj closed 7 years ago

xuuj commented 7 years ago

time:= &kdb.K{kdb.KN, kdb.NONE, []int64{t2.Nanoseconds()}} when I use time.Duration to upsert KDB I got the ERROR: logging before flag.Parse: E0223 11:52:50.294900 13024 decode.go:129] Failed to read message header: EOF

sv commented 7 years ago

I removed the dependency on glog. You should be free to use any package for logging

xuuj commented 7 years ago

upsert time.Duration Data still return the error :"Failed to read message header:EOF"

sv commented 7 years ago

Could you post whole reproducer or link to playground?

On Fri, 24 Feb 2017, 01:45 xuuj, notifications@github.com wrote:

upsert time.Duration Data still return the error :"Failed to read message header:EOF"

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/sv/kdbgo/issues/3#issuecomment-282179262, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA3Brg4C4uMEoIwcjl-yOfINDh6iL2Yks5rfjY6gaJpZM4MJh7x .

xuuj commented 7 years ago

this is my function: func main() { var con *kdb.KDBConn var err error fmt.Println("start") con, err = kdb.DialKDB("127.0.0.1", 5010, "") if err != nil { fmt.Printf("Failed to connect kdb: %s", err.Error())

} else {
    fmt.Println("connect success!!!!")
}

var values = []*kdb.K{}
table := kdb.Table{}
t := time.Now()
ts := t.Hour() * 3600 + t.Minute() * 60 + t.Second()
str := strconv.Itoa(ts)
str = str + "s"
t2, _ := time.ParseDuration(str)
time := &kdb.K{kdb.KN, kdb.NONE, []int64{t2.Nanoseconds()}}
fmt.Println(time)
sym := &kdb.K{kdb.KS, kdb.NONE, []string{"601818"}}
szWindCode := &kdb.K{kdb.KS, kdb.NONE, []string{"601818.sz"}}
nActionDay := &kdb.K{kdb.KI, kdb.NONE, []int32{20160101}}
nTime := &kdb.K{kdb.KI, kdb.NONE, []int32{93001000}}
nIndex := &kdb.K{kdb.KI, kdb.NONE, []int32{0}}
nPrice := &kdb.K{kdb.KI, kdb.NONE, []int32{0}}
nVolume := &kdb.K{kdb.KI, kdb.NONE, []int32{0}}
nTurnover := &kdb.K{kdb.KI, kdb.NONE, []int32{0}}
nBSFlag := &kdb.K{kdb.KI, kdb.NONE, []int32{0}}
chOrderKind := &kdb.K{kdb.KC, kdb.NONE, "s"}
chFunctionCode := &kdb.K{kdb.KC, kdb.NONE, "s"}
nAskOrder := &kdb.K{kdb.KI, kdb.NONE, []int32{0}}
nBidOrder := &kdb.K{kdb.KI, kdb.NONE, []int32{0}}

values = append(values, time)
values = append(values, sym)
values = append(values, szWindCode)
values = append(values, nActionDay)
values = append(values, nTime)
values = append(values, nIndex)
values = append(values, nPrice)
values = append(values, nVolume)
values = append(values, nTurnover)
values = append(values, nBSFlag)
values = append(values, chOrderKind)
values = append(values, chFunctionCode)
values = append(values, nAskOrder)
values = append(values, nBidOrder)
table.Columns = []string{"time", "sym", "szWindCode", "nActionDay", "nTime", "nIndex", "nPrice", "nVolume", "nTurnover", "nBSFlag", "chOrderKind", "chFunctionCode", "nAskOrder", "nBidOrder"}
table.Data = values

k_tab := &kdb.K{kdb.XT, kdb.NONE, table}
fmt.Println(k_tab)
if ret, err := con.Call("upsert", &kdb.K{-kdb.KS, kdb.NONE, "Transaction"}, k_tab); err != nil {
    fmt.Println("Execute kdb function failed error: %v, return: %v",
        err, ret)

} else {
    fmt.Println("execute function success!!!!")
}

} Transaction table struct in KDB : Transaction:([]time:timespan$(); sym:symbol$(); szWindCode:symbol$(); nActionDay:int$(); nTime:int$(); nIndex:int$(); nPrice:int$(); nVolume:int$(); nTurnover:int$(); nBSFlag:int$(); chOrderKind:char$(); chFunctionCode:char$(); nAskOrder:int$(); nBidOrder:int$())

sv commented 7 years ago

timespan was not supported in encoding. Also I expect you were getting 'badmsg error on kdb side...

xuuj commented 7 years ago

yes,how can I solve this problem

sv commented 7 years ago

I updated report already

On Fri, 24 Feb 2017, 09:16 xuuj, notifications@github.com wrote:

yes,how can I solve this problem

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/sv/kdbgo/issues/3#issuecomment-282243003, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA3BvNzfUibtX2SPMZ4vDLFWY4nmAFIks5rfp_ygaJpZM4MJh7x .

sv commented 7 years ago

And you are always welcomed to submit PR yourself :)

xuuj commented 7 years ago

thanks :)