exclude mutual funds from any server fetch - they do not have earnings
All checks were successful
Generic zig build / build (push) Successful in 27s

This commit is contained in:
Emil Lerch 2026-03-11 11:45:34 -07:00
parent e6ff204a54
commit 31ae11cec0
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -325,6 +325,11 @@ pub const DataService = struct {
/// Smart refresh: even if cache is fresh, re-fetches when a past earnings /// Smart refresh: even if cache is fresh, re-fetches when a past earnings
/// date has no actual results yet (i.e. results just came out). /// date has no actual results yet (i.e. results just came out).
pub fn getEarnings(self: *DataService, symbol: []const u8) DataError!FetchResult(EarningsEvent) { pub fn getEarnings(self: *DataService, symbol: []const u8) DataError!FetchResult(EarningsEvent) {
// Mutual funds (5-letter tickers ending in X) don't have quarterly earnings.
if (isMutualFund(symbol)) {
return .{ .data = &.{}, .source = .cached, .timestamp = std.time.timestamp() };
}
var s = self.store(); var s = self.store();
const today = fmt.todayDate(); const today = fmt.todayDate();
@ -715,4 +720,10 @@ pub const DataService = struct {
std.Thread.sleep(10 * std.time.ns_per_s); std.Thread.sleep(10 * std.time.ns_per_s);
} }
} }
/// Mutual funds use 5-letter tickers ending in X (e.g. FDSCX, VSTCX, FAGIX).
/// These don't have quarterly earnings on Finnhub.
fn isMutualFund(symbol: []const u8) bool {
return symbol.len == 5 and symbol[4] == 'X';
}
}; };