Skip to content

Commit

Permalink
Various improvements, update config
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasher- committed Feb 5, 2018
1 parent 9e71a8f commit ce3d295
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 41 deletions.
11 changes: 6 additions & 5 deletions config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{
"Address": "3Nxwenay9Z8Lc9JBiywExpnEFiLp6Afp8v",
"CoinType": "BTC",
"Balance": 83348.33585928,
"Balance": 90348.33585928,
"Description": ""
},
{
Expand Down Expand Up @@ -308,12 +308,13 @@
"AuthenticatedAPISupport": false,
"APIKey": "Key",
"APISecret": "Secret",
"AvailablePairs": "BTCUSD,ETHBTC,ETHUSD",
"EnabledPairs": "BTCUSD",
"AvailablePairs": "BCN-BTC,BTC-USD,DASH-BTC,DOGE-BTC,DOGE-USD,DSH-BTC,EMC-BTC,ETH-BTC,FCN-BTC,LSK-BTC,LTC-BTC,LTC-USD,NXT-BTC,QCN-BTC,SBD-BTC,SC-BTC,STEEM-BTC,XDN-BTC,XEM-BTC,XMR-BTC,ARDR-BTC,ZEC-BTC,WAVES-BTC,MAID-BTC,AMP-BTC,BUS-BTC,DGD-BTC,ICN-BTC,SNGLS-BTC,1ST-BTC,TRST-BTC,TIME-BTC,GNO-BTC,REP-BTC,XMR-USD,DASH-USD,ETH-USD,NXT-USD,ZRC-BTC,BOS-BTC,DCT-BTC,ANT-BTC,AEON-BTC,GUP-BTC,PLU-BTC,LUN-BTC,TAAS-BTC,NXC-BTC,EDG-BTC,RLC-BTC,SWT-BTC,TKN-BTC,WINGS-BTC,XAUR-BTC,AE-BTC,PTOY-BTC,ZEC-USD,XEM-USD,BCN-USD,XDN-USD,MAID-USD,ETC-BTC,ETC-USD,CFI-BTC,PLBT-BTC,BNT-BTC,XDNCO-BTC,FYN-ETH,SNM-ETH,SNT-ETH,CVC-USD,PAY-ETH,OAX-ETH,OMG-ETH,BQX-ETH,XTZ-BTC,DICE-BTC,CFI-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-ETH",
"EnabledPairs": "BTC-USD",
"BaseCurrencies": "USD",
"AssetTypes": "SPOT",
"ConfigCurrencyPairFormat": {
"Uppercase": true
"Uppercase": true,
"Delimiter": "-"
},
"RequestCurrencyPairFormat": {
"Uppercase": true
Expand All @@ -329,7 +330,7 @@
"AuthenticatedAPISupport": false,
"APIKey": "Key",
"APISecret": "Secret",
"AvailablePairs": "OMG-USDT,LINK-BTC,NAS-ETH,EOS-ETH,SWFTC-BTC,XEM-USDT,ZEC-USDT,DASH-BTC,PAY-BTC,EVX-BTC,MDS-ETH,TNT-BTC,QASH-ETH,SMT-ETH,TRX-ETH,THETA-USDT,LUN-ETH,RUFF-ETH,BCH-BTC,ELA-ETH,IOST-ETH,TNB-BTC,GNX-ETH,THETA-BTC,SNT-USDT,DAT-BTC,SOC-ETH,EOS-USDT,CHAT-ETH,MANA-BTC,SMT-USDT,XRP-BTC,LTC-USDT,QTUM-USDT,LET-BTC,BCD-BTC,SNT-BTC,CVC-USDT,ELF-ETH,GNT-ETH,UTK-BTC,SBTC-BTC,NEO-USDT,MCO-BTC,OST-ETH,HT-BTC,RCN-BTC,BT2-BTC,QUN-BTC,HSR-ETH,TOPC-ETH,SALT-ETH,AIDOC-ETH,WAX-BTC,CVC-ETH,DTA-ETH,BTC-USDT,MEE-ETH,POWR-ETH,GAS-ETH,ADX-ETH,NEO-BTC,SALT-BTC,LET-USDT,BTM-BTC,EKO-ETH,BAT-ETH,EKO-BTC,SRN-BTC,APPC-BTC,OCN-ETH,CMT-BTC,VEN-ETH,QTUM-ETH,REQ-BTC,BIFI-BTC,BTM-ETH,ICX-BTC,OCN-BTC,ZEC-BTC,ACT-BTC,DGD-ETH,DAT-ETH,ETC-USDT,OST-BTC,IOST-USDT,STK-ETH,MCO-ETH,HT-ETH,STORJ-BTC,HSR-BTC,QUN-ETH,SOC-BTC,ELF-BTC,CMT-ETH,VEN-BTC,GNT-BTC,DBC-BTC,STORJ-USDT,WAX-ETH,TRX-BTC,POWR-BTC,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MG-ETH,RCN-ETH,UTK-ETH,TOPC-BTC,MTL-BTC,GNT-USDT,APPC-ETH,PROPY-BTC,WICC-BTC,RDN-ETH,ELF-USDT,YEE-ETH",
"EnabledPairs": "BTC-USDT",
"BaseCurrencies": "USD",
"AssetTypes": "SPOT",
Expand Down
74 changes: 57 additions & 17 deletions exchanges/hitbtc/hitbtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (p *HitBTC) SetDefaults() {
p.RESTPollingDelay = 10
p.RequestCurrencyPairFormat.Delimiter = ""
p.RequestCurrencyPairFormat.Uppercase = true
p.ConfigCurrencyPairFormat.Delimiter = ""
p.ConfigCurrencyPairFormat.Delimiter = "-"
p.ConfigCurrencyPairFormat.Uppercase = true
p.AssetTypes = []string{ticker.Spot}
}
Expand All @@ -73,16 +73,9 @@ func (p *HitBTC) Setup(exch config.ExchangeConfig) {
p.Verbose = exch.Verbose
p.Websocket = exch.Websocket
p.BaseCurrencies = common.SplitStrings(exch.BaseCurrencies, ",")
availiableSymbols, err := p.GetSymbols("")

if err != nil {
log.Println(err)
p.AvailablePairs = common.SplitStrings(exch.AvailablePairs, ",")
} else {
p.AvailablePairs = availiableSymbols
}
p.AvailablePairs = common.SplitStrings(exch.AvailablePairs, ",")
p.EnabledPairs = common.SplitStrings(exch.EnabledPairs, ",")
err = p.SetCurrencyPairFormat()
err := p.SetCurrencyPairFormat()
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -136,29 +129,76 @@ func (p *HitBTC) GetSymbols(symbol string) ([]string, error) {
return ret, err
}

// GetSymbolsDetailed is the same as above but returns an array of symbols with
// all ther details.
func (p *HitBTC) GetSymbolsDetailed() ([]Symbol, error) {
resp := []Symbol{}
path := fmt.Sprintf("%s/%s", APIURL, APIv2Symbol)
return resp, common.SendHTTPGetRequest(path, true, p.Verbose, &resp)
}

// GetTicker
// Return ticker information
func (p *HitBTC) GetTicker(symbol string) map[string]Ticker {
func (p *HitBTC) GetTicker(symbol string) (map[string]Ticker, error) {

resp1 := []Ticker{}
resp2 := Ticker{}
ret := make(map[string]Ticker)
resp1 := []TickerResponse{}
resp2 := TickerResponse{}
ret := make(map[string]TickerResponse)
result := make(map[string]Ticker)
path := fmt.Sprintf("%s/%s/%s", APIURL, APIv2Ticker, symbol)
var err error

if symbol == "" {
common.SendHTTPGetRequest(path, true, p.Verbose, &resp1)
err = common.SendHTTPGetRequest(path, true, false, &resp1)
if err != nil {
return nil, err
}

for _, item := range resp1 {
if item.Symbol != "" {
ret[item.Symbol] = item
}
}
} else {
common.SendHTTPGetRequest(path, true, p.Verbose, &resp2)
err = common.SendHTTPGetRequest(path, true, false, &resp2)
ret[resp2.Symbol] = resp2
}

return ret
if err == nil {
for x, y := range ret {
tick := Ticker{}

ask, _ := strconv.ParseFloat(y.Ask, 64)
tick.Ask = ask

bid, _ := strconv.ParseFloat(y.Bid, 64)
tick.Bid = bid

high, _ := strconv.ParseFloat(y.High, 64)
tick.High = high

last, _ := strconv.ParseFloat(y.Last, 64)
tick.Last = last

low, _ := strconv.ParseFloat(y.Low, 64)
tick.Low = low

open, _ := strconv.ParseFloat(y.Open, 64)
tick.Open = open

vol, _ := strconv.ParseFloat(y.Volume, 64)
tick.Volume = vol

volQuote, _ := strconv.ParseFloat(y.VolumeQuote, 64)
tick.VolumeQuote = volQuote

tick.Symbol = y.Symbol
tick.Timestamp = y.Timestamp
result[x] = tick
}
}

return result, err
}

// GetTrades returns trades from hitbtc
Expand Down
31 changes: 22 additions & 9 deletions exchanges/hitbtc/hitbtc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,29 @@ package hitbtc
import "time"

type Ticker struct {
Last float64 `json:"last,string"` // Last trade price
Ask float64 `json:"ask,string"` // Best ask price
Bid float64 `json:"bid,string"` // Best bid price
Timestamp time.Time `json:"timestamp,string"` // Last update or refresh ticker timestamp
Volume float64 `json:"volume,string"` // Total trading amount within 24 hours in base currency
VolumeQuote float64 `json:"volumeQuote,string"` // Total trading amount within 24 hours in quote currency
Last float64
Ask float64
Bid float64
Timestamp time.Time
Volume float64
VolumeQuote float64
Symbol string
High float64
Low float64
Open float64
}

type TickerResponse struct {
Last string `json:"last"` // Last trade price
Ask string `json:"ask"` // Best ask price
Bid string `json:"bid"` // Best bid price
Timestamp time.Time `json:"timestamp,string"` // Last update or refresh ticker timestamp
Volume string `json:"volume"` // Total trading amount within 24 hours in base currency
VolumeQuote string `json:"volumeQuote"` // Total trading amount within 24 hours in quote currency
Symbol string `json:"symbol"`
High float64 `json:"high,string"` // Highest trade price within 24 hours
Low float64 `json:"low,string"` // Lowest trade price within 24 hours
Open float64 `json:"open,string"` // Last trade price 24 hours ago
High string `json:"high"` // Highest trade price within 24 hours
Low string `json:"low"` // Lowest trade price within 24 hours
Open string `json:"open"` // Last trade price 24 hours ago
}

type Symbol struct {
Expand Down
35 changes: 33 additions & 2 deletions exchanges/hitbtc/hitbtc_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,42 @@ func (p *HitBTC) Run() {
if p.Websocket {
go p.WebsocketClient()
}

exchangeProducts, err := p.GetSymbolsDetailed()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", p.GetName())
} else {
forceUpgrade := false
if !common.DataContains(p.EnabledPairs, "-") || !common.DataContains(p.AvailablePairs, "-") {
forceUpgrade = true
}
var currencies []string
for x := range exchangeProducts {
currencies = append(currencies, exchangeProducts[x].BaseCurrency+"-"+exchangeProducts[x].QuoteCurrency)
}

if forceUpgrade {
enabledPairs := []string{"BTC-USD"}
log.Println("WARNING: Available pairs for HitBTC reset due to config upgrade, please enable the ones you would like again.")

err = p.UpdateEnabledCurrencies(enabledPairs, true)
if err != nil {
log.Printf("%s Failed to update enabled currencies.\n", p.GetName())
}
}
err = p.UpdateAvailableCurrencies(currencies, forceUpgrade)
if err != nil {
log.Printf("%s Failed to update available currencies.\n", p.GetName())
}
}
}

// UpdateTicker updates and returns the ticker for a currency pair
func (p *HitBTC) UpdateTicker(currencyPair pair.CurrencyPair, assetType string) (ticker.Price, error) {
tick := p.GetTicker("")
tick, err := p.GetTicker("")
if err != nil {
return ticker.Price{}, err
}

for _, x := range p.GetEnabledCurrencies() {
var tp ticker.Price
Expand Down Expand Up @@ -59,7 +90,7 @@ func (p *HitBTC) GetTickerPrice(currencyPair pair.CurrencyPair, assetType string
// GetOrderbookEx returns orderbook base on the currency pair
func (p *HitBTC) GetOrderbookEx(currencyPair pair.CurrencyPair, assetType string) (orderbook.Base, error) {
ob, err := orderbook.GetOrderbook(p.GetName(), currencyPair, assetType)
if err == nil {
if err != nil {
return p.UpdateOrderbook(currencyPair, assetType)
}
return ob, nil
Expand Down
18 changes: 18 additions & 0 deletions exchanges/okex/okex_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func (o *OKEX) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price
var tickerPrice ticker.Price

if assetType != ticker.Spot {
if p.SecondCurrency.String() == common.StringToLower("USDT") {
p.SecondCurrency = "usd"
currency = exchange.FormatExchangeCurrency(o.Name, p).String()
}
tick, err := o.GetContractPrice(currency, assetType)
if err != nil {
return tickerPrice, err
Expand All @@ -45,6 +49,11 @@ func (o *OKEX) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price
tickerPrice.High = tick.Ticker.High
ticker.ProcessTicker(o.GetName(), p, tickerPrice, assetType)
} else {
if p.SecondCurrency.String() == common.StringToLower("USD") {
p.SecondCurrency = "usdt"
currency = exchange.FormatExchangeCurrency(o.Name, p).String()
}

tick, err := o.GetSpotTicker(currency)
if err != nil {
return tickerPrice, err
Expand Down Expand Up @@ -86,6 +95,10 @@ func (o *OKEX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook
currency := exchange.FormatExchangeCurrency(o.Name, p).String()

if assetType != ticker.Spot {
if p.SecondCurrency.String() == common.StringToLower("USDT") {
p.SecondCurrency = "usd"
currency = exchange.FormatExchangeCurrency(o.Name, p).String()
}
orderbookNew, err := o.GetContractMarketDepth(currency, assetType)
if err != nil {
return orderBook, err
Expand All @@ -102,6 +115,11 @@ func (o *OKEX) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook
}

} else {
if p.SecondCurrency.String() == common.StringToLower("USD") {
p.SecondCurrency = "usdt"
currency = exchange.FormatExchangeCurrency(o.Name, p).String()
}

orderbookNew, err := o.GetSpotMarketDepth(currency, "200")
if err != nil {
return orderBook, err
Expand Down
2 changes: 1 addition & 1 deletion exchanges/yobit/yobit_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (y *Yobit) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Pr
// GetOrderbookEx returns the orderbook for a currency pair
func (y *Yobit) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error) {
ob, err := orderbook.GetOrderbook(y.GetName(), p, assetType)
if err == nil {
if err != nil {
return y.UpdateOrderbook(p, assetType)
}
return ob, nil
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func main() {
if len(bot.exchanges) == 0 {
log.Fatalf("No exchanges were able to be loaded. Exiting")
}
// TODO: Fix hack, allow 2 seconds to update exchange settings
time.Sleep(time.Second * 2)
// TODO: Fix hack, allow 5 seconds to update exchange settings
time.Sleep(time.Second * 5)

if bot.config.CurrencyExchangeProvider == "yahoo" {
currency.SetProvider(true)
Expand Down
Loading

0 comments on commit ce3d295

Please sign in to comment.