The project is under heavy development so interfaces and structure might/will change. Library initially written to be used by the project Sharesies Bot to apply Dollar-cost averaging on NZ Market Exchange.
go get github.com/deividfortuna/sharesies
ctx := context.Background()
s, _ := sharesies.New(nil)
p, err := s.Authenticate(ctx, &sharesies.SharesiesCredentials{
Username: "email@exmaple.com",
Password: "your_password_here",
})
if err != nil {
log.Fatal(err)
}
i, err := s.Instruments(ctx, &sharesies.InstrumentsRequest{
Page: 1,
Perpage: 100,
Sort: "name",
Pricechangetime: "1y",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(i)
fundId := "0545fbc5-b579-4944-9057-55d01849a493"
costBuy, err := s.CostBuy(ctx, fundId, 100.00)
if err != nil {
log.Fatal(err)
}
b, err := s.Buy(ctx, costBuy)
if err != nil {
log.Fatal(err)
}
fmt.Println(b)
fundId := "0545fbc5-b579-4944-9057-55d01849a493"
shares := 1.5 //number of shares to sell
costSell, err := s.CostSell(ctx, fundId, shares)
if err != nil {
log.Fatal(err)
}
sr, err := s.Sell(ctx, costSell)
if err != nil {
log.Fatal(err)
}
fmt.Println(b)
MIT License - Copyright (c) 2021 Deivid Fortuna