mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
binance: fix, call set time service only when key and secret is given
This commit is contained in:
parent
8b93aeeeb2
commit
bace225470
|
@ -57,13 +57,12 @@ type Exchange struct {
|
||||||
func New(key, secret string) *Exchange {
|
func New(key, secret string) *Exchange {
|
||||||
var client = binance.NewClient(key, secret)
|
var client = binance.NewClient(key, secret)
|
||||||
client.HTTPClient = &http.Client{Timeout: 15 * time.Second}
|
client.HTTPClient = &http.Client{Timeout: 15 * time.Second}
|
||||||
_, _ = client.NewSetServerTimeService().Do(context.Background())
|
|
||||||
|
|
||||||
var futuresClient = binance.NewFuturesClient(key, secret)
|
var futuresClient = binance.NewFuturesClient(key, secret)
|
||||||
futuresClient.HTTPClient = &http.Client{Timeout: 15 * time.Second}
|
futuresClient.HTTPClient = &http.Client{Timeout: 15 * time.Second}
|
||||||
_, _ = futuresClient.NewSetServerTimeService().Do(context.Background())
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
if len(key) > 0 && len(secret) > 0 {
|
||||||
_, err = client.NewSetServerTimeService().Do(context.Background())
|
_, err = client.NewSetServerTimeService().Do(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -73,6 +72,7 @@ func New(key, secret string) *Exchange {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &Exchange{
|
return &Exchange{
|
||||||
key: key,
|
key: key,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user