Unofficial library for working with InvestAPI platforms Tinkoff Investments
Clone this repository first, and we are ready to go.
$ git clone https://github.com/ssummers02/invest-api-go-sdk
func main() {
cfg := pkg.Config{
Token: "token",
AccountID: []string{"account-id"},
}
services, err := pkg.NewServicePool(cfg)
if err != nil {
log.Println(err)
}
accounts, err := services.GetSandboxAccounts()
if err != nil {
log.Println(err)
}
log.Println(accounts)
}
func listenTradeStream(ctx context.Context, services *pkg.ServicePool) {
for {
msg, err := services.OrderStreamInterface.Recv()
if err != nil {
log.Println(err)
}
orderTrades := msg.GetOrderTrades()
if orderTrades != nil {
log.Println(orderTrades)
}
select {
case <-time.After(1 * time.Second):
// pass
case <-ctx.Done():
return
}
}
}
func main() {
cfg := pkg.Config{
Token: "token",
AccountID: []string{"account-id"},
}
services, err := pkg.NewServicePool(cfg)
if err != nil {
log.Println(err)
}
tradeStreamCtx, _ := context.WithCancel(context.Background())
go listenTradeStream(tradeStreamCtx, services)
}