Use the new registrar
This commit is contained in:
parent
db866e672b
commit
04c17fc7b3
@ -1,45 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kcotugno/tacitus"
|
||||
"github.com/kcotugno/tacitus/ops"
|
||||
"github.com/kcotugno/tacitus/osutil"
|
||||
"github.com/kcotugno/tacitus/postgres"
|
||||
"github.com/kcotugno/tacitus/gdax"
|
||||
"github.com/kcotugno/tacitus/gdax/websocket"
|
||||
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logger := osutil.NewLogger()
|
||||
c := websocket.NewClient()
|
||||
ls := gdax.ListenerService{}
|
||||
ls.Client = c
|
||||
ls.Logger = logger
|
||||
|
||||
|
||||
db := postgres.NewClient()
|
||||
db.Name = "gdax"
|
||||
db.User = "gdax"
|
||||
db.SetLogger(logger)
|
||||
err := db.Open()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
r := ops.NewRegistrar()
|
||||
r.SetLogger(logger)
|
||||
if err := r.Record("ETH-USD", "BTC-USD"); err != nil {
|
||||
logger.Info("Error: %v", err)
|
||||
}
|
||||
|
||||
err = ls.Open()
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
|
||||
ls.Subscribe("ETH-USD", "BTC-USD")
|
||||
|
||||
for t := range ls.Stream() {
|
||||
go func (trade tacitus.Trade) {
|
||||
_, err := db.TradeService().CreateTrade(trade)
|
||||
if err != nil {
|
||||
logger.Info("Error inserting trade: %v", err)
|
||||
}
|
||||
}(t)
|
||||
}
|
||||
t := make(chan bool)
|
||||
<- t
|
||||
}
|
||||
|
Reference in New Issue
Block a user