File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ struct Asset {
24
24
current_price_cents : u32 ,
25
25
// if sell price is None, it isn't sold
26
26
sell_price_cents : Option < u32 > ,
27
+ quantity : u32 ,
27
28
}
28
29
29
30
fn is_asset_sold ( asset : & Asset ) -> bool {
@@ -58,6 +59,7 @@ fn print_assets(assets: &Vec<Asset>) {
58
59
"Current Price" ,
59
60
"Percent Change" ,
60
61
"Sell Price" ,
62
+ "Quantity"
61
63
] ) ;
62
64
63
65
for asset in assets {
@@ -90,6 +92,7 @@ fn print_assets(assets: &Vec<Asset>) {
90
92
} else {
91
93
"N/A (currently held)" . to_string( )
92
94
} ,
95
+ asset. quantity. to_string( ) ,
93
96
] ) ;
94
97
}
95
98
println ! ( "{table}" ) ;
@@ -113,6 +116,9 @@ fn add_asset(connector: &yf::YahooConnector) -> Option<Asset> {
113
116
print ! ( "Enter sell price if sold, otherwise enter 'held': " ) ;
114
117
let sell_price_raw: String = read ! ( ) ;
115
118
119
+ print ! ( "Enter quantity: " ) ;
120
+ let n: u32 = read ! ( ) ;
121
+
116
122
let current_price: Option < u32 > = get_current_ticker_price ( connector, & symbol) ;
117
123
// if I access a string twice I have to make it owned for some reason - IDK
118
124
// what that means or if there is a better way
@@ -125,6 +131,7 @@ fn add_asset(connector: &yf::YahooConnector) -> Option<Asset> {
125
131
} else {
126
132
Some ( sell_price_raw. parse ( ) . unwrap ( ) )
127
133
} ) ,
134
+ quantity : n,
128
135
} )
129
136
}
130
137
You can’t perform that action at this time.
0 commit comments