goksei

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 16 Imported by: 0

README

goksei

Unofficial client library for AKSES-KSEI

Go Reference Go Report Card

Project status

Unstable proof of concept

Features

  • Login with username and (salted) password
  • Cache token on disk with auto relogin when expired
  • Get balance overview
  • Get balance for Equities, Mutual Funds, Bonds, and "Others"
  • Get cash balance
  • Command-line interface

Using as library

Get it as dependency

go get -u github.com/chickenzord/goksei

Example usages:


import "github.com/chickenzord/goksei/pkg/goksei"

func main() {
    client := goksei.NewClient("username", "saltedpassword")

    equityBalance, err := client.GetShareBalances(goksei.EquityType)
    if err != nil {
        panic(err)
    }

    // ...
}

Using as CLI

Create .env file with following content:

GOKSEI_USERNAME=youremail@domain.com
GOKSEI_PASSWORD=yoursaltedpassword

The salted password can be obtained by logging in with your account on https://akses.ksei.co.id/login and inspect the request payload sent by JS code.

Currently the CLI only serve as feature showcase. Run it with...

go run .

Disclaimer

This project is only for personal and educational purpose. Use on your own risk, there is no guarantee this project will always work when KSEI changed their API or policies.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustodianBankNameByCode added in v0.7.1

func CustodianBankNameByCode(code string) (name string, ok bool)

func CustodianBankNameByID deprecated added in v0.6.0

func CustodianBankNameByID(id string) (name string, ok bool)

CustodianBankNameByID returns bank name by ID

Deprecated: use CustodianBankNameByCode instead

Types

type AuthStore

type AuthStore gokv.Store

func NewFileAuthStore

func NewFileAuthStore(dir string) (AuthStore, error)

type CashBalance added in v0.5.0

type CashBalance struct {
	ID            int     `json:"id"`
	AccountNumber string  `json:"rekening"`
	BankID        string  `json:"bank"`
	Currency      string  `json:"currCode"`
	Balance       float64 `json:"saldo"`
	BalanceIDR    float64 `json:"saldoIdr"`
	Status        int     `json:"status"`
}

func (*CashBalance) CurrentBalance added in v0.5.0

func (c *CashBalance) CurrentBalance() float64

type CashBalanceResponse added in v0.5.0

type CashBalanceResponse struct {
	Data []CashBalance `json:"data"`
}

type Client

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

func NewClient

func NewClient(opts ClientOpts) *Client

func (*Client) Get added in v0.5.0

func (c *Client) Get(path string, dst interface{}) error

func (*Client) GetCashBalances added in v0.5.0

func (c *Client) GetCashBalances() (*CashBalanceResponse, error)

func (*Client) GetGlobalIdentity

func (c *Client) GetGlobalIdentity() (*GlobalIdentityResponse, error)

func (*Client) GetPortfolioSummary

func (c *Client) GetPortfolioSummary() (*PortfolioSummaryResponse, error)

func (*Client) GetShareBalances

func (c *Client) GetShareBalances(portfolioType PortfolioType) (*ShareBalanceResponse, error)

func (*Client) SetAuth

func (c *Client) SetAuth(username, password string)

type ClientOpts

type ClientOpts struct {
	AuthStore AuthStore // directory path to store cached authentication data
	Username  string
	Password  string
}

type CustodianBank added in v0.5.0

type CustodianBank struct {
	Code string
	Name string
}

func CustodianBankByCode added in v0.7.1

func CustodianBankByCode(code string) (custodianBank *CustodianBank, ok bool)

func CustodianBanks added in v0.7.0

func CustodianBanks() []CustodianBank

type GlobalIdentity

type GlobalIdentity struct {
	LoginID  string `json:"idLogin"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Phone    string `json:"phone"`
	FullName string `json:"fullName"`

	InvestorID   string `json:"investorId"`
	InvestorName string `json:"sidName"`
	CitizenID    string `json:"nikId"`
	PassportID   string `json:"passportId"`
	TaxID        string `json:"npwp"`   // Indonesian Tax number (NPWP)
	CardID       string `json:"cardId"` // KSEI card ID
}

type GlobalIdentityResponse

type GlobalIdentityResponse struct {
	Code       string
	Status     string
	Identities []GlobalIdentity
}

type LoginRequest

type LoginRequest struct {
	ID       string `json:"id"`
	AppType  string `json:"appType"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type LoginResponse

type LoginResponse struct {
	Validation string `json:"validation"`
}

type MutualFund added in v0.4.0

type MutualFund struct {
	Code              string
	ProductName       string
	FundType          string
	InvestmentManager string
}

func MutualFundByCode added in v0.4.0

func MutualFundByCode(code string) (mutualFund *MutualFund, ok bool)

func MutualFunds added in v0.7.0

func MutualFunds() []MutualFund

type PortfolioSummaryDetails

type PortfolioSummaryDetails struct {
	Type    string  `json:"type"`
	Amount  float64 `json:"summaryAmount"`
	Percent float64 `json:"percent"`
}

type PortfolioSummaryResponse

type PortfolioSummaryResponse struct {
	Total   float64                   `json:"summaryValue"`
	Details []PortfolioSummaryDetails `json:"summaryResponse"`
}

type PortfolioType

type PortfolioType string
var (
	EquityType     PortfolioType = "EKUITAS"
	MutualFundType PortfolioType = "REKSADANA"
	CashType       PortfolioType = "KAS"
	BondType       PortfolioType = "OBLIGASI"
	OtherType      PortfolioType = "LAINNYA"
)

func (PortfolioType) Name

func (t PortfolioType) Name() string

type ShareBalance

type ShareBalance struct {
	Account      string  `json:"rekening"`   // Security account number. Example: "XL001CANE000000"
	FullName     string  `json:"efek"`       // Name of the asset. Example: "GOTO - GOTO GOJEK TOKOPEDIA Tbk"
	Participant  string  `json:"partisipan"` // Security or Asset Management name. Example: "MAHAKARYA ARTHA SEKURITAS, PT "
	BalanceType  string  `json:"tipeSaldo"`  // Example: "available"
	Currency     string  `json:"curr"`       // Example: "IDR"
	Amount       float64 `json:"jumlah"`     // units owned
	ClosingPrice float64 `json:"harga"`      // last closing price
	// contains filtered or unexported fields
}

func (*ShareBalance) CurrentValue

func (c *ShareBalance) CurrentValue() float64

func (*ShareBalance) Name added in v0.3.1

func (c *ShareBalance) Name() string

func (*ShareBalance) Symbol

func (c *ShareBalance) Symbol() string

func (*ShareBalance) Valid

func (c *ShareBalance) Valid() bool

type ShareBalanceResponse

type ShareBalanceResponse struct {
	Total float64        `json:"summaryValue"`
	Data  []ShareBalance `json:"data"`
}

func (*ShareBalanceResponse) RemoveInvalidData

func (r *ShareBalanceResponse) RemoveInvalidData()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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