avoid fetching entity facts for etfs
This commit is contained in:
parent
be48f612c5
commit
f3c16907df
2 changed files with 26 additions and 20 deletions
|
|
@ -14,8 +14,8 @@
|
||||||
.hash = "httpz-0.0.0-PNVzrLjJCAD37S0CcrXpsjSqr86hVjK0rsALTDJ98AAJ",
|
.hash = "httpz-0.0.0-PNVzrLjJCAD37S0CcrXpsjSqr86hVjK0rsALTDJ98AAJ",
|
||||||
},
|
},
|
||||||
.zfin = .{
|
.zfin = .{
|
||||||
.url = "git+https://git.lerch.org/lobo/zfin#b796a46699cf9ace2611f768c159bbf3d842c048",
|
.url = "git+https://git.lerch.org/lobo/zfin#d7a86cd63901e8c823bdeedd548e5beb9759ea9c",
|
||||||
.hash = "zfin-0.0.0-J-B21lwDPABENCoGdpzMLkYXuhl8zf79td0gWhpsg9zF",
|
.hash = "zfin-0.0.0-J-B21qcGPABbosCyx3cN-gMOFEN1ZbqrRZpS6WUQtLzC",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
42
src/main.zig
42
src/main.zig
|
|
@ -681,12 +681,13 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
|
||||||
sym_ok = false;
|
sym_ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Classification (Wikidata). Captures CIK if Wikidata
|
// Classification (Wikidata + EDGAR fallback). Captures
|
||||||
// had it — used to chain into entity_facts below.
|
// CIK and is_etf — used to chain into entity_facts below.
|
||||||
// NotFound is logged as `n/a` (symbol genuinely has no
|
// NotFound is logged as `n/a` (symbol genuinely has no
|
||||||
// Wikidata entry) and doesn't flip sym_ok.
|
// Wikidata or EDGAR entry) and doesn't flip sym_ok.
|
||||||
var cik_buf: ?[]u8 = null;
|
var cik_buf: ?[]u8 = null;
|
||||||
defer if (cik_buf) |b| allocator.free(b);
|
defer if (cik_buf) |b| allocator.free(b);
|
||||||
|
var is_etf = false;
|
||||||
try printRateLimitWait(&svc, .classification, stdout);
|
try printRateLimitWait(&svc, .classification, stdout);
|
||||||
if (svc.getClassification(sym, .{})) |result| {
|
if (svc.getClassification(sym, .{})) |result| {
|
||||||
defer result.deinit();
|
defer result.deinit();
|
||||||
|
|
@ -694,6 +695,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
|
||||||
if (result.data[0].cik) |cik| {
|
if (result.data[0].cik) |cik| {
|
||||||
cik_buf = allocator.dupe(u8, cik) catch null;
|
cik_buf = allocator.dupe(u8, cik) catch null;
|
||||||
}
|
}
|
||||||
|
is_etf = result.data[0].is_etf;
|
||||||
}
|
}
|
||||||
try stdout.print(", classification ok ({s})", .{@tagName(result.source)});
|
try stdout.print(", classification ok ({s})", .{@tagName(result.source)});
|
||||||
} else |err| switch (err) {
|
} else |err| switch (err) {
|
||||||
|
|
@ -721,22 +723,26 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entity facts (XBRL). Only attempted when the
|
// Entity facts (XBRL). Only attempted when the
|
||||||
// classification step yielded a CIK — funds without
|
// classification step yielded a CIK from a non-fund
|
||||||
// Wikidata entries don't reach here even though they
|
// record. ETFs/funds CIKs (iShares Trust, Fidelity series
|
||||||
// have an EDGAR CIK from the ticker map (production
|
// CIKs, etc.) don't file the operating-company XBRL
|
||||||
// zfin chains entity_facts off Wikidata's CIK, so the
|
// concepts entity_facts looks for; calling EDGAR for
|
||||||
// server warms the cache the same way).
|
// them is guaranteed-404 noise. Skip them up front.
|
||||||
if (cik_buf) |cik| {
|
if (cik_buf) |cik| {
|
||||||
try printRateLimitWait(&svc, .entity_facts, stdout);
|
if (is_etf) {
|
||||||
if (svc.getEntityFacts(cik, .{})) |result| {
|
try stdout.print(", entity_facts n/a (ETF)", .{});
|
||||||
defer result.deinit();
|
} else {
|
||||||
try stdout.print(", entity_facts ok ({s})", .{@tagName(result.source)});
|
try printRateLimitWait(&svc, .entity_facts, stdout);
|
||||||
} else |err| switch (err) {
|
if (svc.getEntityFacts(cik, .{})) |result| {
|
||||||
zfin.DataError.NotFound => try stdout.print(", entity_facts n/a", .{}),
|
defer result.deinit();
|
||||||
else => {
|
try stdout.print(", entity_facts ok ({s})", .{@tagName(result.source)});
|
||||||
try stdout.print(", entity_facts FAILED ({t})", .{err});
|
} else |err| switch (err) {
|
||||||
sym_ok = false;
|
zfin.DataError.NotFound => try stdout.print(", entity_facts n/a", .{}),
|
||||||
},
|
else => {
|
||||||
|
try stdout.print(", entity_facts FAILED ({t})", .{err});
|
||||||
|
sym_ok = false;
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue