github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/examples/ws/authenticated-feed-ingest/main.go (about) 1 package main 2 3 import ( 4 "log" 5 6 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/balanceinfo" 7 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/event" 8 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/fundingcredit" 9 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/fundingloan" 10 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/fundingoffer" 11 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/fundingtrade" 12 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/margin" 13 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/notification" 14 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/order" 15 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/position" 16 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/trades" 17 "github.com/bitfinexcom/bitfinex-api-go/pkg/models/wallet" 18 "github.com/bitfinexcom/bitfinex-api-go/pkg/mux" 19 ) 20 21 func main() { 22 m := mux.New(). 23 TransformRaw(). 24 WithAPIKEY("YOUR_API_KEY"). 25 WithAPISEC("YOUR_API_SECRET"). 26 Start() 27 28 crash := make(chan error) 29 30 go func() { 31 crash <- m.Listen(func(msg interface{}, err error) { 32 if err != nil { 33 log.Printf("error received: %s\n", err) 34 } 35 36 switch v := msg.(type) { 37 case event.Info: 38 log.Printf("%T: %+v\n", v, v) 39 case order.New: 40 log.Printf("%T: %+v\n", v, v) 41 case *order.Snapshot: 42 log.Printf("%T: %+v\n", v, v) 43 case order.Update: 44 log.Printf("%T: %+v\n", v, v) 45 case order.Cancel: 46 log.Printf("%T: %+v\n", v, v) 47 case wallet.Update: 48 log.Printf("%T: %+v\n", v, v) 49 case *wallet.Snapshot: 50 log.Printf("%T: %+v\n", v, v) 51 case balanceinfo.Update: 52 log.Printf("%T: %+v\n", v, v) 53 case fundingoffer.New: 54 log.Printf("%T: %+v\n", v, v) 55 case fundingoffer.Cancel: 56 log.Printf("%T: %+v\n", v, v) 57 case fundingoffer.Update: 58 log.Printf("%T: %+v\n", v, v) 59 case *fundingoffer.Snapshot: 60 log.Printf("%T: %+v\n", v, v) 61 case fundingcredit.New: 62 log.Printf("%T: %+v\n", v, v) 63 case fundingcredit.Update: 64 log.Printf("%T: %+v\n", v, v) 65 case fundingcredit.Cancel: 66 log.Printf("%T: %+v\n", v, v) 67 case trades.AuthFundingTradeUpdate: 68 log.Printf("%T: %+v\n", v, v) 69 case trades.AuthFundingTradeExecuted: 70 log.Printf("%T: %+v\n", v, v) 71 case trades.AuthTradeExecution: 72 log.Printf("%T: %+v\n", v, v) 73 case trades.AuthTradeExecutionUpdate: 74 log.Printf("%T: %+v\n", v, v) 75 case fundingtrade.HistoricalSnapshot: 76 log.Printf("%T: %+v\n", v, v) 77 case *fundingcredit.Snapshot: 78 log.Printf("%T: %+v\n", v, v) 79 case *position.Snapshot: 80 log.Printf("%T: %+v\n", v, v) 81 case position.New: 82 log.Printf("%T: %+v\n", v, v) 83 case position.Update: 84 log.Printf("%T: %+v\n", v, v) 85 case position.Cancel: 86 log.Printf("%T: %+v\n", v, v) 87 case *fundingloan.Snapshot: 88 log.Printf("%T: %+v\n", v, v) 89 case fundingloan.New: 90 log.Printf("%T: %+v\n", v, v) 91 case fundingloan.Update: 92 log.Printf("%T: %+v\n", v, v) 93 case fundingloan.Cancel: 94 log.Printf("%T: %+v\n", v, v) 95 case notification.Notification: 96 log.Printf("%T: %+v\n", v, v) 97 case *margin.InfoUpdate: 98 log.Printf("%T: %+v\n", v, v) 99 case *margin.InfoBase: 100 log.Printf("%T: %+v\n", v, v) 101 default: 102 log.Printf("raw/unhandled: %T: %+v\n", v, v) 103 } 104 }) 105 }() 106 107 log.Fatal(<-crash) 108 }