Files
gocryptotrader/main.go
2014-11-22 20:20:11 +11:00

99 lines
3.3 KiB
Go

package main
import (
"log"
"time"
"os"
"os/exec"
)
type Exchange struct {
btcchina BTCChina
bitstamp Bitstamp
bitfinex Bitfinex
btce BTCE
okcoinChina OKCoin
okcoinIntl OKCoin
huobi HUOBI
}
func main() {
log.Println("Bot started")
exchange := Exchange{}
exchange.okcoinChina.SetURL(OKCOIN_API_URL_CHINA)
exchange.okcoinIntl.SetURL(OKCOIN_API_URL)
//temp until proper asynchronous method of getting pricing/order books is coded
for {
go func() {
BTCChinaBTC := exchange.btcchina.GetTicker("btccny")
log.Printf("BTCChina BTC: Last %s High %s Low %s Volume %s\n", BTCChinaBTC.Last, BTCChinaBTC.High, BTCChinaBTC.Low, BTCChinaBTC.Vol)
}()
go func() {
HuobiBTC := exchange.huobi.GetTicker("btc")
log.Printf("Huobi BTC: Last %s High %s Low %s Volume %f\n", HuobiBTC.Last, HuobiBTC.High, HuobiBTC.Low, HuobiBTC.Vol)
}()
go func() {
BitstampBTC := exchange.bitstamp.GetTicker()
log.Printf("Bitstamp BTC: Last %s High %s Low %s Volume %s\n", BitstampBTC.Last, BitstampBTC.High, BitstampBTC.Low, BitstampBTC.Volume)
}()
go func() {
BitfinexBTC := exchange.bitfinex.GetTicker("btcusd")
log.Printf("Bitfinex BTC: Last %s High %s Low %s Volume %s\n", BitfinexBTC.Last_price, BitfinexBTC.High, BitfinexBTC.Low, BitfinexBTC.Volume)
}()
go func() {
BTCeBTC := exchange.btce.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() {
OKCoinChinaBTC := exchange.okcoinChina.GetTicker("btc_cny")
log.Printf("OKCoin China BTC: Last %s High %s Low %s Volume %s\n", OKCoinChinaBTC.Last, OKCoinChinaBTC.High, OKCoinChinaBTC.Low, OKCoinChinaBTC.Vol)
}()
go func() {
OKCoinChinaIntlBTC := exchange.okcoinIntl.GetTicker("btc_usd")
log.Printf("OKCoin Intl BTC: Last %s High %s Low %s Volume %s\n", OKCoinChinaIntlBTC.Last, OKCoinChinaIntlBTC.High, OKCoinChinaIntlBTC.Low, OKCoinChinaIntlBTC.Vol)
}()
go func() {
BTCChinaLTC := exchange.btcchina.GetTicker("ltccny")
log.Printf("BTCChina LTC: Last %s High %s Low %s Volume %s\n", BTCChinaLTC.Last, BTCChinaLTC.High, BTCChinaLTC.Low, BTCChinaLTC.Vol)
}()
go func() {
BitfinexLTC := exchange.bitfinex.GetTicker("ltcusd")
log.Printf("Bitfinex LTC: Last %s High %s Low %s Volume %s\n", BitfinexLTC.Last_price, BitfinexLTC.High, BitfinexLTC.Low, BitfinexLTC.Volume)
}()
go func() {
BTCeLTC := exchange.btce.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)
}()
go func() {
OKCoinChinaLTC := exchange.okcoinChina.GetTicker("ltc_cny")
log.Printf("OKCoin China LTC: Last %s High %s Low %s Volume %s\n", OKCoinChinaLTC.Last, OKCoinChinaLTC.High, OKCoinChinaLTC.Low, OKCoinChinaLTC.Vol)
}()
go func() {
OKCoinChinaIntlLTC := exchange.okcoinIntl.GetTicker("ltc_usd")
log.Printf("OKCoin Intl LTC: Last %s High %s Low %s Volume %s\n", OKCoinChinaIntlLTC.Last, OKCoinChinaIntlLTC.High, OKCoinChinaIntlLTC.Low, OKCoinChinaIntlLTC.Vol)
}()
go func() {
HuobiLTC := exchange.huobi.GetTicker("ltc")
log.Printf("Huobi LTC: Last %s High %s Low %s Volume %f\n", HuobiLTC.Last, HuobiLTC.High, HuobiLTC.Low, HuobiLTC.Vol)
}()
time.Sleep(time.Second * 15)
cmd := exec.Command("cmd", "/c", "cls")
cmd.Stdout = os.Stdout
cmd.Run()
}
}