Added basic Bitfinex Websocket implementation.

This commit is contained in:
Adrian Gallagher
2015-05-30 19:06:49 +10:00
parent 721d74ff8a
commit 793ea76d43
3 changed files with 122 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"errors"
"fmt"
"github.com/gorilla/websocket"
"log"
"strconv"
"strings"
@@ -159,6 +160,7 @@ type Bitfinex struct {
BaseCurrencies []string
AvailablePairs []string
EnabledPairs []string
WebsocketConn *websocket.Conn
}
func (b *Bitfinex) SetDefaults() {
@@ -188,10 +190,15 @@ func (b *Bitfinex) SetAPIKeys(apiKey, apiSecret string) {
func (b *Bitfinex) Run() {
if b.Verbose {
log.Printf("%s Websocket: %s.", b.GetName(), IsEnabled(b.Websocket))
log.Printf("%s polling delay: %ds.\n", b.GetName(), b.RESTPollingDelay)
log.Printf("%s %d currencies enabled: %s.\n", b.GetName(), len(b.EnabledPairs), b.EnabledPairs)
}
if b.Websocket {
go b.WebsocketClient()
}
exchangeProducts, err := b.GetSymbols()
if err != nil {
log.Printf("%s Failed to get available symbols.\n", b.GetName())