clean up quote

This commit is contained in:
Emil Lerch 2026-03-20 08:51:49 -07:00
parent ce72985054
commit 35fc9101fd
Signed by: lobo
GPG key ID: A7B62D657EF764F8
3 changed files with 3 additions and 9 deletions

View file

@ -18,7 +18,7 @@ pub fn run(allocator: std.mem.Allocator, svc: *zfin.DataService, symbol: []const
// Fetch candle data for chart and history // Fetch candle data for chart and history
const candle_result = svc.getCandles(symbol) catch |err| switch (err) { const candle_result = svc.getCandles(symbol) catch |err| switch (err) {
zfin.DataError.NoApiKey => { zfin.DataError.NoApiKey => {
try cli.stderrPrint("Error: TWELVEDATA_API_KEY not set.\n"); try cli.stderrPrint("Error: No API key configured for candle data.\n");
return; return;
}, },
else => { else => {
@ -120,7 +120,7 @@ pub fn display(allocator: std.mem.Allocator, candles: []const zfin.Candle, quote
for (candles[start_idx..]) |candle| { for (candles[start_idx..]) |candle| {
var row_buf: [128]u8 = undefined; var row_buf: [128]u8 = undefined;
const day_gain = candle.close >= candle.open; const day_gain = candle.close >= candle.open;
try cli.setGainLoss(out, color, if (day_gain) @as(f64, 1) else @as(f64, -1)); try cli.setGainLoss(out, color, if (day_gain) 1.0 else -1.0);
try out.print("{s}\n", .{fmt.fmtCandleRow(&row_buf, candle)}); try out.print("{s}\n", .{fmt.fmtCandleRow(&row_buf, candle)});
try cli.reset(out, color); try cli.reset(out, color);
} }

View file

@ -1030,7 +1030,7 @@ pub const App = struct {
}, },
.quote, .performance => { .quote, .performance => {
if (self.symbol.len == 0) return; if (self.symbol.len == 0) return;
if (!self.perf_loaded) self.loadPerfData(); if (!self.perf_loaded) perf_tab.loadData(self);
}, },
.earnings => { .earnings => {
if (self.symbol.len == 0) return; if (self.symbol.len == 0) return;
@ -1059,10 +1059,6 @@ pub const App = struct {
portfolio_tab.rebuildPortfolioRows(self); portfolio_tab.rebuildPortfolioRows(self);
} }
pub fn loadPerfData(self: *App) void {
perf_tab.loadData(self);
}
pub fn setStatus(self: *App, msg: []const u8) void { pub fn setStatus(self: *App, msg: []const u8) void {
const len = @min(msg.len, self.status_msg.len); const len = @min(msg.len, self.status_msg.len);
@memcpy(self.status_msg[0..len], msg[0..len]); @memcpy(self.status_msg[0..len], msg[0..len]);

View file

@ -336,8 +336,6 @@ fn buildStyledLines(app: *App, arena: std.mem.Allocator) ![]const StyledLine {
} }
try lines.append(arena, .{ .text = "", .style = th.contentStyle() }); try lines.append(arena, .{ .text = "", .style = th.contentStyle() });
if (app.candles == null and !app.perf_loaded) app.loadPerfData();
// Use stored real-time quote if available (fetched on manual refresh) // Use stored real-time quote if available (fetched on manual refresh)
const quote_data = app.quote; const quote_data = app.quote;