Documentation ¶
Index ¶
Constants ¶
const ( Dow string = "^DJI" SP500 string = "^GSPC" Nasdaq string = "^IXIC" Russell2000 string = "^RUT" Foreign string = "VXUS" China string = "000001.SS" USBond string = "BND" Treasury10 string = "^TNX" Gold string = "GC=F" Oil string = "CL=F" Bitcoin string = "BTC-USD" Ethereum string = "ETH-USD" )
Market index symbols
Variables ¶
var AssetDB = func() map[string]*Asset { return map[string]*Asset{ "SPY": {"SPY", AssetClassUSStock, AssetClassUSStockLarge}, "VOO": {"VOO", AssetClassUSStock, AssetClassUSStockLarge}, "VTI": {"VTI", AssetClassUSStock, AssetClassUSStockLarge}, "VTV": {"VTV", AssetClassUSStock, AssetClassUSStockLargeValue}, "VIG": {"VTV", AssetClassUSStock, AssetClassUSStockLarge}, "VUG": {"VUG", AssetClassUSStock, AssetClassUSStockLargeGrowth}, "QQQ": {"QQQ", AssetClassUSStock, AssetClassUSStockLargeTech}, "VO": {"VO", AssetClassUSStock, AssetClassUSStockMid}, "VB": {"VB", AssetClassUSStock, AssetClassUSStockSmall}, "VEU": {"VEU", AssetClassInternationalStock, AssetClassInternationalStock}, "VXUS": {"VXUS", AssetClassInternationalStock, AssetClassInternationalStock}, "VWO": {"VWO", AssetClassInternationalStock, AssetClassEmergingMarketStock}, "GXC": {"GXC", AssetClassChinaStock, AssetClassChinaStock}, "VNQ": {"VNQ", AssetClassUSRealEstate, AssetClassUSRealEstate}, "EPR": {"EPR", AssetClassUSRealEstate, AssetClassUSRealEstateExperiential}, "VNQI": {"VNQI", AssetClassInternationalRealEstate, AssetClassInternationalRealEstate}, "BND": {"BND", AssetClassUSBond, AssetClassUSBond}, "GOVT": {"GOVT", AssetClassUSTreasury, AssetClassUSTreasury}, "VGLT": {"VGLT", AssetClassUSTreasury, AssetClassUSTreasuryLongTerm}, "SPTI": {"SPTI", AssetClassUSTreasury, AssetClassUSTreasuryIntermediateTerm}, "SHY": {"SHY", AssetClassUSTreasury, AssetClassUSTreasuryShortTerm}, "TIP": {"TIP", AssetClassUSTreasury, AssetClassUSTreasuryInflationProtected}, "DBC": {"DBC", AssetClassCommodity, AssetClassCommodity}, "USO": {"USO", AssetClassCommodity, AssetClassCrudeOil}, "GLD": {"GLD", AssetClassCommodity, AssetClassGold}, "IAU": {"IAU", AssetClassCommodity, AssetClassGold}, "SLV": {"SLV", AssetClassCommodity, AssetClassSilver}, "BTC-USD": {"BTC-USD", AssetClassCrypto, AssetClassCrypto}, "ETH-USD": {"ETH-USD", AssetClassCrypto, AssetClassCrypto}, } }
AssetDB returns a built-in database for assets of interest
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct { Symbol string Class AssetClass Subclass AssetClass }
Asset defines a security held in the portfolio
type AssetClass ¶
type AssetClass string
AssetClass defines the type for asset classes and subclasses
const ( AssetClassUSStock AssetClass = "US Stock" AssetClassUSStockLarge AssetClass = "US Stock Large" AssetClassUSStockLargeValue AssetClass = "US Stock Large Value" AssetClassUSStockLargeGrowth AssetClass = "US Stock Large Growth" AssetClassUSStockLargeTech AssetClass = "US Stock Large Tech" AssetClassUSStockMid AssetClass = "US Stock Mid" AssetClassUSStockSmall AssetClass = "US Stock Small" AssetClassInternationalStock AssetClass = "International Stock" AssetClassEmergingMarketStock AssetClass = "Emerging Market Stock" AssetClassChinaStock AssetClass = "China Stock" AssetClassUSRealEstate AssetClass = "US Real Estate" AssetClassUSRealEstateExperiential AssetClass = "US Real Estate Experiential" AssetClassInternationalRealEstate AssetClass = "International Real Estate" AssetClassUSBond AssetClass = "US Bond" AssetClassUSTreasury AssetClass = "US Treasury" AssetClassUSTreasuryLongTerm AssetClass = "US Treasury Long Term" AssetClassUSTreasuryIntermediateTerm AssetClass = "US Treasury Intermediate Term" AssetClassUSTreasuryShortTerm AssetClass = "US Treasury Short Term" AssetClassUSTreasuryInflationProtected AssetClass = "US Treasury Inflation Protected" AssetClassCommodity AssetClass = "Commodity" AssetClassCrudeOil AssetClass = "CrudeOil" AssetClassGold AssetClass = "Gold" AssetClassSilver AssetClass = "Silver" AssetClassCrypto AssetClass = "Crypto" AssetClassOther AssetClass = "Other" )
Asset class definitions
type Holding ¶
type Holding struct { Asset *Asset Quantity float64 CostBasis float64 Watch float64 Quote *finance.Quote Status *HoldingStatus }
Holding defines a position in the portfolio
func NewHolding ¶
NewHolding returns a new holding object
func (*Holding) GetHistoricalQuote ¶
GetHistoricalQuote returns the quote on a specific day
func (*Holding) Refresh ¶
Refresh gets the current quote and computes the current status of a particular holding
func (*Holding) RefreshQuote ¶
RefreshQuote gets the current quote of a particular holding
func (*Holding) RefreshStatus ¶
func (holding *Holding) RefreshStatus()
RefreshStatus computes the current status of a holding from the current quote
type HoldingStatus ¶
HoldingStatus defines the real-time status of a particular holding
type Market ¶
type Market struct { Dow *finance.Index SP500 *finance.Index Nasdaq *finance.Index Russell2000 *finance.Index Foreign *finance.Index China *finance.Index USBond *finance.Index Treasury10 *finance.Index Gold *finance.Index Oil *finance.Index Bitcoin *finance.Index Ethereum *finance.Index }
Market defines the broader market indices we track
type Performance ¶
type Performance struct { Portfolio *Portfolio BenchmarkSymbol string InitialBalance float64 StartDate time.Time EndDate time.Time Result *PerformanceResult Benchmark *PerformanceResult Ready bool }
Performance analyzes the historic performance of a portfolio and compares it against a benchmark
func NewPerformance ¶
func NewPerformance(portfolio *Portfolio, benchmark string, initialBalance float64) *Performance
NewPerformance creates a new analysis of the historic performance of a portfolio
func (*Performance) Compute ¶
func (performance *Performance) Compute() error
Compute generates the performance data for the portfolio
type PerformanceResult ¶
type PerformanceResult struct { Portfolio *Portfolio Historic []Historic FinalBalance float64 CAGR float64 Stdev float64 BestYear float64 WorstYear float64 MaxDrawdown float64 SharpeRatio float64 Return *Return }
PerformanceResult contains the historic performance of a portfolio
func NewPerformanceResult ¶
func NewPerformanceResult() *PerformanceResult
NewPerformanceResult creates a new historic performance result of a portfolio
type Portfolio ¶
type Portfolio struct { Name string CostBasis float64 Symbols []string Holdings map[string]*Holding TargetAllocation map[string]float64 Status *Status Performance *Performance }
Portfolio defines a portfolio of asset holdings
func NewPortfolio ¶
func NewPortfolio() *Portfolio
NewPortfolio returns an empty portfolio of asset holdings
func (*Portfolio) Refresh ¶
Refresh computes the current status of the entire portfolio and its holdings
func (*Portfolio) RefreshStatus ¶
func (portfolio *Portfolio) RefreshStatus()
RefreshStatus computes the current status of the entire portfolio
type Profile ¶
type Profile struct { Name string Cash float64 CostBasis float64 Market *Market Portfolios []*Portfolio TargetAllocation map[string]float64 MergedPortfolio *Portfolio Status *ProfileStatus }
Profile contains multiple portfolios
func (*Profile) Refresh ¶
Refresh computes the current status of the entire profile and its portfolios
func (*Profile) RefreshStatus ¶
func (profile *Profile) RefreshStatus()
RefreshStatus computes the current status of the entire profile
type ProfileStatus ¶
type ProfileStatus struct { Value float64 RegularMarketChange float64 RegularMarketChangePercent float64 Unrealized float64 UnrealizedPercent float64 Allocation map[string]float64 }
ProfileStatus defines the real-time status of the entire portfolio