add prev close to cli/tui
This commit is contained in:
parent
b7bb2c85d7
commit
aa8dafa3ab
2 changed files with 9 additions and 0 deletions
|
|
@ -340,6 +340,9 @@ pub fn display(allocator: std.mem.Allocator, candles: []const zfin.Candle, quote
|
||||||
try out.print(" High: ${d:.2}\n", .{high_val});
|
try out.print(" High: ${d:.2}\n", .{high_val});
|
||||||
try out.print(" Low: ${d:.2}\n", .{low_val});
|
try out.print(" Low: ${d:.2}\n", .{low_val});
|
||||||
try out.print(" Volume: {s}\n", .{fmt.fmtIntCommas(&vol_buf, vol_val)});
|
try out.print(" Volume: {s}\n", .{fmt.fmtIntCommas(&vol_buf, vol_val)});
|
||||||
|
if (prev_close > 0) {
|
||||||
|
try out.print(" Prev Close: ${d:.2}\n", .{prev_close});
|
||||||
|
}
|
||||||
|
|
||||||
if (fmt.pctChange(price, prev_close)) |dc| {
|
if (fmt.pctChange(price, prev_close)) |dc| {
|
||||||
var chg_buf: [64]u8 = undefined;
|
var chg_buf: [64]u8 = undefined;
|
||||||
|
|
|
||||||
|
|
@ -668,6 +668,9 @@ fn buildStyledLines(app: *App, arena: std.mem.Allocator) ![]const StyledLine {
|
||||||
if (quote_data) |q| {
|
if (quote_data) |q| {
|
||||||
// No candle data but have a quote - show it
|
// No candle data but have a quote - show it
|
||||||
try lines.append(arena, .{ .text = try std.fmt.allocPrint(arena, " Price: {f}", .{Money.from(q.close)}), .style = th.contentStyle() });
|
try lines.append(arena, .{ .text = try std.fmt.allocPrint(arena, " Price: {f}", .{Money.from(q.close)}), .style = th.contentStyle() });
|
||||||
|
if (q.previous_close > 0) {
|
||||||
|
try lines.append(arena, .{ .text = try std.fmt.allocPrint(arena, " Prev: ${d:.2}", .{q.previous_close}), .style = th.mutedStyle() });
|
||||||
|
}
|
||||||
{
|
{
|
||||||
var chg_buf: [64]u8 = undefined;
|
var chg_buf: [64]u8 = undefined;
|
||||||
const change_style = if (q.change >= 0) th.positiveStyle() else th.negativeStyle();
|
const change_style = if (q.change >= 0) th.positiveStyle() else th.negativeStyle();
|
||||||
|
|
@ -763,6 +766,9 @@ fn buildDetailColumns(
|
||||||
try col1.add(arena, try std.fmt.allocPrint(arena, " High: ${d:.2}", .{if (quote_data) |q| q.high else latest.high}), th.mutedStyle());
|
try col1.add(arena, try std.fmt.allocPrint(arena, " High: ${d:.2}", .{if (quote_data) |q| q.high else latest.high}), th.mutedStyle());
|
||||||
try col1.add(arena, try std.fmt.allocPrint(arena, " Low: ${d:.2}", .{if (quote_data) |q| q.low else latest.low}), th.mutedStyle());
|
try col1.add(arena, try std.fmt.allocPrint(arena, " Low: ${d:.2}", .{if (quote_data) |q| q.low else latest.low}), th.mutedStyle());
|
||||||
try col1.add(arena, try std.fmt.allocPrint(arena, " Volume: {s}", .{fmt.fmtIntCommas(&vol_buf, if (quote_data) |q| q.volume else latest.volume)}), th.mutedStyle());
|
try col1.add(arena, try std.fmt.allocPrint(arena, " Volume: {s}", .{fmt.fmtIntCommas(&vol_buf, if (quote_data) |q| q.volume else latest.volume)}), th.mutedStyle());
|
||||||
|
if (prev_close > 0) {
|
||||||
|
try col1.add(arena, try std.fmt.allocPrint(arena, " Prev: ${d:.2}", .{prev_close}), th.mutedStyle());
|
||||||
|
}
|
||||||
if (fmt.pctChange(price, prev_close)) |dc| {
|
if (fmt.pctChange(price, prev_close)) |dc| {
|
||||||
var chg_buf: [64]u8 = undefined;
|
var chg_buf: [64]u8 = undefined;
|
||||||
const change_style = if (dc.change >= 0) th.positiveStyle() else th.negativeStyle();
|
const change_style = if (dc.change >= 0) th.positiveStyle() else th.negativeStyle();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue