Exemplo n.º 1
0
// Initialize exchanges
func setExchanges() {
	exchanges = []exchange.Interface{
		bitfinex.New(os.Getenv("BITFINEX_KEY"), os.Getenv("BITFINEX_SECRET"), cfg.Sec.Symbol, "usd", 1, 0.001, cfg.Sec.AvailShortBitfinex, cfg.Sec.AvailFundsBitfinex),
		okcoin.New(os.Getenv("OKUSD_KEY"), os.Getenv("OKUSD_SECRET"), cfg.Sec.Symbol, "usd", 1, 0.002, cfg.Sec.AvailShortOKusd, cfg.Sec.AvailFundsOKusd),
		okcoin.New(os.Getenv("OKCNY_KEY"), os.Getenv("OKCNY_SECRET"), cfg.Sec.Symbol, "cny", 1, 0.000, cfg.Sec.AvailShortOKcny, cfg.Sec.AvailFundsOKcny),
		btcchina.New(os.Getenv("BTC_KEY"), os.Getenv("BTC_SECRET"), cfg.Sec.Symbol, "cny", 1, 0.000, cfg.Sec.AvailShortBTC, cfg.Sec.AvailFundsBTC),
	}
	for _, exg := range exchanges {
		log.Printf("Using exchange %s with priority %d and fee of %.4f", exg, exg.Priority(), exg.Fee())
	}
	currencies = append(currencies, "cny")
}
Exemplo n.º 2
0
// Tester program for displaying OKCoin book data to terminal

package main

import (
	"bitfx/btcchina"
	"bitfx/exchange"
	"bitfx/forex"
	"fmt"
	"log"
	"os"
	"os/exec"
)

var (
	btc = btcchina.New("", "", "btc", "cny", 0, 0, 0, 0)
	cny float64
)

func main() {
	filename := "btcbook.log"
	logFile, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	if err != nil {
		log.Fatal(err)
	}
	log.SetOutput(logFile)
	log.Println("Starting new run")
	fxChan := make(chan forex.Quote)
	fxDoneChan := make(chan bool, 1)
	quote := forex.CommunicateFX("cny", fxChan, fxDoneChan)
	if quote.Error != nil || quote.Price == 0 {