finnomena

package module
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 9 Imported by: 0

README

finnomena-go

Go Reference Go Report Card

Go client for the Finnomena.com Thai mutual fund API.

Installation

go get github.com/jwitmann/finnomena-go

Quick Start

import (
    "context"
    "time"
    
    finnomena "github.com/jwitmann/finnomena-go"
)

func main() {
    client := finnomena.NewClient()
    
    // Get all funds
    funds, err := client.GetFundsList(context.Background())
    
    // Get historical prices
    from := time.Now().AddDate(-1, 0, 0)
    to := time.Now()
    bars, err := client.GetHistoricalPrices(context.Background(), "FUND-A", "D", from, to)
    
    // Get fund latest NAV
    latest, err := client.GetFundLatest(context.Background(), "F000001")
}

Data Types

All API response types are available in the models subpackage:

import "github.com/jwitmann/finnomena-go/models"

// Direct access to types
var fund models.Fund
var bars models.BarsResponse

Note: The standalone finnomena-models module has been merged into this package. Update your import from github.com/jwitmann/finnomena-models to github.com/jwitmann/finnomena-go/models.

Features

  • All Finnomena API endpoints
  • Context support for cancellation/timeouts
  • Automatic retry with exponential backoff
  • Thai-to-English fee translation
  • Zero external dependencies

Retry Configuration

client := finnomena.NewClient()
client.SetRetryConfig(5, 2*time.Second)

Default: 3 retries with 1s, 2s, 4s exponential backoff.

API Coverage

Fund Data
  • GetFundsList(ctx) - All available funds
  • SearchFund(query) - Find fund by short code or ID
  • GetSymbolInfo(ctx, symbol) - Trading symbol metadata
Historical Prices
  • GetHistoricalPrices(ctx, symbol, resolution, from, to) - OHLCV bars
Fund Information
  • GetFundLatest(ctx, fundID) - Current NAV and change
  • GetFundPerformance(ctx, fundID) - Returns, Sharpe, drawdown
  • GetFundOverview(ctx, fundID) - 3D metrics (PP, RR, DD scores)
  • GetFundFee(ctx, fundID) - Fee structure
  • GetFundPortfolio(ctx, fundID) - Holdings and allocation
  • GetFundVerify(ctx, fundID) - Available data periods
Utility
  • GetServerTime(ctx) - Server timestamp

Fee Translation Example

Thai fund fees are returned in Thai language. Use TranslateFee to convert them to English:

fee, err := client.GetFundFee(context.Background(), "F000001")
if err != nil {
    log.Fatal(err)
}

for i := range fee.Fees {
    finnomena.TranslateFee(&fee.Fees[i], true)
    fmt.Printf("%s: %s %s\n", 
        fee.Fees[i].Description,
        fee.Fees[i].Rate,
        fee.Fees[i].Unit)
}

Disclaimer

This is an unofficial client for the Finnomena.com API. It is not affiliated with or endorsed by Finnomena.

License

MIT License - see LICENSE file for details

Documentation

Index

Constants

View Source
const (
	BaseURL = "https://www.finnomena.com/fn3/api/fund/v2/public"

	// Default retry configuration
	DefaultMaxRetries      = 3
	DefaultRetryDelay      = 1 * time.Second
	RetryBackoffMultiplier = 2
)

Variables

View Source
var FeeDescriptionTranslation = map[string]string{
	"ค่าใช้จ่ายอื่นๆ":                                        "other fee",
	"ค่าธรรมเนียมการขายหน่วยลงทุน (Front-end Fee)":           "purchase fee",
	"ค่าธรรมเนียมการจัดการ":                                  "management fee",
	"ค่าธรรมเนียมการรับซื้อคืนหน่วยลงทุน (Back-end Fee)":     "redemption fee",
	"ค่าธรรมเนียมการสับเปลี่ยนหน่วยลงทุนเข้า (SWITCHING IN)": "switch in fee",
	"ค่าธรรมเนียมการสับเปลี่ยนหน่วยลงทุนออก (SWITCHING OUT)": "switch out fee",
	"ค่าธรรมเนียมและค่าใช้จ่ายรวมทั้งหมด":                    "total expense ratio",
	"ค่าธรรมเนียมการโอนหน่วยลงทุน":                           "unit transfer fee",
	"ค่าธรรมเนียมนายทะเบียนหน่วย":                            "registrar fee",
	"ค่าธรรมเนียมผู้ดูแลผลประโยชน์":                          "trustee fee",
}
View Source
var FeeOtherDescTranslation = map[string]string{
	"บริษัทจัดการอาจเรียกเก็บค่าธรรมเนียมการขายและค่าธรรมเนียมการรับซื้อคืนกับผู้ลงทุนแต่ละกลุ่มไม่เท่ากัน ทั้งนี้ ผู้ลงทุนสามารถดูรายละเอียดเพิ่มเติมได้ที่หนังสือชี้ชวนส่วนข้อมูลกองทุนรวม":                              "The fund management company may charge different sales fees and redemption fees to different investor groups. Investors can find more details in the fund information section of the prospectus.",
	"บริษัทจัดการอาจพิจารณาเปลี่ยนแปลงค่าธรรมเนียมที่เรียกเก็บจริงเพื่อให้สอดคล้องกับกลยุทธ์หรือค่าใช้จ่ายในการบริหารจัดการ และรวมค่าใช้จ่ายเป็นข้อมูลของรอบปีบัญชีล่าสุดหรือประมาณการเบื้องต้น (กรณียังไม่ครบรอบปีบัญชี)": "The management company may consider adjusting the actual fees charged to align with its strategy or management expenses, and include these expenses in the data for the latest accounting year or a preliminary estimate (if the accounting year has not yet ended).",
}
View Source
var FeeUnitTranslation = map[string]string{
	"ต่อปี ของมูลค่าทรัพย์สินสุทธิของกองทุน": "per year of NAV",
	"% ต่อปี": "% per year",
	"บาท":     "baht",
}

Functions

func TranslateFee

func TranslateFee(fee *models.Fee, useEnglish bool)

Types

type Client

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

Client represents the Finnomena API client

func NewClient

func NewClient() *Client

NewClient creates a new Finnomena API client

func NewClientWithRetry

func NewClientWithRetry(maxRetries int, retryDelay time.Duration) *Client

NewClientWithRetry creates a new Finnomena API client with custom retry configuration

func NewClientWithTimeout

func NewClientWithTimeout(timeout time.Duration) *Client

NewClientWithTimeout creates a new Finnomena API client with custom timeout

func (*Client) GetFundDividend added in v1.2.0

func (c *Client) GetFundDividend(fundID string) (*models.FundDividend, error)

GetFundDividend retrieves dividend information for a specific fund

func (*Client) GetFundFee

func (c *Client) GetFundFee(fundID string) (*models.FundFee, error)

GetFundFee retrieves fee information for a specific fund

func (*Client) GetFundLatest

func (c *Client) GetFundLatest(fundID string) (*models.FundLatest, error)

GetFundLatest retrieves the latest data for a specific fund

func (*Client) GetFundOverview

func (c *Client) GetFundOverview(fundID string) (*models.FundOverview, error)

GetFundOverview retrieves overview data for a specific fund

func (*Client) GetFundPerformance

func (c *Client) GetFundPerformance(fundID string) (*models.FundPerformance, error)

GetFundPerformance retrieves performance data for a specific fund

func (*Client) GetFundPortfolio

func (c *Client) GetFundPortfolio(fundID string) (*models.FundPortfolio, error)

func (*Client) GetFundVerify

func (c *Client) GetFundVerify(fundID string) (*models.FundVerify, error)

GetFundVerify retrieves verification data including available periods for a fund

func (*Client) GetFundsList

func (c *Client) GetFundsList() ([]models.Fund, error)

GetFundsList retrieves the list of all available funds

func (*Client) GetHistoricalPrices

func (c *Client) GetHistoricalPrices(symbol, resolution string, from, to time.Time) (*models.BarsResponse, error)

GetHistoricalPrices retrieves historical OHLCV bars for a fund

func (*Client) GetRelatedFunds added in v1.2.0

func (c *Client) GetRelatedFunds(categoryID, period string, excludeFundIDs []string, limit int) (*models.RelatedFundsData, error)

GetRelatedFunds retrieves related funds for a specific category

func (*Client) GetServerTime

func (c *Client) GetServerTime() (int64, error)

GetServerTime retrieves the server time from the API

func (*Client) GetSymbolInfo

func (c *Client) GetSymbolInfo(symbol string) (*models.SymbolInfo, error)

GetSymbolInfo retrieves symbol information for a specific fund

func (*Client) SearchFund

func (c *Client) SearchFund(query string) (*models.Fund, error)

SearchFund searches for a fund by short code or name

func (*Client) SetRetryConfig

func (c *Client) SetRetryConfig(maxRetries int, retryDelay time.Duration)

SetRetryConfig configures the retry behavior for the client

Directories

Path Synopsis
Package models provides data types for the Finnomena.com Thai mutual fund API.
Package models provides data types for the Finnomena.com Thai mutual fund API.

Jump to

Keyboard shortcuts

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