Skip to content

Commit

Permalink
Moved ticker fetching from main into the relative exchange.
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasher- committed Mar 18, 2015
1 parent 8fdcb81 commit b23070d
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 215 deletions.
18 changes: 18 additions & 0 deletions bitfinexhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ func (b *Bitfinex) SetAPIKeys(apiKey, apiSecret string) {
b.APISecret = apiSecret
}

func (b *Bitfinex) Run() {
b.GetAccountFeeInfo()
b.GetAccountBalance()

for b.Enabled {
go func() {
BitfinexLTC := b.GetTicker("ltcusd")
log.Printf("Bitfinex LTC: Last %f High %f Low %f Volume %f\n", BitfinexLTC.Last, BitfinexLTC.High, BitfinexLTC.Low, BitfinexLTC.Volume)
}()

go func() {
BitfinexBTC := b.GetTicker("btcusd")
log.Printf("Bitfinex BTC: Last %f High %f Low %f Volume %f\n", BitfinexBTC.Last, BitfinexBTC.High, BitfinexBTC.Low, BitfinexBTC.Volume)
}()
time.Sleep(time.Second * 10)
}
}

func (b *Bitfinex) GetFee(maker bool, symbol string) (float64, error) {
for _, i := range b.Fees {
if symbol == i.Currency {
Expand Down
12 changes: 12 additions & 0 deletions bitstamphttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ func (b *Bitstamp) SetAPIKeys(clientID, apiKey, apiSecret string) {
b.APISecret = apiSecret
}

func (b *Bitstamp) Run() {
b.GetBalance()

for b.Enabled {
go func() {
BitstampBTC := b.GetTicker()
log.Printf("Bitstamp BTC: Last %f High %f Low %f Volume %f\n", BitstampBTC.Last, BitstampBTC.High, BitstampBTC.Low, BitstampBTC.Volume)
}()
time.Sleep(time.Second * 10)
}
}

func (b *Bitstamp) GetTicker() (BitstampTicker) {
err := SendHTTPGetRequest(BITSTAMP_API_URL + BITSTAMP_API_TICKER, true, &b.Ticker)

Expand Down
21 changes: 21 additions & 0 deletions btcchinahttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,27 @@ func (b *BTCChina) GetFee() (float64) {
return b.Fee
}

func (b *BTCChina) Run() {
for b.Enabled {
go func() {
BTCChinaBTC := b.GetTicker("btccny")
BTCChinaBTCLastUSD, _ := ConvertCurrency(BTCChinaBTC.Last, "CNY", "USD")
BTCChinaBTCHighUSD, _ := ConvertCurrency(BTCChinaBTC.High, "CNY", "USD")
BTCChinaBTCLowUSD, _ := ConvertCurrency(BTCChinaBTC.Low, "CNY", "USD")
log.Printf("BTCChina BTC: Last %f (%f) High %f (%f) Low %f (%f) Volume %f\n", BTCChinaBTCLastUSD, BTCChinaBTC.Last, BTCChinaBTCHighUSD, BTCChinaBTC.High, BTCChinaBTCLowUSD, BTCChinaBTC.Low, BTCChinaBTC.Vol)
}()

go func() {
BTCChinaLTC := b.GetTicker("ltccny")
BTCChinaLTCLastUSD, _ := ConvertCurrency(BTCChinaLTC.Last, "CNY", "USD")
BTCChinaLTCHighUSD, _ := ConvertCurrency(BTCChinaLTC.High, "CNY", "USD")
BTCChinaLTCLowUSD, _ := ConvertCurrency(BTCChinaLTC.Low, "CNY", "USD")
log.Printf("BTCChina LTC: Last %f (%f) High %f (%f) Low %f (%f) Volume %f\n", BTCChinaLTCLastUSD, BTCChinaLTC.Last, BTCChinaLTCHighUSD, BTCChinaLTC.High, BTCChinaLTCLowUSD, BTCChinaLTC.Low, BTCChinaLTC.Vol)
}()
time.Sleep(time.Second * 10)
}
}

func (b *BTCChina) GetTicker(symbol string) (BTCChinaTicker) {
type Response struct {
Ticker BTCChinaTicker
Expand Down
15 changes: 15 additions & 0 deletions btcehttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ func (b *BTCE) GetFee() (float64) {
return b.Fee
}

func (b *BTCE) Run() {
for b.Enabled {
go func() {
BTCeBTC := b.GetTicker("btc_usd")
log.Printf("BTC-e BTC: Last %f High %f Low %f Volume %f\n", BTCeBTC.Last, BTCeBTC.High, BTCeBTC.Low, BTCeBTC.Vol_cur)
}()

go func() {
BTCeLTC := b.GetTicker("ltc_usd")
log.Printf("BTC-e LTC: Last %f High %f Low %f Volume %f\n", BTCeLTC.Last, BTCeLTC.High, BTCeLTC.Low, BTCeLTC.Vol_cur)
}()
time.Sleep(time.Second * 10)
}
}

func (b *BTCE) GetInfo() {
req := fmt.Sprintf("%s/%s/%s/", BTCE_API_PUBLIC_URL, BTCE_API_PUBLIC_VERSION, BTCE_INFO)
err := SendHTTPGetRequest(req, true, nil)
Expand Down
21 changes: 21 additions & 0 deletions btcmarkets.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ func (b *BTCMarkets) GetFee() (float64) {
return b.Fee
}

func (b *BTCMarkets) Run() {
for b.Enabled {
go func() {
BTCMarketsBTC := b.GetTicker("BTC")
BTCMarketsBTCLastUSD, _ := ConvertCurrency(BTCMarketsBTC.LastPrice, "AUD", "USD")
BTCMarketsBTCBestBidUSD, _ := ConvertCurrency(BTCMarketsBTC.BestBID, "AUD", "USD")
BTCMarketsBTCBestAskUSD, _ := ConvertCurrency(BTCMarketsBTC.BestAsk, "AUD", "USD")
log.Printf("BTC Markets BTC: Last %f (%f) Bid %f (%f) Ask %f (%f)\n", BTCMarketsBTCLastUSD, BTCMarketsBTC.LastPrice, BTCMarketsBTCBestBidUSD, BTCMarketsBTC.BestBID, BTCMarketsBTCBestAskUSD, BTCMarketsBTC.BestAsk)
}()

go func() {
BTCMarketsLTC := b.GetTicker("LTC")
BTCMarketsLTCLastUSD, _ := ConvertCurrency(BTCMarketsLTC.LastPrice, "AUD", "USD")
BTCMarketsLTCBestBidUSD, _ := ConvertCurrency(BTCMarketsLTC.BestBID, "AUD", "USD")
BTCMarketsLTCBestAskUSD, _ := ConvertCurrency(BTCMarketsLTC.BestAsk, "AUD", "USD")
log.Printf("BTC Markets LTC: Last %f (%f) Bid %f (%f) Ask %f (%f)", BTCMarketsLTCLastUSD, BTCMarketsLTC.LastPrice, BTCMarketsLTCBestBidUSD, BTCMarketsLTC.BestBID, BTCMarketsLTCBestAskUSD, BTCMarketsLTC.BestAsk)
}()
time.Sleep(time.Second * 10)
}
}

func (b *BTCMarkets) GetTicker(symbol string) (BTCMarketsTicker) {
ticker := BTCMarketsTicker{}
path := fmt.Sprintf("/market/%s/AUD/tick", symbol)
Expand Down
12 changes: 12 additions & 0 deletions coinbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"log"
"time"
"fmt"
"strconv"
"net/url"
Expand Down Expand Up @@ -108,6 +109,17 @@ func (c *Coinbase) GetFee(maker bool) (float64) {
}
}

func (c *Coinbase) Run() {
for c.Enabled {
go func() {
CoinbaseStats := c.GetStats("BTC-USD")
CoinbaseTicker := c.GetTicker("BTC-USD")
log.Printf("Coinbase BTC: Last %f High %f Low %f Volume %f\n", CoinbaseTicker.Price, CoinbaseStats.High, CoinbaseStats.Low, CoinbaseStats.Volume)
}()
time.Sleep(time.Second * 10)
}
}

func (c *Coinbase) SetAPIKeys(password, apiKey, apiSecret string) {
c.Password = password
c.APIKey = apiKey
Expand Down
21 changes: 21 additions & 0 deletions huobihttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ func (h *HUOBI) GetFee() (float64) {
return h.Fee
}

func (h *HUOBI) Run() {
for h.Enabled {
go func() {
HuobiBTC := h.GetTicker("btc")
HuobiBTCLastUSD, _ := ConvertCurrency(HuobiBTC.Last, "CNY", "USD")
HuobiBTCHighUSD, _ := ConvertCurrency(HuobiBTC.High, "CNY", "USD")
HuobiBTCLowUSD, _ := ConvertCurrency(HuobiBTC.Low, "CNY", "USD")
log.Printf("Huobi BTC: Last %f (%f) High %f (%f) Low %f (%f) Volume %f\n", HuobiBTCLastUSD, HuobiBTC.Last, HuobiBTCHighUSD, HuobiBTC.High, HuobiBTCLowUSD, HuobiBTC.Low, HuobiBTC.Vol)
}()

go func() {
HuobiLTC := h.GetTicker("ltc")
HuobiLTCLastUSD, _ := ConvertCurrency(HuobiLTC.Last, "CNY", "USD")
HuobiLTCHighUSD, _ := ConvertCurrency(HuobiLTC.High, "CNY", "USD")
HuobiLTCLowUSD, _ := ConvertCurrency(HuobiLTC.Low, "CNY", "USD")
log.Printf("Huobi LTC: Last %f (%f) High %f (%f) Low %f (%f) Volume %f\n", HuobiLTCLastUSD, HuobiLTC.Last, HuobiLTCHighUSD, HuobiLTC.High, HuobiLTCLowUSD, HuobiLTC.Low, HuobiLTC.Vol)
}()
time.Sleep(time.Second * 10)
}
}

func (h *HUOBI) GetTicker(symbol string) (HuobiTicker) {
resp := HuobiTickerResponse{}
path := fmt.Sprintf("http://market.huobi.com/staticmarket/ticker_%s_json.js", symbol)
Expand Down
10 changes: 10 additions & 0 deletions itbithttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ func (i *ItBit) GetFee(maker bool) (float64) {
}
}

func (i *ItBit) Run() {
for i.Enabled {
go func() {
ItbitBTC := i.GetTicker("XBTUSD")
log.Printf("ItBit BTC: Last %f High %f Low %f Volume %f\n", ItbitBTC.LastPrice, ItbitBTC.High24h, ItbitBTC.Low24h, ItbitBTC.Volume24h)
}()
time.Sleep(time.Second * 10)
}
}

func (i *ItBit) GetTicker(currency string) (ItBitTicker) {
path := ITBIT_API_URL + "/markets/" + currency + "/ticker"
var itbitTicker ItBitTicker
Expand Down
14 changes: 14 additions & 0 deletions kraken.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ func (k *Kraken) GetFee(cryptoTrade bool) (float64) {
}
}

func (k *Kraken) Run() {
for k.Enabled {
go func() {
KrakenBTC := k.GetTicker("XBTUSD")
log.Printf("Kraken BTC: %v\n", KrakenBTC)
}()
go func() {
KrakenLTC := k.GetTicker("LTCUSD")
log.Printf("Kraken LTC: %v\n", KrakenLTC)
}()
time.Sleep(time.Second * 10)
}
}

func (k *Kraken) GetServerTime() {
result, err := k.SendKrakenRequest(KRAKEN_SERVER_TIME)

Expand Down
10 changes: 10 additions & 0 deletions lakebtchttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ func (l *LakeBTC) GetFee(maker bool) (float64) {
}
}

func (l *LakeBTC) Run() {
for l.Enabled {
go func() {
LakeBTCTickerResponse := l.GetTicker()
log.Printf("LakeBTC USD: Last %f (%f) High %f (%f) Low %f (%f) Volume US %f (CNY %f)\n", LakeBTCTickerResponse.USD.Last, LakeBTCTickerResponse.CNY.Last, LakeBTCTickerResponse.USD.High, LakeBTCTickerResponse.CNY.High, LakeBTCTickerResponse.USD.Low, LakeBTCTickerResponse.CNY.Low, LakeBTCTickerResponse.USD.Volume, LakeBTCTickerResponse.CNY.Volume)
}()
time.Sleep(time.Second * 10)
}
}

func (l *LakeBTC) GetTicker() (LakeBTCTickerResponse) {
response := LakeBTCTickerResponse{}
err := SendHTTPGetRequest(LAKEBTC_API_URL + LAKEBTC_TICKER, true, &response)
Expand Down
Loading

0 comments on commit b23070d

Please sign in to comment.