Documentation
¶
Index ¶
- Constants
- func FetchAndSaveNew(dataDir string) error
- type Client
- func (c *Client) FetchAndUpdate() error
- func (c *Client) GetByName(name string) (*Company, error)
- func (c *Client) GetBySymbol(symbol string) (*Company, error)
- func (c *Client) GetCustomTranslation(thaiText, transType string) (string, bool)
- func (c *Client) GetSETData() *SETData
- func (c *Client) IsThaiName(name string) bool
- func (c *Client) LogUntranslated(thaiText, transType, fundID string)
- func (c *Client) NeedsUpdate() bool
- func (c *Client) SetCustomTranslation(thaiText, englishText, transType string, verified bool)
- func (c *Client) TranslateIndustry(thaiIndustry string) string
- func (c *Client) TranslateName(thaiName string) string
- func (c *Client) TranslateSector(thaiSector string) string
- func (c *Client) TranslateWithFallback(thaiText, transType, fundID string) string
- type Company
- type CustomTranslations
- type Industry
- type SETData
- type SETMappings
- type SETMetadata
- type Sector
- type Translation
- type UntranslatedEntry
Constants ¶
const ( SETURLEN = "https://www.set.or.th/dat/eod/listedcompany/static/listedCompanies_en_US.xls" SETURLTH = "https://www.set.or.th/dat/eod/listedcompany/static/listedCompanies_th_TH.xls" )
Variables ¶
This section is empty.
Functions ¶
func FetchAndSaveNew ¶
FetchAndSaveNew fetches SET data from the website and saves to the given data directory This is a standalone function to handle the case where no existing data exists
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides SET data lookup and translation services
func (*Client) FetchAndUpdate ¶
FetchAndUpdate downloads latest SET data from official SET website Returns error on failure but existing data remains usable
func (*Client) GetBySymbol ¶
GetBySymbol looks up a company by its ticker symbol
func (*Client) GetCustomTranslation ¶
GetCustomTranslation looks up a custom translation
func (*Client) GetSETData ¶
GetSETData returns the raw SET data (for advanced use cases)
func (*Client) IsThaiName ¶
IsThaiName checks if a string contains Thai characters
func (*Client) LogUntranslated ¶
LogUntranslated records an item that couldn't be translated
func (*Client) NeedsUpdate ¶
NeedsUpdate checks if SET data needs to be updated based on last update timestamp Returns true if data is older than 30 days or has never been updated
func (*Client) SetCustomTranslation ¶
SetCustomTranslation adds or updates a custom translation
func (*Client) TranslateIndustry ¶
TranslateIndustry translates a Thai industry name to English
func (*Client) TranslateName ¶
TranslateName translates a Thai company name to English
func (*Client) TranslateSector ¶
TranslateSector translates a Thai sector name to English
func (*Client) TranslateWithFallback ¶
TranslateWithFallback attempts translation using multiple sources: 1. Custom translations (user-defined) 2. Hardcoded Finnomena mappings 3. SET data (official Stock Exchange of Thailand) 4. Returns original if no translation found
type Company ¶
type Company struct {
NameEN string `json:"name_en"`
NameTH string `json:"name_th"`
Market string `json:"market"`
IndustryID string `json:"industry_id"`
SectorID string `json:"sector_id"`
}
Company represents a SET-listed company
type CustomTranslations ¶
type CustomTranslations struct {
Version int `json:"version"`
Sectors map[string]Translation `json:"sectors"`
Industries map[string]Translation `json:"industries"`
Companies map[string]Translation `json:"companies"`
Untranslated []UntranslatedEntry `json:"untranslated_log,omitempty"`
}
CustomTranslations stores user-defined translations
type SETData ¶
type SETData struct {
Companies map[string]Company `json:"companies"`
Industries map[string]Industry `json:"industries"`
Sectors map[string]Sector `json:"sectors"`
Metadata SETMetadata `json:"metadata,omitempty"`
}
SETData contains the complete SET exchange data
type SETMappings ¶
type SETMetadata ¶
type SETMetadata struct {
LastUpdate string `json:"last_update"`
SourceURLEN string `json:"source_url_en,omitempty"`
SourceURLTH string `json:"source_url_th,omitempty"`
RecordCount int `json:"record_count"`
}
SETMetadata contains metadata about the SET data source
type Translation ¶
type Translation struct {
EN string `json:"en"`
Verified bool `json:"verified"`
Date string `json:"date"`
}
Translation represents a single translation entry