exclude mutual funds from any server fetch - they do not have earnings
All checks were successful
Generic zig build / build (push) Successful in 27s
All checks were successful
Generic zig build / build (push) Successful in 27s
This commit is contained in:
parent
e6ff204a54
commit
31ae11cec0
1 changed files with 11 additions and 0 deletions
|
|
@ -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';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue