Documentation
¶
Overview ¶
CoinMetrics client for BTC on-chain valuation.
Community API exposes CapMVRVCur and CapMrktCurUSD for BTC. CapRealUSD may require paid access, so the client computes realized cap as market cap / MVRV when direct CapRealUSD is unavailable. This still keeps the realized-cap source auditable because CapMVRVCur is CoinMetrics' own realized-cap ratio.
FRED (St. Louis Fed) macro data fetcher for guanfu.
拉 7 个序列:
- DTWEXBGS: Trade-Weighted USD Index (Broad),daily — DXY 代理
- DFII10: 10-Year TIPS 收益率,daily
- M2SL: M2 货币供应(季调),monthly — YoY 同比
- SP500: 标普 500,daily — 与 BTC 做 30d 收益相关
- WALCL: Fed 总资产(每周三),weekly — QT 监控
- RRPONTSYD: 隔夜逆回购(daily),daily — 流动性蓄水池
- WTREGEN: 财政部现金余额(daily),daily — TGA 注水/抽水
Net Liquidity ≈ WALCL - RRPONTSYD - WTREGEN ¶
需要环境变量 FRED_API_KEY。无 key 时 FetchMacroData 返回 nil + nil error, 由 RealClient 决定是否填 placeholder。
Index ¶
- Constants
- func BTCDailyHistoryCachePath(cacheDir string) string
- func FetchAndCacheStock(ctx context.Context, s *store.PriceStore, ticker string, days int) ([]store.PricePoint, error)
- func FetchFearGreedHistory(ctx context.Context) ([]store.PricePoint, error)
- func FetchFutuPricePoints(symbols []string, days int) (map[string][]store.PricePoint, error)
- func FetchGoldIncremental(ctx context.Context, lastDate string) ([]store.PricePoint, error)
- func FetchLondonGoldPricePoints(ctx context.Context) ([]store.PricePoint, error)
- func FormatRefreshTable(results []*RefreshResult) string
- func NeedsIncrementalRefresh(asset string, defaultDays int) int
- func SaveBTCDailyHistoryCache(path string, points []BTCDailyPoint) error
- func StockKey(ticker string) string
- func SyncSnapshotToPriceStore(snap *model.MarketSnapshot)
- func ValidateStockTicker(s *store.PriceStore, ticker string) error
- type BTCDailyPoint
- type BTCSource
- type BinanceKline
- type BinanceOpenInterest
- type BinancePremiumIndex
- type CAPESource
- type CBOEPutCallSource
- type CGFearGreed
- type CGMarketItem
- type CGSimplePrice
- type CMCMarketContextSource
- type CoinbaseBTCSource
- type CrossAssetFutuPrices
- type CrossAssetPrices
- type DataProvider
- type DefillamaStablecoinSource
- type DeribitOptionsData
- type DeribitOptionsSource
- type ETFData
- type ETFFlow
- type ExchangeRateResp
- type FREDSource
- type FutuEquityValuation
- type FutuKLPoint
- type FutuSnapshot
- type GoldSource
- type HashRatePoint
- type MacroData
- type MempoolData
- type MockClient
- type OnchainValuationData
- type RealClient
- type RefreshResult
- type Source
- type StockKeysSource
- type StooqPutCallSource
- type YahooETFSource
Constants ¶
const (
BTCFullHistoryStart = "2010-07-18"
)
const StockNamespacePrefix = "stock_"
StockNamespacePrefix is prepended to lowercase ticker to form the PriceStore key. Exposed for tests and consumers that need to read stock data directly.
Variables ¶
This section is empty.
Functions ¶
func BTCDailyHistoryCachePath ¶
BTCDailyHistoryCachePath returns the on-disk cache path for full BTC daily history. GUANFU_BTC_KLINE_CACHE is intentionally compatible with backtest workflows that want a stable, explicit kline cache.
func FetchAndCacheStock ¶
func FetchAndCacheStock(ctx context.Context, s *store.PriceStore, ticker string, days int) ([]store.PricePoint, error)
FetchAndCacheStock returns daily closes for a ticker from PriceStore (if fresh) or from Yahoo (otherwise), persisting fetched data under the namespaced key "stock_<ticker>".
days controls the requested history window when fetching. Yahoo caps free access at roughly 10y daily, so days >> 3650 falls back to whatever Yahoo returns.
func FetchFearGreedHistory ¶
func FetchFearGreedHistory(ctx context.Context) ([]store.PricePoint, error)
FetchFearGreedHistory fetches the full Fear & Greed index history from alternative.me. The API supports ?limit=0 to get all historical data (2018-02-01 onwards).
func FetchFutuPricePoints ¶
FetchFutuPricePoints fetches daily close prices for multiple Futu symbols and returns them as a map of lowercase-asset-key → oldest-first PricePoint slice. Uses the Python bridge (or direct Go client when available).
func FetchGoldIncremental ¶
FetchGoldIncremental fetches only recent gold data for PriceStore updates.
func FetchLondonGoldPricePoints ¶
func FetchLondonGoldPricePoints(ctx context.Context) ([]store.PricePoint, error)
FetchLondonGoldPricePoints fetches XAU/USD daily price history. Returns oldest-first PricePoint slice. Uses DBnomics LBMA for deep history; falls back to Yahoo XAUUSD=X.
func FormatRefreshTable ¶
func FormatRefreshTable(results []*RefreshResult) string
FormatRefreshTable renders results as a human-readable status table.
func NeedsIncrementalRefresh ¶
NeedsIncrementalRefresh checks the PriceStore to determine if a full fetch is needed or if incremental is sufficient. Returns the recommended fetch days.
func SaveBTCDailyHistoryCache ¶
func SaveBTCDailyHistoryCache(path string, points []BTCDailyPoint) error
func SyncSnapshotToPriceStore ¶
func SyncSnapshotToPriceStore(snap *model.MarketSnapshot)
SyncSnapshotToPriceStore persists the cross-asset price data from a MarketSnapshot into the PriceStore. Called after each successful GetSnapshot run.
func ValidateStockTicker ¶
func ValidateStockTicker(s *store.PriceStore, ticker string) error
ValidateStockTicker rejects empty tickers and tickers that collide with any existing PriceStore key (case-insensitive). Existing keys include core asset prices (btc/qqq/...) and feature data (fred_dxy/vixy/...) — both must be protected from accidental overwrite via import-stock.
Types ¶
type BTCDailyPoint ¶
type BTCDailyPoint struct {
Date string `json:"date"`
Close decimal.Decimal `json:"close"`
Volume decimal.Decimal `json:"volume,omitempty"`
Source string `json:"source,omitempty"`
}
BTCDailyPoint is an oldest-first daily BTC close used by production indicators and backtests. Volume is available only for Binance-covered days.
func LoadBTCDailyHistoryCache ¶
func LoadBTCDailyHistoryCache(path string) ([]BTCDailyPoint, error)
func LoadOrUpdateBTCDailyHistory ¶
func LoadOrUpdateBTCDailyHistory(ctx context.Context, cacheDir string) ([]BTCDailyPoint, error)
LoadOrUpdateBTCDailyHistory loads the persistent BTC daily cache, seeds it from CoinMetrics PriceUSD when needed, and overlays recent Binance candles so the latest daily/intraday close is refreshed on each uncached run.
type BTCSource ¶
type BTCSource struct{}
BTCSource refreshes the canonical BTC daily price archive.
func (BTCSource) DisplayName ¶
func (BTCSource) Refresh ¶
func (BTCSource) Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
type BinanceKline ¶
type BinanceKline []interface{}
BinanceKline: [Open time, Open, High, Low, Close, Volume, ...]
type BinanceOpenInterest ¶
type BinancePremiumIndex ¶
type CAPESource ¶
type CAPESource struct{}
CAPESource refreshes spx_cape via the Python script.
func (CAPESource) DisplayName ¶
func (CAPESource) DisplayName() string
func (CAPESource) Key ¶
func (CAPESource) Key() string
func (CAPESource) Refresh ¶
func (CAPESource) Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
type CBOEPutCallSource ¶
type CBOEPutCallSource struct{}
CBOEPutCallSource fetches CBOE total Put/Call ratio without an API key.
The storage key remains "stooq_putcall" for compatibility with existing forecast features and local archives. New data is sourced directly from CBOE official historical CSVs and Daily Market Statistics pages.
func (CBOEPutCallSource) DisplayName ¶
func (CBOEPutCallSource) DisplayName() string
func (CBOEPutCallSource) Key ¶
func (CBOEPutCallSource) Key() string
func (CBOEPutCallSource) Refresh ¶
func (s CBOEPutCallSource) Refresh(ctx context.Context, ps *store.PriceStore) (*RefreshResult, error)
Refresh uses CBOE historical CSVs for old data and CBOE Daily Market Statistics for recent/current data. CBOE does not expose a documented bulk post-2019 CSV, so first-run refresh limits page scraping to a recent window that is long enough for the 252-observation percentile feature.
type CGFearGreed ¶
type CGMarketItem ¶
type CGSimplePrice ¶
type CMCMarketContextSource ¶
type CMCMarketContextSource struct{}
CMCMarketContextSource pulls a small latest-only market context set from CoinMarketCap. It stores daily snapshots under cmc_* PriceStore keys.
func (CMCMarketContextSource) DisplayName ¶
func (CMCMarketContextSource) DisplayName() string
func (CMCMarketContextSource) Key ¶
func (CMCMarketContextSource) Key() string
func (CMCMarketContextSource) Refresh ¶
func (c CMCMarketContextSource) Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
type CoinbaseBTCSource ¶
type CoinbaseBTCSource struct{}
CoinbaseBTCSource pulls BTC-USD daily close from Coinbase for the premium-vs-Binance signal. Key: coinbase_btc.
func (CoinbaseBTCSource) DisplayName ¶
func (CoinbaseBTCSource) DisplayName() string
func (CoinbaseBTCSource) Key ¶
func (CoinbaseBTCSource) Key() string
func (CoinbaseBTCSource) Refresh ¶
func (c CoinbaseBTCSource) Refresh(ctx context.Context, ps *store.PriceStore) (*RefreshResult, error)
type CrossAssetFutuPrices ¶
type CrossAssetFutuPrices struct {
QQQPrice float64
QQQHistory []float64
QQQPriceAsOf string
SPYPrice float64
SPYHistory []float64
SPYPriceAsOf string
GLDPrice float64 // 实物黄金 ETF
GLDHistory []float64
GLDPriceAsOf string
UUPPrice float64 // 做多美元 ETF (DXY proxy)
UUPHistory []float64
UUPPriceAsOf string
TLTPrice float64 // 20Y+ 美债 ETF
TLTHistory []float64
TLTPriceAsOf string
VIXYPrice float64 // VIX 波动率 ETF
WTIPrice float64 // USO oil ETF proxy
WTIHistory []float64
WTIPriceAsOf string
OilPriceSource string
VIXYHistory []float64
VIXYPriceAsOf string
// New ETFs for Part D 懒人组合
BILPrice float64 // 1-3 Month T-Bill ETF
BILHistory []float64
BILPriceAsOf string
SHYPrice float64 // 1-3 Year Treasury ETF
SHYHistory []float64
SHYPriceAsOf string
BNDPrice float64 // Total Bond Market ETF
BNDHistory []float64
BNDPriceAsOf string
VTIPrice float64 // Total US Stock Market ETF
VTIHistory []float64
VTIPriceAsOf string
Warnings []string
}
CrossAssetFutuPrices holds prices fetched from Futu OpenD
func FetchCrossAssetFromFutu ¶
func FetchCrossAssetFromFutu(days int) (*CrossAssetFutuPrices, error)
FetchCrossAssetFromFutu 从本地富途网关拉取跨资产数据
QQQ, SPY (美股) — 主要对比标的 GLD (黄金ETF) — 补充 PAXG,提供更长历史 UUP (美元ETF) — DXY 实时代理,替代 FRED TLT (长期美债) — 利率/避险情绪 VIXY (波动率ETF) — 传统市场恐慌指数
type CrossAssetPrices ¶
type CrossAssetPrices struct {
// Gold (Binance PAXG — tokenized gold)
GoldPrice float64
GoldHistory []float64
GoldPriceAsOf string
// Gold ETF (Futu GLD — physical gold ETF)
GLDPrice float64
GLDHistory []float64
GLDPriceAsOf string
// US equities (Futu > Yahoo)
QQQPrice float64
QQQHistory []float64
QQQPriceAsOf string
SPYPrice float64
SPYHistory []float64
SPYPriceAsOf string
// DXY proxy (Futu UUP — USD bull ETF)
UUPPrice float64
UUPHistory []float64
UUPPriceAsOf string
// Treasuries (Futu TLT — 20Y+)
TLTPrice float64
TLTHistory []float64
TLTPriceAsOf string
// Volatility (Futu VIXY — VIX ETF)
VIXYPrice float64
VIXYHistory []float64
VIXYPriceAsOf string
// Oil proxy / WTI futures. Source identifies whether the value is USO ETF
// proxy or actual CL=F WTI futures data.
WTIPrice float64
WTIHistory []float64
WTIPriceAsOf string
OilPriceSource string
Warnings []string
}
CrossAssetPrices 跨资产价格数据聚合
func FetchCrossAssetData ¶
func FetchCrossAssetData(ctx context.Context, targetDays int) (*CrossAssetPrices, error)
FetchCrossAssetData 拉取黄金(London Gold > PAXG) + QQQ/SPY/GLD/UUP/VIXY(Futu>Yahoo) 的近期价格和历史。
数据源优先级:
- 黄金: London Gold (PriceStore, 1968+) > Binance PAXG/USDT (tokenized gold, 2019+)
- QQQ/SPY: Futu OpenD (本地网关) > Yahoo Finance (公网备份)
- 油价: Futu USO ETF proxy > Yahoo CL=F WTI futures
环境变量:
FUTU_GATEWAY=127.0.0.1:11111 (默认) FUTU_ENABLED=0 禁用富途,直接用 Yahoo
type DataProvider ¶
type DataProvider interface {
// GetSnapshot 获取指定日期的市场快照
// 如果是当天,则获取实时数据;如果是历史日期,则获取历史数据
GetSnapshot(ctx context.Context) (*model.MarketSnapshot, error)
}
DataProvider 定义数据获取接口
type DefillamaStablecoinSource ¶
type DefillamaStablecoinSource struct{}
DefillamaStablecoinSource pulls the aggregate stablecoin supply (USD) daily history from DefiLlama. Key: defillama_stablecoin_supply.
func (DefillamaStablecoinSource) DisplayName ¶
func (DefillamaStablecoinSource) DisplayName() string
func (DefillamaStablecoinSource) Key ¶
func (DefillamaStablecoinSource) Key() string
func (DefillamaStablecoinSource) Refresh ¶
func (d DefillamaStablecoinSource) Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
Refresh fetches the full DefiLlama chart when the store is empty; otherwise just appends any new points. The endpoint returns the entire series in one call (~1000 rows as of 2026), so incremental is really "re-fetch then dedupe via Save/Append" — cheap enough on this cadence.
type DeribitOptionsData ¶
type DeribitOptionsData struct {
DVOL float64 // current DVOL value
DVOL60dTrendPct float64 // (now / 60d-ago - 1) * 100
DVOLAvailable bool
DVOLAsOf time.Time
DVOLHistory []float64 // up to ~365 daily samples (resolution=86400)
Skew25dNearTermPct float64 // IV(25Δ put) - IV(25Δ call) for nearest-monthly expiry, percentage points
SkewAvailable bool
SkewAsOf time.Time
SkewExpiry string // expiry instrument name used
Warnings []string
}
DeribitOptionsData — DVOL + skew. Available bool tells caller whether to use it.
func FetchBTCDeribitOptions ¶
func FetchBTCDeribitOptions(ctx context.Context) *DeribitOptionsData
FetchBTCDeribitOptions — best-effort. Never returns an error; failures show up as Available=false on individual sub-fields so the caller can keep going.
type DeribitOptionsSource ¶
type DeribitOptionsSource struct{}
DeribitOptionsSource persists BTC option-market context for local history. DVOL is a one-year daily history pull; 25Δ skew is a latest daily snapshot.
func (DeribitOptionsSource) DisplayName ¶
func (DeribitOptionsSource) DisplayName() string
func (DeribitOptionsSource) Key ¶
func (DeribitOptionsSource) Key() string
func (DeribitOptionsSource) Refresh ¶
func (d DeribitOptionsSource) Refresh(ctx context.Context, ps *store.PriceStore) (*RefreshResult, error)
type ETFData ¶
type ETFData struct {
NetInflow7dUSD float64 `json:"net_inflow_7d_usd"`
NetInflow30dUSD float64 `json:"net_inflow_30d_usd"`
NetInflowMA7dUSD float64 `json:"net_inflow_ma7d_usd"` // 7 日均值(vs 30d 比较)
TotalAssetsUSD float64 `json:"total_assets_usd"`
LatestDate time.Time `json:"-"`
StaleDays int `json:"-"` // 距今天数(>=2 警告)
}
ETFData 整理后的 ETF 数据汇总
type ETFFlow ¶
type ETFFlow struct {
Date time.Time
NetInflowUSD float64
TotalAssetsUSD float64
CumulativeUSD float64
}
ETFFlow 单日 ETF 数据
type ExchangeRateResp ¶
type FREDSource ¶
type FREDSource struct {
StoreKey string // e.g. "fred_dxy"
Series string // e.g. "DTWEXBGS"
Description string
StartDate string // YYYY-MM-DD floor for full pull (FRED returns from this date)
}
FREDSource maps one FRED series ID → one PriceStore key.
func DefaultFREDSources ¶
func DefaultFREDSources() []*FREDSource
DefaultFREDSources lists every fred_* series referenced by current extractors. Adding a new series here automatically wires it into refresh.
func (*FREDSource) DisplayName ¶
func (f *FREDSource) DisplayName() string
func (*FREDSource) Key ¶
func (f *FREDSource) Key() string
func (*FREDSource) Refresh ¶
func (f *FREDSource) Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
Refresh fetches the gap between PriceStore last_date and today from FRED. On full import, walks back to f.StartDate.
type FutuEquityValuation ¶
FutuEquityValuation holds PE/PB for QQQ and SPY from Futu snapshot.
func FetchEquityValuationFromFutu ¶
func FetchEquityValuationFromFutu() (*FutuEquityValuation, error)
FetchEquityValuationFromFutu fetches QQQ and SPY PE/PB via Qot_GetSecuritySnapshot. Falls back to Python bridge when direct Go connection fails.
type FutuKLPoint ¶
type FutuKLPoint struct {
Time time.Time
Open float64
High float64
Low float64
Close float64
Volume float64
}
FutuKLPoint 单根 K 线
type FutuSnapshot ¶
FutuSnapshot holds basic fundamental data from Qot_GetSecuritySnapshot.
type GoldSource ¶
type GoldSource struct{}
GoldSource refreshes London Gold via DBnomics (full) + Yahoo (incremental).
func (GoldSource) DisplayName ¶
func (GoldSource) DisplayName() string
func (GoldSource) Key ¶
func (GoldSource) Key() string
func (GoldSource) Refresh ¶
func (GoldSource) Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
type HashRatePoint ¶
HashRatePoint 单点哈希率
type MacroData ¶
type MacroData struct {
DXY60dTrendPct float64
DXYLatest float64
DXYAsOf string
RealYield10YPct float64
RealYield10YAsOf string
M2YoYPct float64
M2LatestB float64
M2AsOf string
SPXCorrelation30d float64
SPXAsOf string
HYSpreadBps float64
HYSpreadAsOf string
YieldCurve10Y2YBps float64
YieldCurveAsOf string
// US Liquidity (Priority: Fed assets, RRP, TGA)
FedAssetsB float64 // WALCL: Fed total assets (millions USD), converted to billions
FedAssetsAsOf string
RRPB float64 // RRPONTSYD: ON reverse repo (billions USD)
RRPAsOf string
TGA_B float64 // WTREGEN: Treasury General Account (billions USD)
TGAAsOf string
NetLiquidityB float64 // FedAssets - RRP - TGA (billions)
// 60d trends
FedAssets60dTrendPct float64
RRP60dTrendPct float64
TGA60dTrendPct float64
NetLiq60dTrendPct float64
StaleWarnings []string
}
MacroData FRED 衍生指标 + 时效性
type MempoolData ¶
type MempoolData struct {
HashRate3yEHs []HashRatePoint `json:"-"` // 3 年哈希率序列(用于 hash ribbons 计算)
HashRateNowEHs float64 `json:"hash_rate_now_ehs"` // 当前哈希率(EH/s)
HashRibbons30vs60 string `json:"hash_ribbons"` // "上行" / "下行" / "交叉中"
DifficultyChangePct float64 `json:"difficulty_change_pct"`
MempoolMB float64 `json:"mempool_mb"`
MempoolCount int `json:"mempool_count"`
AsOf time.Time `json:"-"`
Warnings []string `json:"-"`
}
MempoolData 网络数据汇总
func FetchMempoolData ¶
func FetchMempoolData(ctx context.Context) (*MempoolData, error)
FetchMempoolData 一次性拉取 mempool.space 三个端点
type MockClient ¶
type MockClient struct{}
func NewMockClient ¶
func NewMockClient() *MockClient
func (*MockClient) GetSnapshot ¶
func (m *MockClient) GetSnapshot(ctx context.Context) (*model.MarketSnapshot, error)
type OnchainValuationData ¶
type OnchainValuationData struct {
MVRV float64
MVRVZScore float64
NUPL float64
MVRVQuantile float64
NUPLQuantile float64
MarketCapUSD float64
RealizedCapUSD float64
RealizedCapMode string
LatestDate time.Time
StaleDays int
Warnings []string
}
func FetchBTCOnchainValuation ¶
func FetchBTCOnchainValuation(ctx context.Context) (*OnchainValuationData, error)
type RealClient ¶
type RealClient struct {
// contains filtered or unexported fields
}
func (*RealClient) GetSnapshot ¶
func (c *RealClient) GetSnapshot(ctx context.Context) (*model.MarketSnapshot, error)
type RefreshResult ¶
type RefreshResult struct {
Key string `json:"key"`
DisplayName string `json:"display_name"`
Mode string `json:"mode"` // "skip" | "full" | "incremental" | "fail"
SkipReason string `json:"skip_reason,omitempty"` // fresh | config | no_new_data | not_applicable
Stale bool `json:"stale,omitempty"`
Action string `json:"action,omitempty"` // ignore | configure | refresh | investigate
Impact string `json:"impact,omitempty"` // forecast | market_reading | both | optional
Added int `json:"added"`
Total int `json:"total"`
LastDate string `json:"last_date"`
Duration string `json:"duration"`
Error string `json:"error,omitempty"`
}
RefreshResult summarizes what happened for one source.
func RefreshAll ¶
func RefreshAll(ctx context.Context, s *store.PriceStore, sources []Source) []*RefreshResult
RefreshAll runs every source sequentially and returns per-source results. Sequential is intentional — most sources hit external APIs with their own rate limits, and serial output is easier to debug than interleaved. A failing source does not stop the loop; its error is captured in the result and the next source runs.
type Source ¶
type Source interface {
Key() string
DisplayName() string
Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
}
Source describes a single dataset that can be refreshed.
type StockKeysSource ¶
type StockKeysSource struct{}
StockKeysSource refreshes every previously-imported stock_<ticker> key. Iterates s.ListAssets() looking for the StockNamespacePrefix.
func (StockKeysSource) DisplayName ¶
func (StockKeysSource) DisplayName() string
func (StockKeysSource) Key ¶
func (StockKeysSource) Key() string
func (StockKeysSource) Refresh ¶
func (StockKeysSource) Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
type StooqPutCallSource ¶
type StooqPutCallSource struct{}
StooqPutCallSource fetches CBOE total Put/Call ratio daily history from Stooq. It is not part of the default refresh source list; prefer CBOEPutCallSource for no-key official CBOE data.
func (StooqPutCallSource) DisplayName ¶
func (StooqPutCallSource) DisplayName() string
func (StooqPutCallSource) Key ¶
func (StooqPutCallSource) Key() string
func (StooqPutCallSource) Refresh ¶
func (s StooqPutCallSource) Refresh(ctx context.Context, ps *store.PriceStore) (*RefreshResult, error)
Refresh fetches the full Stooq CSV when store is empty; appends otherwise. Stooq returns the full history in one call (~5000 rows), so the cost difference between full and incremental is negligible — we re-fetch and dedupe via Save/Append.
type YahooETFSource ¶
type YahooETFSource struct {
StoreKey string // e.g. "qqq" / "spy" / "vixy"
Symbol string // Yahoo symbol, e.g. "QQQ" / "VIXY" / "GC=F"
FullDays int // history window for the first full pull (~10y)
Note string // human description for status output
}
YahooETFSource refreshes one ETF / index from Yahoo into a bare PriceStore key.
func DefaultYahooETFSources ¶
func DefaultYahooETFSources() []*YahooETFSource
DefaultYahooETFSources covers everything currently used in extractors or panels that hits Yahoo (QQQ/SPY price + cross-asset proxies).
Gold is intentionally excluded — gold.go has DBnomics+Yahoo merge logic that handles 1968+ history; YahooETFSource would lose the DBnomics window.
func (*YahooETFSource) DisplayName ¶
func (y *YahooETFSource) DisplayName() string
func (*YahooETFSource) Key ¶
func (y *YahooETFSource) Key() string
func (*YahooETFSource) Refresh ¶
func (y *YahooETFSource) Refresh(ctx context.Context, s *store.PriceStore) (*RefreshResult, error)
Refresh fetches the gap between PriceStore last_date and today. Strategy:
- empty / no data → full pull (FullDays)
- stale → fetch (daysSince + 5) buffer days, Append (Save dedups)
- fresh → skip
Source Files
¶
- btc_history.go
- cape_history.go
- cboe_putcall.go
- client.go
- cmc.go
- coinbase_btc.go
- coinmetrics.go
- cross_asset.go
- defillama_stablecoin.go
- deribit.go
- etf.go
- fetch_stock.go
- fred.go
- fred_history.go
- futu.go
- futu_bridge.go
- futu_store.go
- gold.go
- mempool.go
- mock.go
- real.go
- refresh.go
- refresh_native.go
- stooq_putcall.go
- store_integration.go
- yahoo.go
- yahoo_history.go