futucli/cli/dispatch/
trade_read.rs1use anyhow::Result;
2
3use super::super::commands::{ComboMaxTrdQtysArgs, DealArgs, FundsArgs, OrderArgs, PositionArgs};
4use crate::cmd;
5use crate::output::OutputFormat;
6
7pub(super) async fn dispatch_funds(
8 gateway: &str,
9 output: OutputFormat,
10 args: FundsArgs,
11) -> Result<()> {
12 let acc_id = cmd::account::resolve_account_locator(
13 gateway,
14 args.acc_id,
15 args.card_num.as_deref(),
16 "funds",
17 )
18 .await?;
19 cmd::account::funds(
20 gateway,
21 &args.env,
22 acc_id,
23 args.market.as_deref(),
24 args.currency.as_deref(),
25 output,
26 )
27 .await
28}
29
30pub(super) async fn dispatch_position(
31 gateway: &str,
32 output: OutputFormat,
33 args: PositionArgs,
34) -> Result<()> {
35 let acc_id = cmd::account::resolve_account_locator(
36 gateway,
37 args.acc_id,
38 args.card_num.as_deref(),
39 "positions",
40 )
41 .await?;
42 cmd::account::positions(
43 gateway,
44 &args.env,
45 acc_id,
46 &args.market,
47 args.currency.as_deref(),
48 args.option_strategy_view,
49 output,
50 )
51 .await
52}
53
54pub(super) async fn dispatch_order(
55 gateway: &str,
56 output: OutputFormat,
57 args: OrderArgs,
58) -> Result<()> {
59 let acc_id = cmd::account::resolve_account_locator(
60 gateway,
61 args.acc_id,
62 args.card_num.as_deref(),
63 "orders",
64 )
65 .await?;
66 cmd::account::orders(gateway, &args.env, acc_id, &args.market, output).await
67}
68
69pub(super) async fn dispatch_deal(
70 gateway: &str,
71 output: OutputFormat,
72 args: DealArgs,
73) -> Result<()> {
74 let acc_id = cmd::account::resolve_account_locator(
75 gateway,
76 args.acc_id,
77 args.card_num.as_deref(),
78 "deals",
79 )
80 .await?;
81 cmd::account::deals(gateway, &args.env, acc_id, &args.market, output).await
82}
83
84pub(super) async fn dispatch_combo_max_trd_qtys(
85 gateway: &str,
86 output: OutputFormat,
87 args: ComboMaxTrdQtysArgs,
88) -> Result<()> {
89 cmd::proto_json::run_combo_max_trd_qtys(gateway, &args.c2s_json, output).await
90}