module changes

This commit is contained in:
zhangkun9038@dingtalk.com 2024-12-16 11:41:20 +08:00
parent a72a120dd7
commit 1dc006253a
19 changed files with 167 additions and 133 deletions

View File

@ -1,3 +0,0 @@
module v5sdk_go/config
go 1.14

5
go.mod
View File

@ -1,3 +1,8 @@
module github.com/phyer/v5sdkgo
go 1.15
require (
github.com/gorilla/websocket v1.5.3
github.com/stretchr/testify v1.10.0
)

21
go.sum
View File

@ -0,0 +1,21 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -1,12 +1,13 @@
package main
package v5sdkgo
import (
"context"
"fmt"
. "github.com/phyer/v5sdkgo/rest"
. "github.com/phyer/v5sdkgo/ws"
"log"
"time"
. "v5sdk_go/rest"
. "v5sdk_go/ws"
)
/*

View File

View File

@ -6,11 +6,11 @@ import (
"encoding/json"
"errors"
"fmt"
. "github.com/phyer/v5sdkgo/utils"
"io/ioutil"
"net/http"
"strings"
"time"
. "v5sdk_go/utils"
)
type RESTAPI struct {

View File

View File

View File

@ -2,10 +2,10 @@ package ws
import (
"errors"
. "github.com/phyer/v5sdkgo/ws/wImpl"
. "github.com/phyer/v5sdkgo/ws/wInterface"
"log"
"runtime/debug"
. "v5sdk_go/ws/wImpl"
. "v5sdk_go/ws/wInterface"
)
// 判断返回结果成功失败

View File

@ -5,7 +5,7 @@ package wImpl
import (
"encoding/json"
. "v5sdk_go/utils"
. "github.com/phyer/v5sdkgo/utils"
)
// jrpc请求结构体

View File

@ -6,7 +6,7 @@ package wImpl
import (
"encoding/json"
. "v5sdk_go/utils"
. "github.com/phyer/v5sdkgo/utils"
)
// 客户端请求消息格式

View File

@ -1,6 +1,8 @@
package wInterface
import . "v5sdk_go/ws/wImpl"
import (
. "github.com/phyer/v5sdkgo/ws/wImpl"
)
// 请求数据
type WSParam interface {

View File

@ -5,14 +5,14 @@ import (
"encoding/json"
"errors"
"fmt"
. "github.com/phyer/v5sdkgo/config"
. "github.com/phyer/v5sdkgo/utils"
. "github.com/phyer/v5sdkgo/ws/wImpl"
"log"
"regexp"
"runtime/debug"
"sync"
"time"
. "v5sdk_go/config"
. "v5sdk_go/utils"
. "v5sdk_go/ws/wImpl"
"github.com/gorilla/websocket"
)
@ -531,6 +531,7 @@ func GetInfoFromErrCode(data ErrData) Event {
/*
从error返回中解析出对应的channel
error信息样例
{"event":"error","msg":"channel:index-tickers,instId:BTC-USDT1 doesn't exist","code":"60018"}
*/
func GetInfoFromErrMsg(raw string) (channel string) {

View File

@ -2,14 +2,15 @@ package ws
import (
"context"
. "github.com/phyer/v5sdkgo/ws/wImpl"
"log"
"time"
. "v5sdk_go/ws/wImpl"
)
/*
websocket交易 通用请求
参数说明
evtId封装的事件类型
id: 请求ID
op: 请求参数op
@ -58,6 +59,7 @@ func (a *WsClient) jrpcReq(evtId Event, op string, id string, params []map[strin
/*
单个下单
参数说明
id: 请求ID
params: 请求参数
timeOut: 超时时间
@ -76,6 +78,7 @@ func (a *WsClient) PlaceOrder(id string, param map[string]interface{}, timeOut .
/*
批量下单
参数说明
id: 请求ID
params: 请求参数
timeOut: 超时时间
@ -91,6 +94,7 @@ func (a *WsClient) BatchPlaceOrders(id string, params []map[string]interface{},
/*
单个撤单
参数说明
id: 请求ID
params: 请求参数
timeOut: 超时时间
@ -110,6 +114,7 @@ func (a *WsClient) CancelOrder(id string, param map[string]interface{}, timeOut
/*
批量撤单
参数说明
id: 请求ID
params: 请求参数
timeOut: 超时时间
@ -125,6 +130,7 @@ func (a *WsClient) BatchCancelOrders(id string, params []map[string]interface{},
/*
单个改单
参数说明
id: 请求ID
params: 请求参数
timeOut: 超时时间
@ -144,6 +150,7 @@ func (a *WsClient) AmendOrder(id string, param map[string]interface{}, timeOut .
/*
批量改单
参数说明
id: 请求ID
params: 请求参数
timeOut: 超时时间

View File

@ -2,9 +2,9 @@ package ws
import (
"fmt"
. "github.com/phyer/v5sdkgo/ws/wImpl"
"testing"
"time"
. "v5sdk_go/ws/wImpl"
)
func PrintDetail(d *ProcessDetail) {

View File

@ -3,14 +3,14 @@ package ws
import (
"context"
"errors"
. "github.com/phyer/v5sdkgo/config"
. "github.com/phyer/v5sdkgo/rest"
. "github.com/phyer/v5sdkgo/utils"
. "github.com/phyer/v5sdkgo/ws/wImpl"
. "github.com/phyer/v5sdkgo/ws/wInterface"
"log"
"sync"
"time"
. "v5sdk_go/config"
"v5sdk_go/rest"
. "v5sdk_go/utils"
. "v5sdk_go/ws/wImpl"
. "v5sdk_go/ws/wInterface"
)
/*

View File

@ -1,7 +1,7 @@
package ws
import (
. "v5sdk_go/ws/wImpl"
. "github.com/phyer/v5sdkgo/ws/wImpl"
)
/*

View File

@ -2,7 +2,7 @@ package ws
import (
"errors"
. "v5sdk_go/ws/wImpl"
. "github.com/phyer/v5sdkgo/ws/wImpl"
)
/*

View File

@ -3,11 +3,11 @@ package ws
import (
"encoding/json"
"fmt"
. "github.com/phyer/v5sdkgo/ws/wImpl"
"log"
"strings"
"testing"
"time"
. "v5sdk_go/ws/wImpl"
)
func prework() *WsClient {