Documentation
¶
Index ¶
- Variables
- type APIResponse
- type Errno
- type ErrorMessage
- type FundData
- type Funds
- type Operation
- func (op Operation) GetAmount() float32
- func (op Operation) GetCopy() Operation
- func (op Operation) GetDate() time.Time
- func (op Operation) GetID() string
- func (op Operation) GetInsi() string
- func (op Operation) GetNav() float32
- func (op Operation) GetShares() float32
- func (op *Operation) SetAmount(amount float32)
- func (op *Operation) SetDate(t time.Time)
- func (op *Operation) SetInsi(insi string)
- func (op *Operation) SetNav(nav float32)
- func (op *Operation) SetShares(shares float32)
- type Operations
- type Wallet
- func (w *Wallet) AddFund(fund FundData) error
- func (w *Wallet) AddOperation(op Operation) error
- func (w Wallet) Allocations() map[string][]float32
- func (w Wallet) Capitalization() map[string][]float32
- func (w Wallet) GetAssetsAllocationPOJO() map[string]interface{}
- func (w Wallet) GetCopy() Wallet
- func (w Wallet) GetFundData(insi string) FundData
- func (w Wallet) GetFundInsiByName(name string) string
- func (w Wallet) GetFundNameByInsi(insi string) string
- func (w Wallet) GetFunds() Funds
- func (w Wallet) GetHistoricWalletPOJO() map[string]interface{}
- func (w Wallet) GetID() string
- func (w Wallet) GetName() string
- func (w Wallet) GetOperations() Operations
- func (w Wallet) GetOperationsFor(insi string) ([]Operation, error)
- func (w Wallet) HasFund(insi string) bool
- func (w Wallet) HasOperation(op Operation) bool
- func (w Wallet) Profitability() map[string][]float32
- func (w *Wallet) RemoveFundByInsi(insi string)
- func (w Wallet) RemoveOperation(opID string) error
- func (w *Wallet) SetName(name string) error
- func (w *Wallet) UpdateFundData(fund FundData) error
- func (w *Wallet) UpdateFundDataAndOps(oldInsi string, fund FundData) error
- func (w *Wallet) UpdateOperation(opID string, newOp Operation) error
Constants ¶
This section is empty.
Variables ¶
var ( ERR_MESSAGES = map[Errno]string{ MSG_STATUS_SUCCESS: "operation successful", ERR_INSERT_WALLET: "error saving the wallet", ERR_NEW_WALLET: "invalid name", ERR_NOT_FOUND: "element not found", ERR_DB_NOT_FOUND: "database not avaliable in context", ERR_WALLET_NOT_FOUND: "wallet not found", ERR_NOT_A_WALLET: "not a wallet", ERR_UPDATE_WALLET: "unable to update the wallet", ERR_INSI_NOT_FOUND: "inis not found", } )
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type APIResponse struct {
Type string `json:"type"`
Msg json.RawMessage `json:"msg"`
}
type ErrorMessage ¶
func NewError ¶
func NewError(code Errno, msg string) ErrorMessage
type FundData ¶
type FundData struct {
INSI string `json:"insi,omitempty"`
Name string `json:"name,omitempty"`
Date time.Time `json:"date,omitempty"`
DayChange [2]float32 `json:"day_change,omitempty"`
TimeDelayed string `json:"time_delayed,omitempty"`
OneMonthS string `json:"one_month_s,omitempty"`
ThreeMonthS string `json:"three_month_s,omitempty"`
SixMonthS string `json:"six_month_s,omitempty"`
OneYearS string `json:"one_year_s,omitempty"`
OneDay float32 `json:"one_day,omitempty"`
OneWeek float32 `json:"one_week,omitempty"`
OneMonth float32 `json:"one_month,omitempty"`
ThreeMonth float32 `json:"three_month,omitempty"`
OneYear float32 `json:"one_year,omitempty"`
ThreeYears float32 `json:"three_years,omitempty"`
FiveYears float32 `json:"five_years,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
FundData represents the dynamic data for the Fund
func (FundData) Predictions ¶
Predictions returns the profit predictions
type Funds ¶
Funds contains the dymanic data for each Fund
func CopyFundsMap ¶
CopyFundsMap creates a deep copy for Funds type
type Operation ¶
Operation represents one operation
func NewOperation ¶
NewOperation returns a new operation
func (Operation) GetInsi ¶
GetInsi returns the INSI associated to the Fund where the operation was made
func (Operation) GetNav ¶
GetNav returns the Net Asset Value of the fund to which the operation was carried out
func (Operation) GetShares ¶
GetShares returns the number of shares for the operation was carried out
type Operations ¶
Operations represents the operations that were taken by a Fund
func CopyOperationsMap ¶
func CopyOperationsMap(ops Operations) Operations
CopyOperationsMap creates a deep copy for Operations type
type Wallet ¶
type Wallet struct {
ID string
Name string
Funds Funds
Ops Operations
CreatedAt time.Time
UpdatedAt time.Time
}
Wallet represents a wallet
func (*Wallet) AddOperation ¶
AddOperation adds an operation to the wallet
func (Wallet) Allocations ¶
Allocations returns the percentage of assets allocation in the wallet. The result is a map where the key is the Fund INSI and the value is a slice for the initial allocation and the actual allocation.
func (Wallet) Capitalization ¶
Capitalization returns the wallet capitalization. The return object is a map which each key is a Fund INSI and the value is slice if 3 elements. The first one represents the shares, the second the inputs, and the third one is the wallet's worth.
func (Wallet) GetAssetsAllocationPOJO ¶
GetAssetsAllocationPOJO retuns an object which can be consumed by Charts.js. The object is usefull for plotting the allocations
func (Wallet) GetFundData ¶
GetFundData returns the dynamic data associated to each Fund
func (Wallet) GetFundInsiByName ¶
GetFundInsiByName returns the Fund INSI for a given name
func (Wallet) GetFundNameByInsi ¶
GetFundNameByInsi retruns the Fund name for a given INSI
func (Wallet) GetHistoricWalletPOJO ¶
GetHistoricWalletPOJO retuns an object which can be consumed by Charts.js. The object is usefull for plotting the inputs history
func (Wallet) GetOperations ¶
func (w Wallet) GetOperations() Operations
GetOperations returns the operations
func (Wallet) GetOperationsFor ¶
GetOperationsFor returns all the operations associated to a Fund
func (Wallet) HasFund ¶
HasFund returns true if the Fund is associated to the wallet, otherwise it returns false
func (Wallet) HasOperation ¶
HasOperation returns true is the wallet has the operation, otherwise it returns false
func (Wallet) Profitability ¶
Profitability returns the wallet profitability. The return object is a map which each key is a Fund INSI and the value is slice if 4 elements. The first one is the profitability which is the difference between input and wotrh, the second one is the percentage for the profitability, the third one is the TWR (Time-Weighted Return). Finally, the fourth one is MWR Money-Weighted Return.
func (*Wallet) RemoveFundByInsi ¶
RemoveFundByInsi removes a Fund from the wallet
func (Wallet) RemoveOperation ¶
RemoveOperation removed an operation from the wallet
func (*Wallet) UpdateFundData ¶
UpdateFundData updates the Fund dynamic data
func (*Wallet) UpdateFundDataAndOps ¶
UpdateFundDataAndOps updates the Fund dynamic data and its operations