@@ -29,14 +29,10 @@ struct Cli {
2929#[ derive( Subcommand ) ]
3030enum Commands {
3131 /// Get historical price at the backtest date
32- Quote {
33- symbol : String ,
34- } ,
32+ Quote { symbol : String } ,
3533
3634 /// Show news (stub — historical news not available)
37- News {
38- symbol : String ,
39- } ,
35+ News { symbol : String } ,
4036
4137 /// SEC filings on or before the backtest date
4238 #[ command( subcommand) ]
@@ -180,15 +176,11 @@ enum JsonCommand {
180176 symbol : String ,
181177 amount : f64 ,
182178 price : Option < f64 > ,
183- #[ serde( default ) ]
184- close : bool ,
185179 } ,
186180 PerpSell {
187181 symbol : String ,
188182 amount : f64 ,
189183 price : Option < f64 > ,
190- #[ serde( default ) ]
191- close : bool ,
192184 } ,
193185 PerpLeverage {
194186 symbol : String ,
@@ -262,8 +254,8 @@ async fn cmd_report_list(
262254 date,
263255 ) ;
264256 println ! (
265- " {:<8} {:<12} {:<12} {} " ,
266- "Form" , "Filed" , "Period" , "Accession Number"
257+ " {:<8} {:<12} {:<12} Accession Number " ,
258+ "Form" , "Filed" , "Period"
267259 ) ;
268260 println ! ( " {}" , "-" . repeat( 66 ) ) ;
269261 for f in & filings {
@@ -307,6 +299,7 @@ async fn cmd_report_quarterly(
307299 commands:: report:: get ( symbol, & filing. accession_number , output, json_output) . await
308300}
309301
302+ #[ allow( clippy:: too_many_arguments) ]
310303async fn cmd_trade (
311304 symbol : & str ,
312305 amount : f64 ,
@@ -346,11 +339,7 @@ async fn cmd_trade(
346339
347340// ── JSON dispatch ───────────────────────────────────────────────────────
348341
349- async fn run_json (
350- json_str : & str ,
351- date : NaiveDate ,
352- portfolio : & mut Portfolio ,
353- ) -> Result < ( ) > {
342+ async fn run_json ( json_str : & str , date : NaiveDate , portfolio : & mut Portfolio ) -> Result < ( ) > {
354343 let cmd: JsonCommand = serde_json:: from_str ( json_str)
355344 . map_err ( |e| anyhow:: anyhow!( "Invalid JSON command: {}" , e) ) ?;
356345
@@ -524,13 +513,8 @@ async fn main() -> Result<()> {
524513 let cli = Cli :: parse ( ) ;
525514
526515 // Parse the --at date
527- let date = NaiveDate :: parse_from_str ( & cli. at , "%Y-%m-%d" ) . map_err ( |e| {
528- anyhow:: anyhow!(
529- "Invalid date '{}': {}. Use YYYY-MM-DD format." ,
530- cli. at,
531- e
532- )
533- } ) ?;
516+ let date = NaiveDate :: parse_from_str ( & cli. at , "%Y-%m-%d" )
517+ . map_err ( |e| anyhow:: anyhow!( "Invalid date '{}': {}. Use YYYY-MM-DD format." , cli. at, e) ) ?;
534518
535519 // Validate date is not in the future
536520 let today = chrono:: Utc :: now ( ) . date_naive ( ) ;
@@ -539,7 +523,10 @@ async fn main() -> Result<()> {
539523 }
540524
541525 let mut portfolio = Portfolio :: load ( ) . unwrap_or_else ( |e| {
542- eprintln ! ( "Warning: could not load portfolio state: {:#}. Starting fresh." , e) ;
526+ eprintln ! (
527+ "Warning: could not load portfolio state: {:#}. Starting fresh." ,
528+ e
529+ ) ;
543530 Portfolio :: new ( )
544531 } ) ;
545532
@@ -589,7 +576,13 @@ async fn main() -> Result<()> {
589576 price,
590577 } => {
591578 cmd_trade (
592- & symbol, amount, price, TradeSide :: Buy , TradeType :: Spot , date, & mut portfolio,
579+ & symbol,
580+ amount,
581+ price,
582+ TradeSide :: Buy ,
583+ TradeType :: Spot ,
584+ date,
585+ & mut portfolio,
593586 json_output,
594587 )
595588 . await
@@ -600,7 +593,13 @@ async fn main() -> Result<()> {
600593 price,
601594 } => {
602595 cmd_trade (
603- & symbol, amount, price, TradeSide :: Sell , TradeType :: Spot , date, & mut portfolio,
596+ & symbol,
597+ amount,
598+ price,
599+ TradeSide :: Sell ,
600+ TradeType :: Spot ,
601+ date,
602+ & mut portfolio,
604603 json_output,
605604 )
606605 . await
@@ -613,8 +612,14 @@ async fn main() -> Result<()> {
613612 ..
614613 } => {
615614 cmd_trade (
616- & symbol, amount, price, TradeSide :: Buy , TradeType :: Perp , date,
617- & mut portfolio, json_output,
615+ & symbol,
616+ amount,
617+ price,
618+ TradeSide :: Buy ,
619+ TradeType :: Perp ,
620+ date,
621+ & mut portfolio,
622+ json_output,
618623 )
619624 . await
620625 }
@@ -625,8 +630,14 @@ async fn main() -> Result<()> {
625630 ..
626631 } => {
627632 cmd_trade (
628- & symbol, amount, price, TradeSide :: Sell , TradeType :: Perp , date,
629- & mut portfolio, json_output,
633+ & symbol,
634+ amount,
635+ price,
636+ TradeSide :: Sell ,
637+ TradeType :: Perp ,
638+ date,
639+ & mut portfolio,
640+ json_output,
630641 )
631642 . await
632643 }
@@ -644,10 +655,7 @@ async fn main() -> Result<()> {
644655 Commands :: Balance => {
645656 let cash = portfolio. cash_balance ( ) ;
646657 let positions = portfolio. positions ( ) ;
647- println ! (
648- "\n {} Simulated portfolio" ,
649- "[BACKTEST]" . dimmed( )
650- ) ;
658+ println ! ( "\n {} Simulated portfolio" , "[BACKTEST]" . dimmed( ) ) ;
651659 let cash_str = format ! ( "${:.2}" , cash) ;
652660 let colored_cash = if cash >= 0.0 {
653661 cash_str. green ( ) . to_string ( )
@@ -665,15 +673,9 @@ async fn main() -> Result<()> {
665673 Commands :: Positions => {
666674 let positions = portfolio. positions ( ) ;
667675 if positions. is_empty ( ) {
668- println ! (
669- "\n {} No open positions.\n " ,
670- "[BACKTEST]" . dimmed( )
671- ) ;
676+ println ! ( "\n {} No open positions.\n " , "[BACKTEST]" . dimmed( ) ) ;
672677 } else {
673- println ! (
674- "\n {} Open positions:\n " ,
675- "[BACKTEST]" . dimmed( )
676- ) ;
678+ println ! ( "\n {} Open positions:\n " , "[BACKTEST]" . dimmed( ) ) ;
677679 println ! (
678680 " {:<10} {:<6} {:<8} {:>12} {:>14}" ,
679681 "Symbol" , "Type" , "Side" , "Quantity" , "Avg Entry"
@@ -686,7 +688,11 @@ async fn main() -> Result<()> {
686688 } ;
687689 println ! (
688690 " {:<10} {:<6} {:<8} {:>12.4} {:>14.2}" ,
689- p. symbol, type_str, p. side, p. net_quantity. abs( ) , p. avg_entry_price
691+ p. symbol,
692+ type_str,
693+ p. side,
694+ p. net_quantity. abs( ) ,
695+ p. avg_entry_price
690696 ) ;
691697 }
692698 println ! ( ) ;
0 commit comments