const std = @import("std"); const Date = @import("../Date.zig"); pub const DividendType = enum { regular, special, supplemental, irregular, unknown, }; /// A single dividend payment record. pub const Dividend = struct { /// Date the stock begins trading without the dividend ex_date: Date, /// Date the dividend is paid (may be null if unknown) pay_date: ?Date = null, /// Date of record for eligibility record_date: ?Date = null, /// Cash amount per share amount: f64, /// How many times per year this dividend is expected frequency: ?u8 = null, /// Classification of the dividend type: DividendType = .unknown, /// Currency code (e.g., "USD"). Heap-allocated; freed by deinit(). currency: ?[]const u8 = null, /// Free any owned string fields. pub fn deinit(self: Dividend, allocator: std.mem.Allocator) void { if (self.currency) |c| allocator.free(c); } /// Free a slice of dividends, calling deinit on each element first. pub fn freeSlice(allocator: std.mem.Allocator, divs: []const Dividend) void { for (divs) |d| d.deinit(allocator); allocator.free(divs); } };