shresiesbot

package module
v0.0.0-...-23ce73b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 7 Imported by: 0

README

Auto Invest Sharesies NZ (Work in progress)

Currently, Sharesies NZ only support auto-invest for managed funds what creates the need for this application to apply dollar-cost averaging for companies on NZ Market Exchange.

The project is under heavy development so interfaces and structure of the configuration files might/will change. The current implementation is an MVP put together in a couple of hours.

Scheduler

Linux crontab compatible instruction for executing orders

Predefined
Entry Description Equivalent To
@yearly (or @annually) Run once a year, midnight, Jan. 1st 0 0 1 1 *
@monthly Run once a month, midnight, first of month 0 0 1 * *
@weekly Run once a week, midnight between Sat/Sun 0 0 * * 0
@daily (or @midnight) Run once a day, midnight 0 0 * * *
@hourly Run once an hour, beginning of hour 0 * * * *

More information:

Configuration

config/auto_invest.yml

sharesies:
  username: test@test.com
  password: password

balance:
  scheduler: 0 0 1 */6 * # 6 Month
  holds: 
    - reference: Delegat Group
      id: 0545fbc5-b579-4944-9057-55d01849a493
      weight: 50 # 50%
    - reference: ANZ
      id: 860a502e-d07c-435e-9dcc-7d4631a4ee21
      weight: 50 # 50%

buy:
  scheduler: "0 8 * * MON" # Monday 8am
  orders:
    - reference: Delegat Group # Only for log purpose
      id: 0545fbc5-b579-4944-9057-55d01849a493
      amount: 1.00
    - reference: ANZ # Only for log purpose
      id: 860a502e-d07c-435e-9dcc-7d4631a4ee21
      amount: 1.00

Docker Compose

version: "3"

services:
  sharesiesbot:
    image: deividfortuna/sharesies-bot:latest
    container_name: sharesies-bot
    volumes:
      - './config/:/config'
    restart: unless-stopped

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoInvest

type AutoInvest struct {
	Sharesies *Credentials
	Buy       *BuyConfiguration
	Balance   *BalanceConfiguration
}

type BalanceConfiguration

type BalanceConfiguration struct {
	Scheduler string `validate:"required"`
	Holds     []Hold `validate:"required"`
}

type BuyConfiguration

type BuyConfiguration struct {
	Scheduler string     `validate:"required"`
	Orders    []BuyOrder `validate:"required"`
}

type BuyOrder

type BuyOrder struct {
	Reference string  `validate:"required"`
	Id        string  `validate:"required"`
	Amount    float64 `validate:"required"`
}

type Credentials

type Credentials struct {
	Username string `validate:"required"`
	Password string `validate:"required"`
}

type ExchangeClient

type ExchangeClient interface {
	Authenticate(ctx context.Context, creds *sharesies.Credentials) (*sharesies.ProfileResponse, error)
	CostBuy(ctx context.Context, fundId string, amount float64) (*sharesies.CostBuyResponse, error)
	Buy(ctx context.Context, costBuy *sharesies.CostBuyResponse) (*sharesies.ProfileResponse, error)
	CostSell(ctx context.Context, foundId string, shareAmount float64) (*sharesies.CostSellResponse, error)
	Sell(ctx context.Context, sellBuy *sharesies.CostSellResponse) (*sharesies.ProfileResponse, error)
}

type Hold

type Hold struct {
	Reference string  `validate:"required"`
	Id        string  `validate:"required"`
	Weight    float64 `validate:"required"`
}

type Scheduler

type Scheduler interface {
	AddFunc(spec string, cmd func()) (cron.EntryID, error)
}

type SellOrder

type SellOrder struct {
	Id        string
	Reference string
	Shares    float64
}

type SharesiesBot

type SharesiesBot struct {
	// contains filtered or unexported fields
}

func New

func New(scheduler Scheduler, client ExchangeClient, config *AutoInvest) *SharesiesBot

func (*SharesiesBot) Run

func (b *SharesiesBot) Run() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL