Skip to content

deividfortuna/sharesies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Unofficial Go Sharesies NZ SDK

Go Reference

Sharesies NZ

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.

Installation

go get github.com/deividfortuna/sharesies

Get Started

ctx := context.Background()
s, _ := sharesies.New(nil)

Authenticate

p, err := s.Authenticate(ctx, &sharesies.SharesiesCredentials{
	Username: "[email protected]",
	Password: "your_password_here",
})
if err != nil {
	log.Fatal(err)
}

Listed Companies/Funds

i, err := s.Instruments(ctx, &sharesies.InstrumentsRequest{
	Page:            1,
	Perpage:         100,
	Sort:            "name",
	Pricechangetime: "1y",
})
if err != nil {
	log.Fatal(err)
}

fmt.Println(i)

Buy Transaction

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)

Sell Transaction

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)

LICENSE

MIT License - Copyright (c) 2021 Deivid Fortuna

Releases

No releases published

Packages

No packages published

Languages