remove unused fromString on portfolio
This commit is contained in:
parent
34d37e32a8
commit
18f4f00516
1 changed files with 1 additions and 23 deletions
|
|
@ -249,26 +249,12 @@ pub const LotType = enum {
|
|||
.watch => "Watch",
|
||||
};
|
||||
}
|
||||
|
||||
pub fn fromString(s: []const u8) LotType {
|
||||
if (std.mem.eql(u8, s, "option")) return .option;
|
||||
if (std.mem.eql(u8, s, "cd")) return .cd;
|
||||
if (std.mem.eql(u8, s, "cash")) return .cash;
|
||||
if (std.mem.eql(u8, s, "illiquid")) return .illiquid;
|
||||
if (std.mem.eql(u8, s, "watch")) return .watch;
|
||||
return .stock;
|
||||
}
|
||||
};
|
||||
|
||||
/// Call or put option type.
|
||||
pub const OptionType = enum {
|
||||
call,
|
||||
put,
|
||||
|
||||
pub fn fromString(s: []const u8) OptionType {
|
||||
if (std.mem.eql(u8, s, "put")) return .put;
|
||||
return .call;
|
||||
}
|
||||
};
|
||||
|
||||
/// A single lot in a portfolio -- one purchase/sale event.
|
||||
|
|
@ -1192,21 +1178,13 @@ test "portfolio positions" {
|
|||
try std.testing.expectApproxEqAbs(@as(f64, 75.0), aapl.?.realized_gain_loss, 0.01); // 3 * (155-130)
|
||||
}
|
||||
|
||||
test "LotType label and fromString" {
|
||||
test "LotType label" {
|
||||
try std.testing.expectEqualStrings("Stock", LotType.stock.label());
|
||||
try std.testing.expectEqualStrings("Option", LotType.option.label());
|
||||
try std.testing.expectEqualStrings("CD", LotType.cd.label());
|
||||
try std.testing.expectEqualStrings("Cash", LotType.cash.label());
|
||||
try std.testing.expectEqualStrings("Illiquid", LotType.illiquid.label());
|
||||
try std.testing.expectEqualStrings("Watch", LotType.watch.label());
|
||||
|
||||
try std.testing.expectEqual(LotType.option, LotType.fromString("option"));
|
||||
try std.testing.expectEqual(LotType.cd, LotType.fromString("cd"));
|
||||
try std.testing.expectEqual(LotType.cash, LotType.fromString("cash"));
|
||||
try std.testing.expectEqual(LotType.illiquid, LotType.fromString("illiquid"));
|
||||
try std.testing.expectEqual(LotType.watch, LotType.fromString("watch"));
|
||||
try std.testing.expectEqual(LotType.stock, LotType.fromString("unknown"));
|
||||
try std.testing.expectEqual(LotType.stock, LotType.fromString(""));
|
||||
}
|
||||
|
||||
test "Lot.priceSymbol" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue