use adj_close returns under most circumstances
This commit is contained in:
parent
be48c4a8e3
commit
6a46606f83
2 changed files with 13 additions and 12 deletions
|
|
@ -14,8 +14,8 @@
|
||||||
.hash = "httpz-0.0.0-PNVzrBtMBwAPcQx3mNEgat3Xbsynw-eIC9SmOX5M9XtP",
|
.hash = "httpz-0.0.0-PNVzrBtMBwAPcQx3mNEgat3Xbsynw-eIC9SmOX5M9XtP",
|
||||||
},
|
},
|
||||||
.zfin = .{
|
.zfin = .{
|
||||||
.url = "git+https://git.lerch.org/lobo/zfin#913996072ee06c81121f50657e325ce8a56856e6",
|
.url = "git+https://git.lerch.org/lobo/zfin#5052492ffd49ebdc11b209da1b86bbaf7d365e5e",
|
||||||
.hash = "zfin-0.0.0-J-B21paODADTI5LGofs453BW06vDDK9UZl1LapWa-8eb",
|
.hash = "zfin-0.0.0-J-B21ryaDACsjkyET8s_NhF0W745-Qoc_fj9VM8Z-Ngx",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
src/main.zig
21
src/main.zig
|
|
@ -174,8 +174,9 @@ fn handleReturns(app: *App, req: *httpz.Request, res: *httpz.Response) !void {
|
||||||
const vol_best = v10y orelse v5y orelse v3y orelse v1y;
|
const vol_best = v10y orelse v5y orelse v3y orelse v1y;
|
||||||
const vol_term: ?u8 = if (v10y != null) 10 else if (v5y != null) 5 else if (v3y != null) 3 else if (v1y != null) 1 else null;
|
const vol_term: ?u8 = if (v10y != null) 10 else if (v5y != null) 5 else if (v3y != null) 3 else if (v1y != null) 1 else null;
|
||||||
|
|
||||||
// Total returns with dividend reinvestment (non-fatal if dividends unavailable).
|
// Total returns: adj_close is the primary source (accounts for splits + dividends).
|
||||||
// trailing* fields use total return when available, falling back to price-only.
|
// Dividend-reinvestment is only used as fallback when adj_close returns null
|
||||||
|
// (e.g. candle history too short for stable-NAV funds like money markets).
|
||||||
var t1y: ?f64 = p1y;
|
var t1y: ?f64 = p1y;
|
||||||
var t3y: ?f64 = p3y;
|
var t3y: ?f64 = p3y;
|
||||||
var t5y: ?f64 = p5y;
|
var t5y: ?f64 = p5y;
|
||||||
|
|
@ -184,18 +185,18 @@ fn handleReturns(app: *App, req: *httpz.Request, res: *httpz.Response) !void {
|
||||||
if (app.svc.getDividends(symbol)) |div_result| {
|
if (app.svc.getDividends(symbol)) |div_result| {
|
||||||
defer zfin.Dividend.freeSlice(app.allocator, div_result.data);
|
defer zfin.Dividend.freeSlice(app.allocator, div_result.data);
|
||||||
const total = zfin.performance.trailingReturnsWithDividends(candles, div_result.data);
|
const total = zfin.performance.trailingReturnsWithDividends(candles, div_result.data);
|
||||||
if (total.one_year) |r| {
|
if (t1y == null) if (total.one_year) |r| {
|
||||||
t1y = r.annualized_return;
|
t1y = r.annualized_return;
|
||||||
}
|
};
|
||||||
if (total.three_year) |r| {
|
if (t3y == null) if (total.three_year) |r| {
|
||||||
t3y = r.annualized_return;
|
t3y = r.annualized_return;
|
||||||
}
|
};
|
||||||
if (total.five_year) |r| {
|
if (t5y == null) if (total.five_year) |r| {
|
||||||
t5y = r.annualized_return;
|
t5y = r.annualized_return;
|
||||||
}
|
};
|
||||||
if (total.ten_year) |r| {
|
if (t10y == null) if (total.ten_year) |r| {
|
||||||
t10y = r.annualized_return;
|
t10y = r.annualized_return;
|
||||||
}
|
};
|
||||||
} else |_| {}
|
} else |_| {}
|
||||||
|
|
||||||
// Check if XML requested
|
// Check if XML requested
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue