mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Set API keys from config file.
This commit is contained in:
@@ -99,6 +99,11 @@ func (b *Bitfinex) IsEnabled() (bool) {
|
||||
return b.Enabled
|
||||
}
|
||||
|
||||
func (b *Bitfinex) SetAPIKeys(apiKey, apiSecret string) {
|
||||
b.APIKey = apiKey
|
||||
b.APISecret = apiSecret
|
||||
}
|
||||
|
||||
func (b *Bitfinex) SendAuthenticatedHTTPRequest(path string, params map[string]interface{}) (err error) {
|
||||
request := make(map[string]interface{})
|
||||
request["request"] = "/v1/" + path
|
||||
|
||||
@@ -88,6 +88,12 @@ func (b *Bitstamp) IsEnabled() (bool) {
|
||||
return b.Enabled
|
||||
}
|
||||
|
||||
func (b *Bitstamp) SetAPIKeys(clientID, apiKey, apiSecret string) {
|
||||
b.ClientID = clientID
|
||||
b.APIKey = apiKey
|
||||
b.APISecret = apiSecret
|
||||
}
|
||||
|
||||
func (b *Bitstamp) GetTicker() (BitstampTicker) {
|
||||
err := SendHTTPRequest(BITSTAMP_API_URL + BITSTAMP_API_TICKER, true, &b.Ticker)
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ func (b *BTCChina) IsEnabled() (bool) {
|
||||
return b.Enabled
|
||||
}
|
||||
|
||||
func (b *BTCChina) SetAPIKeys(apiKey, apiSecret string) {
|
||||
b.APIKey = apiKey
|
||||
b.APISecret = apiSecret
|
||||
}
|
||||
|
||||
func (b *BTCChina) GetTicker(symbol string) (BTCChinaTicker) {
|
||||
type Response struct {
|
||||
Ticker BTCChinaTicker
|
||||
|
||||
@@ -60,6 +60,11 @@ func (b *BTCE) IsEnabled() (bool) {
|
||||
return b.Enabled
|
||||
}
|
||||
|
||||
func (b *BTCE) SetAPIKeys(apiKey, apiSecret string) {
|
||||
b.APIKey = apiKey
|
||||
b.APISecret = apiSecret
|
||||
}
|
||||
|
||||
func (b *BTCE) GetTicker(symbol string) (BTCeTicker) {
|
||||
type Response struct {
|
||||
Ticker BTCeTicker
|
||||
|
||||
@@ -50,6 +50,11 @@ func (b *BTCMarkets) IsEnabled() (bool) {
|
||||
return b.Enabled
|
||||
}
|
||||
|
||||
func (b *BTCMarkets) SetAPIKeys(apiKey, apiSecret string) {
|
||||
b.APIKey = apiKey
|
||||
b.APISecret = apiSecret
|
||||
}
|
||||
|
||||
func (b *BTCMarkets) GetTicker(symbol string) (BTCMarketsTicker) {
|
||||
ticker := BTCMarketsTicker{}
|
||||
path := fmt.Sprintf("/market/%s/AUD/tick", symbol)
|
||||
|
||||
@@ -14,6 +14,7 @@ type Exchanges struct {
|
||||
Enabled bool
|
||||
APIKey string
|
||||
APISecret string
|
||||
ClientID string
|
||||
Pairs string
|
||||
BaseCurrencies string
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
{
|
||||
"Name": "Bitstamp",
|
||||
"Pairs": "BTCUSD",
|
||||
"ClientID": "ClientID",
|
||||
"APIKey": "Key",
|
||||
"APISecret": "Secret",
|
||||
"BaseCurrencies": "USD",
|
||||
|
||||
@@ -54,6 +54,11 @@ func (h *HUOBI) IsEnabled() (bool) {
|
||||
return h.Enabled
|
||||
}
|
||||
|
||||
func (h *HUOBI) SetAPIKeys(apiKey, apiSecret string) {
|
||||
h.AccessKey = apiKey
|
||||
h.SecretKey = apiSecret
|
||||
}
|
||||
|
||||
func (h *HUOBI) GetTicker(symbol string) (HuobiTicker) {
|
||||
resp := HuobiTickerResponse{}
|
||||
path := fmt.Sprintf("http://market.huobi.com/staticmarket/ticker_%s_json.js", symbol)
|
||||
|
||||
@@ -63,6 +63,11 @@ func (i *ItBit) IsEnabled() (bool) {
|
||||
return i.Enabled
|
||||
}
|
||||
|
||||
func (i *ItBit) SetAPIKeys(apiKey, apiSecret string) {
|
||||
i.ClientKey = apiKey
|
||||
i.APISecret = apiSecret
|
||||
}
|
||||
|
||||
func (i *ItBit) GetTicker(currency string) (ItBitTicker) {
|
||||
path := ITBIT_API_URL + "/markets/" + currency + "/ticker"
|
||||
var itbitTicker ItBitTicker
|
||||
|
||||
@@ -65,6 +65,11 @@ func (l *LakeBTC) IsEnabled() (bool) {
|
||||
return l.Enabled
|
||||
}
|
||||
|
||||
func (l *LakeBTC) SetAPIKeys(apiKey, apiSecret string) {
|
||||
l.Email = apiKey
|
||||
l.APISecret = apiSecret
|
||||
}
|
||||
|
||||
func (l *LakeBTC) GetTicker() (LakeBTCTickerResponse) {
|
||||
response := LakeBTCTickerResponse{}
|
||||
err := SendHTTPRequest(LAKEBTC_API_URL + LAKEBTC_TICKER, true, &response)
|
||||
|
||||
10
main.go
10
main.go
@@ -68,6 +68,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.btcchina.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.bitstamp.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -75,6 +76,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.bitstamp.SetAPIKeys(exch.ClientID, exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.bitfinex.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -82,6 +84,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.bitfinex.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.btce.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -89,6 +92,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.btce.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.btcmarkets.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -96,6 +100,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.btcmarkets.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.okcoinChina.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -103,6 +108,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.okcoinChina.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.okcoinIntl.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -110,6 +116,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.okcoinIntl.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.itbit.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -117,6 +124,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.itbit.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.lakebtc.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -124,6 +132,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.lakebtc.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
} else if exchange.huobi.GetName() == exch.Name {
|
||||
if !exch.Enabled {
|
||||
@@ -131,6 +140,7 @@ func main() {
|
||||
log.Printf("%s disabled.\n", exch.Name)
|
||||
} else {
|
||||
log.Printf("%s enabled.\n", exch.Name)
|
||||
exchange.huobi.SetAPIKeys(exch.APIKey, exch.APISecret)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,11 @@ func (o *OKCoin) SetURL(url string) {
|
||||
o.APIUrl = url
|
||||
}
|
||||
|
||||
func (o *OKCoin) SetAPIKeys(apiKey, apiSecret string) {
|
||||
o.PartnerID = apiKey
|
||||
o.SecretKey = apiSecret
|
||||
}
|
||||
|
||||
func (o *OKCoin) GetTicker(symbol string) (OKCoinTicker) {
|
||||
resp := OKCoinTickerResponse{}
|
||||
path := fmt.Sprintf("ticker.do?symbol=%s&ok=1", symbol)
|
||||
|
||||
Reference in New Issue
Block a user