monujo

package module
v0.0.0-...-6fc235c Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

README

monujo

The investment portfolio

##Install

  1. Run ./install.sh

##HowTo Import Quotes?

  1. Go to http://stooq.com/db/h/
  2. Download daily quotes in ASCII format
  3. Unzip downloaded file
  4. Run ./scripts/import_quotes.sh and pass comma separated list of tickers

##HowTo Update Quotes?

  1. Please make sure tickers.conf file is populated
  2. Go to http://stooq.com/db/
  3. Download latest daily quotes
  4. Run ./scripts/update_quotes [path_to_downloaded_file]

##HowTo Update Latest Quotes Only?

  1. Please make sure tickers.conf file is populated
  2. Go to http://stooq.com/db/
  3. Download latest daily quotes
  4. Run ./scripts/update_latest_quotes [path_to_downloaded_file]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(c dbConf) (*sqlx.DB, error)

func New

func New(c Config, r *Repository, s Screen, i Input) (*monujo, error)

Types

type Alphavantage

type Alphavantage Source

type Bankier

type Bankier Source

type Config

type Config interface {
	Db() dbConf
	Sys() sysConf
	App() appConf
}

func NewConfig

func NewConfig(env string) (Config, error)

type Currencies

type Currencies []Currency

func (*Currencies) CurrencyPairs

func (currencies *Currencies) CurrencyPairs(base string) []string

type Currency

type Currency struct {
	Symbol string `db:"currency"`
}

type FinancialOperationType

type FinancialOperationType struct {
	OperationType
}

type FinancialOperationTypes

type FinancialOperationTypes []FinancialOperationType

type Generali

type Generali Source

type Google

type Google Source

type Ingturbo

type Ingturbo Source

type Input

type Input interface {
	String(name string, args ...string) string
	Float(name string, args ...float64) float64
	Date(name string, args ...time.Time) time.Time
}

type Operation

type Operation struct {
	OperationId int64     `db:"operation_id"`
	PortfolioId int64     `db:"portfolio_id"`
	Date        time.Time `db:"date"`
	Type        string    `db:"type"`
	Value       float64   `db:"value"`
	Description string    `db:"description"`
	Commision   float64   `db:"commision"`
	Tax         float64   `db:"tax"`
}

type OperationType

type OperationType struct {
	Type string `db:"type"`
}

type OperationTypes

type OperationTypes []OperationType

type Operations

type Operations []Operation

type OwnedStock

type OwnedStock struct {
	Stock
	PortfolioId                        int64           `db:"portfolio_id"`
	PortfolioName                      string          `db:"portfolio_name"`
	Shares                             float64         `db:"shares"`
	ExchangeRate                       sql.NullFloat64 `db:"exchange_rate"`
	LastPriceBaseCurrency              sql.NullFloat64 `db:"last_price_base_currency"`
	AveragePrice                       float64         `db:"average_price"`
	AveragePriceBaseCurrency           float64         `db:"average_price_base_currency"`
	InvestmentBaseCurrency             sql.NullFloat64 `db:"investment_base_currency"`
	MarketValueBaseCurrency            sql.NullFloat64 `db:"market_value_base_currency"`
	Gain                               sql.NullFloat64 `db:"gain"`
	PercentageGain                     sql.NullFloat64 `db:"percentage_gain"`
	GainBaseCurrency                   sql.NullFloat64 `db:"gain_base_currency"`
	PercentageGainBaseCurrency         sql.NullFloat64 `db:"percentage_gain_base_currency"`
	AveragePriceAdjusted               float64         `db:"average_price_adjusted"`
	GainAdjusted                       sql.NullFloat64 `db:"gain_adjusted"`
	PercentageGainAdjusted             sql.NullFloat64 `db:"percentage_gain_adjusted"`
	GainAdjustedBaseCurrency           sql.NullFloat64 `db:"gain_adjusted_base_currency"`
	PercentageGainAdjustedBaseCurrency sql.NullFloat64 `db:"percentage_gain_adjusted_base_currency"`
}

type OwnedStocks

type OwnedStocks []OwnedStock

func (*OwnedStocks) DistinctTickers

func (stocks *OwnedStocks) DistinctTickers() []string

type Portfolio

type Portfolio struct {
	PortfolioId int64  `db:"portfolio_id"`
	Name        string `db:"name"`
	Currency    string `db:"currency"`
}

type PortfolioExt

type PortfolioExt struct {
	Portfolio
	CacheValue            sql.NullFloat64 `db:"cache_value"`
	GainOfSoldShares      sql.NullFloat64 `db:"gain_of_sold_shares"`
	Commision             sql.NullFloat64 `db:"commision"`
	Tax                   sql.NullFloat64 `db:"tax"`
	GainOfOwnedShares     sql.NullFloat64 `db:"gain_of_owned_shares"`
	EstimatedGain         sql.NullFloat64 `db:"estimated_gain"`
	EstimatedGainCostsInc sql.NullFloat64 `db:"estimated_gain_costs_inc"`
	EstimatedValue        sql.NullFloat64 `db:"estimated_value"`
	AnnualBalance         float64         `db:"annual_balance"`
	MonthBalance          float64         `db:"month_balance"`
}

type Portfolios

type Portfolios []Portfolio

type PortfoliosExt

type PortfoliosExt []PortfolioExt

type Quote

type Quote struct {
	Ticker  string    `db:"ticker"`
	Date    time.Time `db:"date"`
	Open    float64   `db:"open"`
	High    float64   `db:"high"`
	Low     float64   `db:"low"`
	Close   float64   `db:"close"`
	Volume  float64   `db:"volume"`
	OpenInt float64   `db:"openint"`
}

type Quotes

type Quotes []Quote

type Repository

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

func NewRepository

func NewRepository(db *sqlx.DB, c Config) (*Repository, error)

func (*Repository) Currencies

func (r *Repository) Currencies() (Currencies, error)

func (*Repository) DeleteOperation

func (r *Repository) DeleteOperation(operation Operation) error

func (*Repository) DeleteTransaction

func (r *Repository) DeleteTransaction(transaction Transaction) error

func (*Repository) FinancialOperationTypes

func (r *Repository) FinancialOperationTypes() (FinancialOperationTypes, error)

func (*Repository) OwnedStocks

func (r *Repository) OwnedStocks() (OwnedStocks, error)

func (*Repository) PortfolioOperations

func (r *Repository) PortfolioOperations(portfolio Portfolio) (Operations, error)

func (*Repository) PortfolioTransactions

func (r *Repository) PortfolioTransactions(portfolio Portfolio) (Transactions, error)

func (*Repository) Portfolios

func (r *Repository) Portfolios() (Portfolios, error)

func (*Repository) PortfoliosExt

func (r *Repository) PortfoliosExt() (PortfoliosExt, error)

func (*Repository) Securities

func (r *Repository) Securities(tickers []string) (Securities, error)

func (*Repository) SecurityExists

func (r *Repository) SecurityExists(ticker string) (bool, error)

func (*Repository) Sources

func (r *Repository) Sources() (Sources, error)

func (*Repository) StoreLatestQuote

func (r *Repository) StoreLatestQuote(quote Quote) (string, error)

func (*Repository) StoreOperation

func (r *Repository) StoreOperation(operation Operation) (int64, error)

func (*Repository) StoreSecurity

func (r *Repository) StoreSecurity(s Security) (string, error)

func (*Repository) StoreTransaction

func (r *Repository) StoreTransaction(transaction Transaction) (int64, error)

func (*Repository) UpdateQuotes

func (r *Repository) UpdateQuotes(sources Sources) (chan Quote, error)

type Screen

type Screen interface {
	PrintTable(header []string, data [][]interface{})
	PrintText(format string, a ...interface{})
	NewLine(n ...int)
	Clear()
}

type Securities

type Securities []Security

type Security

type Security struct {
	Ticker        string         `db:"ticker"`
	ShortName     string         `db:"short_name"`
	FullName      string         `db:"full_name"`
	Market        string         `db:"market"`
	Leverage      float64        `db:"leverage"`
	QuotesSource  string         `db:"quotes_source"`
	TickerBankier sql.NullString `db:"ticker_bankier"`
}

type Source

type Source struct {
	Name string `db:"name"`
}

func (Source) Update

func (s Source) Update(securities Securities, quotes chan Quote, wg *sync.WaitGroup, config appConf)

type Sources

type Sources []Source

type Stock

type Stock struct {
	Ticker    string          `db:"ticker"`
	ShortName sql.NullString  `db:"short_name"`
	LastPrice sql.NullFloat64 `db:"last_price"`
	Currency  string          `db:"currency"`
}

func (*Stock) DisplayName

func (stock *Stock) DisplayName() string

type Stooq

type Stooq Source

type Sw

type Sw Source

type Transaction

type Transaction struct {
	TransactionId int64     `db:"transaction_id"`
	PortfolioId   int64     `db:"portfolio_id"`
	Date          time.Time `db:"date"`
	Ticker        string    `db:"ticker"`
	Price         float64   `db:"price"`
	Currency      string    `db:"currency"`
	Shares        float64   `db:"shares"`
	Commision     float64   `db:"commision"`
	ExchangeRate  float64   `db:"exchange_rate"`
	Tax           float64   `db:"tax"`
}

type Transactions

type Transactions []Transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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