Package stats

This commit is contained in:
Adrian Gallagher
2017-03-29 07:44:56 +11:00
parent a9d9ee54f7
commit 659ac59bbb
17 changed files with 40 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -28,7 +29,7 @@ func (a *ANX) Run() {
return
}
log.Printf("ANX %s: Last %f High %f Low %f Volume %f\n", currency, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(a.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(a.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
}()
}
time.Sleep(time.Second * a.RESTPollingDelay)

View File

@@ -6,6 +6,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -54,7 +55,7 @@ func (b *Bitfinex) Run() {
return
}
log.Printf("Bitfinex %s Last %f High %f Low %f Volume %f\n", currency, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(b.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(b.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
}()
}
time.Sleep(time.Second * b.RESTPollingDelay)

View File

@@ -6,6 +6,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -34,7 +35,7 @@ func (b *Bitstamp) Run() {
return
}
log.Printf("Bitstamp %s: Last %f High %f Low %f Volume %f\n", currency, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(b.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(b.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
}()
}
time.Sleep(time.Second * b.RESTPollingDelay)

View File

@@ -6,6 +6,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -34,7 +35,7 @@ func (b *BTCC) Run() {
return
}
log.Printf("BTCC %s: Last %f High %f Low %f Volume %f\n", currency, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(b.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(b.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
}()
}
time.Sleep(time.Second * b.RESTPollingDelay)

View File

@@ -7,6 +7,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -39,7 +40,7 @@ func (b *BTCE) Run() {
x = common.StringToUpper(x[0:3] + x[4:])
log.Printf("BTC-e %s: Last %f High %f Low %f Volume %f\n", x, y.Last, y.High, y.Low, y.Vol_cur)
b.Ticker[x] = y
//AddExchangeInfo(b.GetName(), common.StringToUpper(x[0:3]), common.StringToUpper(x[4:]), y.Last, y.Vol_cur)
stats.AddExchangeInfo(b.GetName(), common.StringToUpper(x[0:3]), common.StringToUpper(x[4:]), y.Last, y.Vol_cur)
}
}()
time.Sleep(time.Second * b.RESTPollingDelay)

View File

@@ -6,6 +6,7 @@ import (
"github.com/thrasher-/gocryptotrader/currency"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -31,8 +32,8 @@ func (b *BTCMarkets) Run() {
BTCMarketsBestBidUSD, _ := currency.ConvertCurrency(ticker.Bid, "AUD", "USD")
BTCMarketsBestAskUSD, _ := currency.ConvertCurrency(ticker.Ask, "AUD", "USD")
log.Printf("BTC Markets %s: Last %f (%f) Bid %f (%f) Ask %f (%f)\n", curr, BTCMarketsLastUSD, ticker.Last, BTCMarketsBestBidUSD, ticker.Bid, BTCMarketsBestAskUSD, ticker.Ask)
//AddExchangeInfo(b.GetName(), currency[0:3], currency[3:], ticker.Last, 0)
//AddExchangeInfo(b.GetName(), currency[0:3], "USD", BTCMarketsLastUSD, 0)
stats.AddExchangeInfo(b.GetName(), curr[0:3], curr[3:], ticker.Last, 0)
stats.AddExchangeInfo(b.GetName(), curr[0:3], "USD", BTCMarketsLastUSD, 0)
}()
}
time.Sleep(time.Second * b.RESTPollingDelay)

View File

@@ -6,6 +6,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -61,7 +62,7 @@ func (g *GDAX) Run() {
return
}
log.Printf("GDAX %s: Last %f High %f Low %f Volume %f\n", currency, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(g.GetName(), currency[0:3], currency[4:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(g.GetName(), currency[0:3], currency[4:], ticker.Last, ticker.Volume)
}()
}
time.Sleep(time.Second * g.RESTPollingDelay)

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -49,7 +50,7 @@ func (g *Gemini) Run() {
return
}
log.Printf("Gemini %s Last %f Bid %f Ask %f Volume %f\n", currency, ticker.Last, ticker.Bid, ticker.Ask, ticker.Volume)
//AddExchangeInfo(g.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(g.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
}()
}
time.Sleep(time.Second * g.RESTPollingDelay)

View File

@@ -7,6 +7,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -38,8 +39,8 @@ func (h *HUOBI) Run() {
HuobiHighUSD, _ := currency.ConvertCurrency(ticker.High, "CNY", "USD")
HuobiLowUSD, _ := currency.ConvertCurrency(ticker.Low, "CNY", "USD")
log.Printf("Huobi %s: Last %f (%f) High %f (%f) Low %f (%f) Volume %f\n", curr, HuobiLastUSD, ticker.Last, HuobiHighUSD, ticker.High, HuobiLowUSD, ticker.Low, ticker.Volume)
// AddExchangeInfo(h.GetName(), common.StringToUpper(currency[0:3]), common.StringToUpper(currency[3:]), ticker.Last, ticker.Volume)
// AddExchangeInfo(h.GetName(), common.StringToUpper(currency[0:3]), "USD", HuobiLastUSD, ticker.Volume)
stats.AddExchangeInfo(h.GetName(), common.StringToUpper(curr[0:3]), common.StringToUpper(curr[3:]), ticker.Last, ticker.Volume)
stats.AddExchangeInfo(h.GetName(), common.StringToUpper(curr[0:3]), "USD", HuobiLastUSD, ticker.Volume)
}()
}
time.Sleep(time.Second * h.RESTPollingDelay)

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -27,7 +28,7 @@ func (i *ItBit) Run() {
return
}
log.Printf("ItBit %s: Last %f High %f Low %f Volume %f\n", currency, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(i.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(i.GetName(), currency[0:3], currency[3:], ticker.Last, ticker.Volume)
}()
}
time.Sleep(time.Second * i.RESTPollingDelay)

View File

@@ -6,6 +6,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -51,7 +52,7 @@ func (k *Kraken) Run() {
for _, x := range k.EnabledPairs {
ticker := k.Ticker[x]
log.Printf("Kraken %s Last %f High %f Low %f Volume %f\n", x, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(k.GetName(), x[0:3], x[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(k.GetName(), x[0:3], x[3:], ticker.Last, ticker.Volume)
}
}
time.Sleep(time.Second * k.RESTPollingDelay)

View File

@@ -7,6 +7,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -27,7 +28,7 @@ func (l *LakeBTC) Run() {
continue
}
log.Printf("LakeBTC BTC %s: Last %f High %f Low %f Volume %f\n", x[3:], ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(l.GetName(), x[0:3], x[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(l.GetName(), x[0:3], x[3:], ticker.Last, ticker.Volume)
}
time.Sleep(time.Second * l.RESTPollingDelay)
}

View File

@@ -7,6 +7,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -58,11 +59,11 @@ func (l *Liqui) Run() {
return
}
for x, y := range ticker {
//currencies := common.SplitStrings(x, "_")
currencies := common.SplitStrings(x, "_")
x = common.StringToUpper(x)
log.Printf("Liqui %s: Last %f High %f Low %f Volume %f\n", x, y.Last, y.High, y.Low, y.Vol_cur)
l.Ticker[x] = y
//AddExchangeInfo(l.GetName(), common.StringToUpper(currencies[0]), common.StringToUpper(currencies[1]), y.Last, y.Vol_cur)
stats.AddExchangeInfo(l.GetName(), common.StringToUpper(currencies[0]), common.StringToUpper(currencies[1]), y.Last, y.Vol_cur)
}
}()
time.Sleep(time.Second * l.RESTPollingDelay)

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -29,7 +30,7 @@ func (l *LocalBitcoins) Run() {
}
log.Printf("LocalBitcoins BTC %s: Last %f Volume %f\n", currency, ticker.Last, ticker.Volume)
//AddExchangeInfo(l.GetName(), x[0:3], x[3:], ticker.Last, ticker.Volume)
stats.AddExchangeInfo(l.GetName(), x[0:3], x[3:], ticker.Last, ticker.Volume)
}
time.Sleep(time.Second * l.RESTPollingDelay)
}

View File

@@ -7,6 +7,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/currency"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -38,7 +39,7 @@ func (o *OKCoin) Run() {
return
}
log.Printf("OKCoin Intl Futures %s (%s): Last %f High %f Low %f Volume %f\n", curr, futuresValue, ticker.Last, ticker.High, ticker.Low, ticker.Vol)
//AddExchangeInfo(o.GetName(), common.StringToUpper(currency[0:3]), common.StringToUpper(currency[4:]), ticker.Last, ticker.Vol)
stats.AddExchangeInfo(o.GetName(), common.StringToUpper(curr[0:3]), common.StringToUpper(curr[4:]), ticker.Last, ticker.Vol)
}()
}
go func() {
@@ -48,7 +49,7 @@ func (o *OKCoin) Run() {
return
}
log.Printf("OKCoin Intl Spot %s: Last %f High %f Low %f Volume %f\n", curr, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//AddExchangeInfo(o.GetName(), common.StringToUpper(currency[0:3]), common.StringToUpper(currency[4:]), ticker.Last, ticker.Volume)
stats.AddExchangeInfo(o.GetName(), common.StringToUpper(curr[0:3]), common.StringToUpper(curr[4:]), ticker.Last, ticker.Volume)
}()
} else {
go func() {
@@ -61,8 +62,8 @@ func (o *OKCoin) Run() {
tickerHighUSD, _ := currency.ConvertCurrency(ticker.High, "CNY", "USD")
tickerLowUSD, _ := currency.ConvertCurrency(ticker.Low, "CNY", "USD")
log.Printf("OKCoin China %s: Last %f (%f) High %f (%f) Low %f (%f) Volume %f\n", curr, tickerLastUSD, ticker.Last, tickerHighUSD, ticker.High, tickerLowUSD, ticker.Low, ticker.Volume)
//AddExchangeInfo(o.GetName(), common.StringToUpper(currency[0:3]), common.StringToUpper(currency[4:]), ticker.Last, ticker.Volume)
//AddExchangeInfo(o.GetName(), common.StringToUpper(currency[0:3]), "USD", tickerLastUSD, ticker.Volume)
stats.AddExchangeInfo(o.GetName(), common.StringToUpper(curr[0:3]), common.StringToUpper(curr[4:]), ticker.Last, ticker.Volume)
stats.AddExchangeInfo(o.GetName(), common.StringToUpper(curr[0:3]), "USD", tickerLastUSD, ticker.Volume)
}()
}
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/thrasher-/gocryptotrader/common"
"github.com/thrasher-/gocryptotrader/exchanges"
"github.com/thrasher-/gocryptotrader/exchanges/stats"
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
)
@@ -34,8 +35,8 @@ func (p *Poloniex) Run() {
return
}
log.Printf("Poloniex %s Last %f High %f Low %f Volume %f\n", currency, ticker.Last, ticker.High, ticker.Low, ticker.Volume)
//currencyPair := common.SplitStrings(currency, "_")
//AddExchangeInfo(p.GetName(), currencyPair[0], currencyPair[1], ticker.Last, ticker.Volume)
currencyPair := common.SplitStrings(currency, "_")
stats.AddExchangeInfo(p.GetName(), currencyPair[0], currencyPair[1], ticker.Last, ticker.Volume)
}()
}
time.Sleep(time.Second * p.RESTPollingDelay)

View File

@@ -1,4 +1,4 @@
package main
package stats
import (
"sort"