thesis_forecasting_website / loaders /fundamental_loader.go
tebakaja's picture
deployment
37f31d4
raw
history blame
1.85 kB
package loaders
import (
"os"
"encoding/json"
)
type Fundamental struct {
FontawesomeIcon string `json:"fontawesome_icon"`
Symbol string `json:"symbol"`
SectorID string `json:"sector_id"`
ShortName string `json:"shortName"`
Address string `json:"address"`
Phone string `json:"phone"`
Website string `json:"website"`
MarketCap string `json:"marketCap"`
DividendRate string `json:"dividendRate"`
DividendYield string `json:"dividendYield"`
EarningsGrowth string `json:"earningsGrowth"`
ProfitMargins string `json:"profitMargins"`
GrossMargins string `json:"grossMargins"`
Beta string `json:"beta"`
BookValue string `json:"bookValue"`
PriceToBook string `json:"priceToBook"`
QuickRatio string `json:"quickRatio"`
CurrentRatio string `json:"currentRatio"`
DebtToEquity string `json:"debtToEquity"`
RevenuePerShare string `json:"revenuePerShare"`
RevenueGrowth string `json:"revenueGrowth"`
Ebitda string `json:"ebitda"`
RegularMarketChange string `json:"regularMarketChange"`
PayoutRatio string `json:"payoutRatio"`
TrailingPE string `json:"trailingPE"`
ForwardPE string `json:"forwardPE"`
TrailingEps string `json:"trailingEps"`
ForwardEps string `json:"forwardEps"`
}
type FundamentalsWrapper struct {
Fundamentals Fundamental `json:"fundamentals"`
}
func FundamentalLoader(path string) (*Fundamental, error) {
file, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var data FundamentalsWrapper
if err := json.Unmarshal(file, &data); err != nil {
return nil, err
}
return &data.Fundamentals, nil
}