Documentation
¶
Index ¶
- Constants
- Variables
- func CreateETF(db *sqlx.DB, etf *ETF) error
- func CreateExchange(db *sqlx.DB, exchange *Exchange) error
- func CreateReit(db *sqlx.DB, reit *REIT) error
- func CreateStock(db *sqlx.DB, stock *Security) (err error)
- func GetSecurityTargetGapPercentage(db *sqlx.DB, input string) (float64, error)
- func InsertDividend(tx *sqlx.Tx, dividend *Dividend) error
- func InsertSecurity(tx *sqlx.Tx, security *Security) error
- func IsSecuritiesTableEmpty(db *sqlx.DB) (bool, error)
- func SecurityExists(db *sqlx.DB, ticker string, exchange string) bool
- func UpdateDividend(tx *sqlx.Tx, dividend *Dividend) error
- func UpdateETF(db *sqlx.DB, etf *ETF) error
- func UpdateREIT(db *sqlx.DB, reit *REIT) error
- func UpdateSecurity(tx *sqlx.Tx, security *Security) error
- func UpdateStock(db *sqlx.DB, stock *Security) (err error)
- func ValidateBigIntRange(min, max *string, minout, maxout *int64) error
- func ValidateIntRange(min, max *float64, minout, maxout *int) error
- type BrowserManager
- type CalcInput
- type Dividend
- type DividendHistoryScrap
- type ETF
- type Exchange
- type Frequency
- type JSONErrorResponse
- type NullableInt
- type NullableString
- type NullableTime
- type REIT
- type SEO
- type SecParams
- type SecParamsPointers
- type Security
- type SecuritySearchView
- type SecurityVars
- type SeekingAlphaScrap
- type SelectedSecurityView
- type Site
- type Timing
Constants ¶
View Source
const ( TimingFWD Timing = "fwd" TimingTTM Timing = "ttm" FrequencyUnknown Frequency = "unknown" FrequencyWeekly Frequency = "weekly" FrequencyBiweekly Frequency = "biweekly" FrequencyMonthly Frequency = "monthly" FrequencyQuarterly Frequency = "quarterly" FrequencySemi Frequency = "semi-annual" FrequencyYearly Frequency = "annual" )
Variables ¶
View Source
var ( ValidOrderColumns = map[string]bool{ "price": true, "consensus": true, "score": true, "coverage": true, "marketcap": true, "volume": true, "avgvolume": true, "outstanding": true, "beta": true, "eps": true, "pe": true, "yield": true, "payout": true, "holdings": true, "aum": true, "expense": true, "nav": true, "inception": true, "pc": true, "ppc": true, "updated": true, } ValidAscValues = map[string]bool{ "asc": true, "desc": true, } )
Possible valid values for Order and Asc fields
Functions ¶
func ValidateBigIntRange ¶
func ValidateIntRange ¶
Types ¶
type BrowserManager ¶
type BrowserManager struct {
// contains filtered or unexported fields
}
func NewBrowserManager ¶
func NewBrowserManager(maxRequests int) *BrowserManager
func (*BrowserManager) Close ¶
func (bm *BrowserManager) Close()
func (*BrowserManager) GetBrowser ¶
func (bm *BrowserManager) GetBrowser() *rod.Browser
📌 Get a browser instance for scraping
func (*BrowserManager) MonitorBrowserHealth ¶
func (bm *BrowserManager) MonitorBrowserHealth()
func (*BrowserManager) MonitorMemory ¶
func (bm *BrowserManager) MonitorMemory()
🚀 Restart Chrome if memory usage exceeds 70%
func (*BrowserManager) ReleaseBrowser ¶
func (bm *BrowserManager) ReleaseBrowser()
📌 Called when a scraper finishes using the browser
func (*BrowserManager) RestartBrowserSafely ¶
func (bm *BrowserManager) RestartBrowserSafely()
🚀 Safe Restart with Backup Browser
type CalcInput ¶
type CalcInput struct {
SID string `form:"sid"`
Rate float64 `form:"rate"`
CompundingFrequency string `form:"compoundingfrequency"`
Principal float64 `form:"principal"`
Currency string `form:"currency"`
ContribFrequency string `form:"contribfrequency"`
Contribution float64 `form:"contribution"`
PriceMod float64 `form:"pricemod"`
YieldMod float64 `form:"yieldmod"`
Years int `form:"years"`
}
type Dividend ¶
type Dividend struct {
Ticker string `db:"ticker" json:"ticker,omitempty"`
Exchange string `db:"exchange" json:"exchange,omitempty"`
Yield int `db:"yield" json:"yield"`
AnnualPayout NullableInt `db:"ap" json:"annualPayout,omitempty"`
Timing NullableString `db:"tm" json:"timing,omitempty"` // Enum: fwd, ttm
PayoutRatio NullableInt `db:"pr" json:"payoutRatio,omitempty"`
GrowthRate NullableInt `db:"lgr" json:"growthRate,omitempty"`
YearsGrowth NullableInt `db:"yog" json:"yearsGrowth,omitempty"`
LastAnnounced NullableInt `db:"lad" json:"lastAnnounced,omitempty"`
Frequency NullableString `db:"frequency" json:"frequency,omitempty"` // Enum: Frequency
ExDivDate NullableTime `db:"edd" json:"exDivDate,omitempty"`
PayoutDate NullableTime `db:"pd" json:"payoutDate,omitempty"`
}
Dividend represents a row from the dividends table.
func (*Dividend) PrettyPrintString ¶
type DividendHistoryScrap ¶
type ETF ¶
type ETF struct {
Security `json:"security"` // Embedded security properties
Holdings int `db:"holdings" json:"holdings"`
Family string `db:"family" json:"family"`
AUM NullableInt `db:"aum" json:"aum,omitempty"`
ExpenseRatio NullableInt `db:"er" json:"expenseRatio,omitempty"`
NAV NullableInt `db:"nav" json:"nav,omitempty"`
InceptionDate NullableTime `db:"inception" json:"inception,omitempty"`
RelatedSecurities []string `json:"relatedSecurities"` // Related securities as "TICKER:EXCHANGE:ALLOCATION"
}
ETF represents a row from the etfs table.
func (*ETF) PrettyPrintString ¶
type Exchange ¶
type Exchange struct {
Title string `db:"title" json:"title"`
Fullname string `db:"fullname" json:"fullname"`
Prefix NullableString `db:"prefix" json:"prefix,omitempty"`
Suffix NullableString `db:"suffix" json:"suffix,omitempty"`
CC string `db:"cc" json:"countryCode"`
OpenTime NullableTime `db:"opentime" json:"openTime,omitempty"`
CloseTime NullableTime `db:"closetime" json:"closeTime,omitempty"`
}
type JSONErrorResponse ¶
type JSONErrorResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Error string `json:"error"`
}
func PlaceholderGet ¶
func PlaceholderGet() (JSONErrorResponse, error)
type NullableInt ¶
func (NullableInt) MarshalJSON ¶
func (ni NullableInt) MarshalJSON() ([]byte, error)
Implement json.Marshaler for NullableInt
func (*NullableInt) Scan ¶
func (ni *NullableInt) Scan(value any) error
Implement sql.Scanner for NullableInt
type NullableString ¶
type NullableString sql.NullString
func (NullableString) MarshalJSON ¶
func (ns NullableString) MarshalJSON() ([]byte, error)
Implement json.Marshaler for NullableString
func (*NullableString) Scan ¶
func (ns *NullableString) Scan(value any) error
Implement sql.Scanner for NullableString
type NullableTime ¶
func (NullableTime) MarshalJSON ¶
func (nt NullableTime) MarshalJSON() ([]byte, error)
func (*NullableTime) Scan ¶
func (nt *NullableTime) Scan(value any) error
Implement sql.Scanner for NullableTime
type REIT ¶
type REIT struct {
Security `json:"security"` // Embedded security properties
Occupation NullableInt `db:"occupation" json:"occupation,omitempty"`
Focus NullableString `db:"focus" json:"focus,omitempty"`
FFO NullableInt `db:"ffo" json:"ffo,omitempty"`
PFFO NullableInt `db:"pffo" json:"pffo,omitempty"`
Timing NullableString `db:"tm" json:"timing,omitempty"` // Enum: fwd, ttm
}
REIT represents a row from the reits table.
type SecParams ¶
type SecParams struct {
Exchange []string `query:"exchange"`
Country []string `query:"country"`
Currency []string `query:"currency"` // New field
MinPrice int `query:"minPrice"`
MaxPrice int `query:"maxPrice"`
Consensus string `query:"consensus"` // New field
MinScore int `query:"minScore"` // New field
MaxScore int `query:"maxScore"` // New field
MinCov int `query:"minCov"` // New field
MaxCov int `query:"maxCov"` // New field
MinCap int64 `query:"minCap"` // New field
MaxCap int64 `query:"maxCap"` // New field
MinVol int64 `query:"minVol"` // New field
MaxVol int64 `query:"maxVol"` // New field
MinOutstanding int64 `query:"minOutstanding"` // New field
MaxOutstanding int64 `query:"maxOutstanding"` // New field
MinBeta int `query:"minBeta"` // New field
MaxBeta int `query:"maxBeta"` // New field
MinEps int `query:"minEps"` // New field
MaxEps int `query:"maxEps"` // New field
MinPe int `query:"minPe"` // New field
MaxPe int `query:"maxPe"` // New field
Dividend bool `query:"dividend"`
MinYield int `query:"minYield"` // New field
MaxYield int `query:"maxYield"` // New field
MinPayoutRatio int `query:"minPayoutRatio"` // New field
MaxPayoutRatio int `query:"maxPayoutRatio"` // New field
Frequency []string `query:"frequency"` // New field
MinHoldings int `query:"minHoldings"` // New field
MaxHoldings int `query:"maxHoldings"` // New field
Family []string `query:"family"` // New field
MinAum int64 `query:"minAum"` // New field
MaxAum int64 `query:"maxAum"` // New field
MinExpenseRatio int `query:"minExpenseRatio"` // New field
MaxExpenseRatio int `query:"maxExpenseRatio"` // New field
MinInception time.Time `query:"minInception"` // New field
MaxInception time.Time `query:"maxInception"` // New field
Order []string `query:"order"`
Asc string `query:"asc"`
Limit int `query:"limit"`
}
type SecParamsPointers ¶
type SecParamsPointers struct {
Exchange *string `query:"exchange"`
Country *string `query:"country"`
Currency *string `query:"currency"` // New field
MinPrice *float64 `query:"minPrice"`
MaxPrice *float64 `query:"maxPrice"`
Consensus *string `query:"consensus"` // New field
MinScore *float64 `query:"minScore"` // New field
MaxScore *float64 `query:"maxScore"` // New field
MinCov *int `query:"minCov"` // New field
MaxCov *int `query:"maxCov"` // New field
MinCap *string `query:"minCap"` // New field
MaxCap *string `query:"maxCap"` // New field
MinVol *string `query:"minVol"` // New field
MaxVol *string `query:"maxVol"` // New field
MinOutstanding *string `query:"minOutstanding"` // New field
MaxOutstanding *string `query:"maxOutstanding"` // New field
MinBeta *float64 `query:"minBeta"` // New field
MaxBeta *float64 `query:"maxBeta"` // New field
MinEps *float64 `query:"minEps"` // New field
MaxEps *float64 `query:"maxEps"` // New field
MinPe *float64 `query:"minPe"` // New field
MaxPe *float64 `query:"maxPe"` // New field
Dividend *bool `query:"dividend"`
MinYield *float64 `query:"minYield"` // New field
MaxYield *float64 `query:"maxYield"` // New field - depends on dividend
MinPayoutRatio *float64 `query:"minPayoutRatio"` // New field - depends on dividend
MaxPayoutRatio *float64 `query:"maxPayoutRatio"` // New field - depends on dividend
Frequency *string `query:"frequency"` // New field - depends on dividend
MinHoldings *float64 `query:"minHoldings"` // New field
MaxHoldings *float64 `query:"maxHoldings"` // New field
Family *string `query:"family"` // New field
MinAum *string `query:"minAum"` // New field
MaxAum *string `query:"maxAum"` // New field
MinExpenseRatio *float64 `query:"minExpenseRatio"` // New field
MaxExpenseRatio *float64 `query:"maxExpenseRatio"` // New field
MinInception *string `query:"minInception"` // New field
MaxInception *string `query:"maxInception"` // New field
Order *string `query:"order"`
Asc *string `query:"asc"`
Limit *int `query:"limit"`
}
func (*SecParamsPointers) Validate ¶
func (p *SecParamsPointers) Validate() (*SecParams, error)
Validate method ensures that all fields are valid and normalizes them
type Security ¶
type Security struct {
Ticker string `db:"ticker" json:"ticker"`
Exchange string `db:"exchange" json:"exchange"`
Typology string `db:"typology" json:"typology"` // STOCK, ETF, REIT
Currency string `db:"currency" json:"currency"`
FullName string `db:"fullname" json:"fullName"`
Sector NullableString `db:"sector" json:"sector,omitempty"`
Industry NullableString `db:"industry" json:"industry,omitempty"`
SubIndustry NullableString `db:"subindustry" json:"subIndustry,omitempty"`
Price int `db:"price" json:"price"`
PC int `db:"pc" json:"pc"`
PCP int `db:"pcp" json:"pcp"`
YearLow int `db:"yrl" json:"yearLow"`
YearHigh int `db:"yrh" json:"yearHigh"`
DayLow int `db:"drl" json:"dayLow"`
DayHigh int `db:"drh" json:"dayHigh"`
Consensus NullableString `db:"consensus" json:"consensus,omitempty"`
Score NullableInt `db:"score" json:"score,omitempty"`
Coverage NullableInt `db:"coverage" json:"coverage,omitempty"`
MarketCap NullableInt `db:"cap" json:"marketCap,omitempty"`
Volume NullableInt `db:"volume" json:"volume,omitempty"`
AvgVolume NullableInt `db:"avgvolume" json:"avgVolume,omitempty"`
Outstanding NullableInt `db:"outstanding" json:"outstanding,omitempty"`
Beta NullableInt `db:"beta" json:"beta,omitempty"`
PClose int `db:"pclose" json:"previousClose"`
COpen int `db:"copen" json:"currentOpen"`
Bid int `db:"bid" json:"bid"`
BidSize NullableInt `db:"bidsz" json:"bidSize,omitempty"`
Ask int `db:"ask" json:"ask"`
AskSize NullableInt `db:"asksz" json:"askSize,omitempty"`
EPS NullableInt `db:"eps" json:"eps,omitempty"`
PE NullableInt `db:"pe" json:"pe,omitempty"`
Target NullableInt `db:"target" json:"target,omitempty"`
STM NullableString `db:"stm" json:"stm,omitempty"` // Enum: fwd, ttm/
Created time.Time `db:"created" json:"created"`
Updated time.Time `db:"updated" json:"updated"`
Dividend *Dividend `db:"-" json:"dividend,omitempty"` // Associated dividend data (if exists)
}
func (*Security) CreatePrettyPrintString ¶
type SecuritySearchView ¶
type SecurityVars ¶
type SecurityVars struct {
Price float64
Currency string
Yield float64
Frequency string
ExpenseRatio float64
PayoutMonth int
}
func GetSecurityVars ¶
func GetSecurityVars(db *sqlx.DB, input string) (*SecurityVars, error)
type SeekingAlphaScrap ¶
type SeekingAlphaScrap struct {
Holdings *int `json:"holdings"`
FFO *int `json:"ffo"`
PFFO *int `json:"pffo"`
REITiming *string `json:"timing"`
Pr *int `json:"pr"`
Lgr *int `json:"lgr"`
Yog *int `json:"yog"`
Lad *int `json:"lad"`
Frequency *string `json:"frequency"`
ExDivDate *time.Time `json:"exDivDate"`
PayoutDate *time.Time `json:"payoutDate"`
}
type SelectedSecurityView ¶
type SelectedSecurityView struct {
Ticker string `json:"ticker"`
Exchange string `json:"exchange"`
Fullname string `json:"fullname"`
Price string `json:"price"`
Typology string `json:"typology"`
Currency string `json:"currency"`
Target string `json:"target"`
Yield string `json:"yield"`
AnnualPayout string `json:"annualPayout"`
PayoutRatio string `json:"payoutRatio"`
Frequency string `json:"frequency"`
Family string `json:"family"`
ExpenseRatio string `json:"expenseRatio"`
ProjectedPriceIncrease string `json:"projectedPriceIncrease"`
ProjectedYieldIncrease string `json:"projectedYieldIncrease"`
}
func GetSecurityView ¶
func GetSecurityView(db *sqlx.DB, tp, input string) (*SelectedSecurityView, error)
type Site ¶
func GetDefaultSite ¶
Click to show internal directories.
Click to hide internal directories.