aboutsummaryrefslogtreecommitdiff
path: root/api/markets.go
blob: 60fb9122b94d8bde62d7b19d37bbe116a361a33b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package api

import (
	"immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front/markets"
)

var Poloniex *markets.Poloniex

func OpenMarketsConnection() error {
	for {
		err := Poloniex.StartTicker()
		if err != nil {
			return err
		}
		log.Warn("connection to poloniex stream ended, restarting it...")
	}
}

func init() {
	Poloniex = markets.NewPoloniex()

	// We open markets connections in the background as it can take time.
	go func() {
		err := OpenMarketsConnection()
		if err != nil {
			ErrorChan <- err
		}
	}()
}