[update] 新增模拟交易参数
This commit is contained in:
parent
15e2268351
commit
eddcaecc92
|
@ -43,6 +43,7 @@ type ExchangeSession struct {
|
|||
Secret string `json:"secret,omitempty" yaml:"secret,omitempty"`
|
||||
Passphrase string `json:"passphrase,omitempty" yaml:"passphrase,omitempty"`
|
||||
Proxy string `json:"proxy,omitempty" yaml:"proxy,omitempty"`
|
||||
Simulated string `json:"simulated,omitempty" yaml:"simulated,omitempty"`
|
||||
SubAccount string `json:"subAccount,omitempty" yaml:"subAccount,omitempty"`
|
||||
|
||||
// Withdrawal is used for enabling withdrawal functions
|
||||
|
@ -796,7 +797,7 @@ func (session *ExchangeSession) newBasicPrivateExchange(exchangeName types.Excha
|
|||
var err error
|
||||
var exMinimal types.ExchangeMinimal
|
||||
if session.Key != "" && session.Secret != "" {
|
||||
exMinimal, err = exchange2.New(exchangeName, session.Key, session.Secret, session.Passphrase, session.Proxy)
|
||||
exMinimal, err = exchange2.New(exchangeName, session.Key, session.Secret, session.Passphrase, session.Proxy, session.Simulated)
|
||||
} else {
|
||||
exMinimal, err = exchange2.NewWithEnvVarPrefix(exchangeName, session.EnvVarPrefix)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func NewPublic(exchangeName types.ExchangeName) (types.Exchange, error) {
|
||||
exMinimal, err := New(exchangeName, "", "", "", "")
|
||||
exMinimal, err := New(exchangeName, "", "", "", "", "0")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func NewPublic(exchangeName types.ExchangeName) (types.Exchange, error) {
|
|||
return nil, fmt.Errorf("exchange %T does not implement types.Exchange", exMinimal)
|
||||
}
|
||||
|
||||
func New(n types.ExchangeName, key, secret, passphrase, proxy string) (types.ExchangeMinimal, error) {
|
||||
func New(n types.ExchangeName, key, secret, passphrase, proxy, simulated string) (types.ExchangeMinimal, error) {
|
||||
switch n {
|
||||
|
||||
case types.ExchangeBinance:
|
||||
|
@ -37,7 +37,7 @@ func New(n types.ExchangeName, key, secret, passphrase, proxy string) (types.Exc
|
|||
return max.New(key, secret), nil
|
||||
|
||||
case types.ExchangeOKEx:
|
||||
return okex.New(key, secret, passphrase), nil
|
||||
return okex.New(key, secret, passphrase, simulated), nil
|
||||
|
||||
case types.ExchangeKucoin:
|
||||
return kucoin.New(key, secret, passphrase), nil
|
||||
|
@ -71,5 +71,6 @@ func NewWithEnvVarPrefix(n types.ExchangeName, varPrefix string) (types.Exchange
|
|||
|
||||
passphrase := os.Getenv(varPrefix + "_API_PASSPHRASE")
|
||||
proxy := os.Getenv(varPrefix + "_PROXY")
|
||||
return New(n, key, secret, passphrase, proxy)
|
||||
simulated := os.Getenv(varPrefix + "_SIMULATED")
|
||||
return New(n, key, secret, passphrase, proxy, simulated)
|
||||
}
|
||||
|
|
|
@ -65,13 +65,12 @@ var log = logrus.WithFields(logrus.Fields{
|
|||
var ErrSymbolRequired = errors.New("symbol is a required parameter")
|
||||
|
||||
type Exchange struct {
|
||||
key, secret, passphrase string
|
||||
|
||||
client *okexapi.RestClient
|
||||
timeNowFunc func() time.Time
|
||||
key, secret, passphrase, simulated string
|
||||
client *okexapi.RestClient
|
||||
timeNowFunc func() time.Time
|
||||
}
|
||||
|
||||
func New(key, secret, passphrase string) *Exchange {
|
||||
func New(key, secret, passphrase, simulated string) *Exchange {
|
||||
client := okexapi.NewClient()
|
||||
|
||||
if len(key) > 0 && len(secret) > 0 {
|
||||
|
@ -82,6 +81,7 @@ func New(key, secret, passphrase string) *Exchange {
|
|||
key: key,
|
||||
secret: secret,
|
||||
passphrase: passphrase,
|
||||
simulated: simulated,
|
||||
client: client,
|
||||
timeNowFunc: time.Now,
|
||||
}
|
||||
|
|
|
@ -24,6 +24,18 @@ const PublicWebSocketURL = "wss://wsaws.okx.com:8443/ws/v5/public"
|
|||
const PrivateWebSocketURL = "wss://wsaws.okx.com:8443/ws/v5/private"
|
||||
const PublicBusinessWebSocketURL = "wss://wsaws.okx.com:8443/ws/v5/business"
|
||||
|
||||
/*
|
||||
模拟交易
|
||||
REST:https://www.okx.com
|
||||
WebSocket公共频道:wss://wspap.okx.com:8443/ws/v5/public
|
||||
WebSocket私有频道:wss://wspap.okx.com:8443/ws/v5/private
|
||||
WebSocket业务频道:wss://wspap.okx.com:8443/ws/v5/business
|
||||
*/
|
||||
const SimulatedRestBaseURL = "https://www.okx.com/"
|
||||
const SimulatedPublicWebSocketURL = "wss://wspap.okx.com:8443/ws/v5/public"
|
||||
const SimulatedPrivateWebSocketURL = "wss://wspap.okx.com:8443/ws/v5/private"
|
||||
const SimulatedPublicBusinessWebSocketURL = "wss://wspap.okx.com:8443/ws/v5/business"
|
||||
|
||||
type SideType string
|
||||
|
||||
const (
|
||||
|
|
|
@ -16,7 +16,7 @@ func Test_QueryKlines(t *testing.T) {
|
|||
t.Skip("Please configure all credentials about OKEX")
|
||||
}
|
||||
|
||||
e := New(key, secret, passphrase)
|
||||
e := New(key, secret, passphrase, "0")
|
||||
|
||||
queryOrder := types.OrderQuery{
|
||||
Symbol: "BTC-USDT",
|
||||
|
|
Loading…
Reference in New Issue
Block a user