1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//! Account summary tags
use std::fmt::{Display, Error, Formatter};

use crate::core::account_summary_tags::AccountSummaryTags::*;

//==================================================================================================
/// AccountType — Identifies the IB account structure
/// NetLiquidation — The basis for determining the price of the assets in your account. Total cash value + stock value + options value + bond value
/// TotalCashValue — Total cash balance recognized at the time of trade + futures PNL
/// SettledCash — Cash recognized at the time of settlement - purchases at the time of trade - commissions - taxes - fees
/// AccruedCash — Total accrued cash value of stock, commodities and securities
/// BuyingPower — Buying power serves as a measurement of the dollar value of securities that one may purchase in a securities account without depositing additional funds
/// EquityWithLoanValue — Forms the basis for determining whether a client has the necessary assets to either initiate or maintain security positions. Cash + stocks + bonds + mutual funds
/// PreviousEquityWithLoanValue — Marginable Equity with Loan value as of 16:00 ET the previous day
/// GrossPositionValue — The sum of the absolute value of all stock and equity option positions
/// RegTEquity — Regulation T equity for universal account
/// RegTMargin — Regulation T margin for universal account
/// SMA — Special Memorandum Account: Line of credit created when the market value of securities in a Regulation T account increase in value
/// InitMarginReq — Initial Margin requirement of whole portfolio
/// MaintMarginReq — Maintenance Margin requirement of whole portfolio
/// AvailableFunds — This value tells what you have available for trading
/// ExcessLiquidity — This value shows your margin cushion, before liquidation
/// Cushion — Excess liquidity as a percentage of net liquidation value
/// FullInitMarginReq — Initial Margin of whole portfolio with no discounts or intraday credits
/// FullMaintMarginReq — Maintenance Margin of whole portfolio with no discounts or intraday credits
/// FullAvailableFunds — Available funds of whole portfolio with no discounts or intraday credits
/// FullExcessLiquidity — Excess liquidity of whole portfolio with no discounts or intraday credits
/// LookAheadNextChange — Time when look-ahead values take effect
/// LookAheadInitMarginReq — Initial Margin requirement of whole portfolio as of next period's margin change
/// LookAheadMaintMarginReq — Maintenance Margin requirement of whole portfolio as of next period's margin change
/// LookAheadAvailableFunds — This value reflects your available funds at the next margin change
/// LookAheadExcessLiquidity — This value reflects your excess liquidity at the next margin change
/// HighestSeverity — A measure of how close the account is to liquidation
/// DayTradesRemaining — The Number of Open/Close trades a user could put on before Pattern Day Trading is detected. A value of "-1" means that the user can put on unlimited day trades.
/// Leverage — GrossPositionValue / NetLiquidation
/// $LEDGER — Single flag to relay all cash balance tags*, only in base currency.
/// $LEDGER:CURRENCY — Single flag to relay all cash balance tags*, only in the specified currency.
/// $LEDGER:ALL — Single flag to relay all cash balance tags* in all currencies.

pub enum AccountSummaryTags {
    AccountType,
    NetLiquidation,
    TotalCashValue,
    SettledCash,
    AccruedCash,
    BuyingPower,
    EquityWithLoanValue,
    PreviousEquityWithLoanValue,
    GrossPositionValue,
    ReqTEquity,
    ReqTMargin,
    SMA,
    InitMarginReq,
    MaintMarginReq,
    AvailableFunds,
    ExcessLiquidity,
    Cushion,
    FullInitMarginReq,
    FullMaintMarginReq,
    FullAvailableFunds,
    FullExcessLiquidity,
    LookAheadNextChange,
    LookAheadInitMarginReq,
    LookAheadMaintMarginReq,
    LookAheadAvailableFunds,
    LookAheadExcessLiquidity,
    HighestSeverity,
    DayTradesRemaining,
    Leverage,
    Ledger,
    LedgerCurrency,
    LedgerAll,
    AllTags,
}

impl AccountSummaryTags {
    fn display(&self) -> &str {
        match self {
            AccountType => "AccountType",
            NetLiquidation => "NetLiquidation",
            TotalCashValue => "TotalCashValue",
            SettledCash => "SettledCash",
            AccruedCash => "AccruedCash",
            BuyingPower => "BuyingPower",
            EquityWithLoanValue => "EquityWithLoanValue",
            PreviousEquityWithLoanValue => "PreviousEquityWithLoanValue",
            GrossPositionValue => "GrossPositionValue",
            ReqTEquity => "ReqTEquity",
            ReqTMargin => "ReqTMargin",
            SMA => "SMA",
            InitMarginReq => "InitMarginReq",
            MaintMarginReq => "MaintMarginReq",
            AvailableFunds => "AvailableFunds",
            ExcessLiquidity => "ExcessLiquidity",
            Cushion => "Cushion",
            FullInitMarginReq => "FullInitMarginReq",
            FullMaintMarginReq => "FullMaintMarginReq",
            FullAvailableFunds => "FullAvailableFunds",
            FullExcessLiquidity => "FullExcessLiquidity",
            LookAheadNextChange => "LookAheadNextChange",
            LookAheadInitMarginReq => "LookAheadInitMarginReq",
            LookAheadMaintMarginReq => "LookAheadMaintMarginReq",
            LookAheadAvailableFunds => "LookAheadAvailableFunds",
            LookAheadExcessLiquidity => "LookAheadExcessLiquidity",
            HighestSeverity => "HighestSeverity",
            DayTradesRemaining => "DayTradesRemaining",
            Leverage => "Leverage",
            Ledger => "$LEDGER",
            LedgerCurrency => "$LEDGER:CURRENCY",
            LedgerAll => "$LEDGER:ALL",
            AllTags => {
                "AccountType,
            NetLiquidation,
            TotalCashValue,
            SettledCash,
            AccruedCash,
            BuyingPower,
            EquityWithLoanValue,
            PreviousEquityWithLoanValue,
            GrossPositionValue,
            ReqTEquity,
            ReqTMargin,
            SMA,
            InitMarginReq,
            MaintMarginReq,
            AvailableFunds,
            ExcessLiquidity,
            Cushion,Cushion,
            FullInitMarginReq,
            FullMaintMarginReq,
            FullAvailableFunds,
            FullExcessLiquidity,
            LookAheadNextChange,
            LookAheadInitMarginReq,
            LookAheadMaintMarginReq,
            LookAheadAvailableFunds,
            LookAheadExcessLiquidity,
            HighestSeverity,
            DayTradesRemaining,
            Leverage,
            $LEDGER,
            $LEDGER:CURRENCY,
            $LEDGER:ALL"
            }
        }
    }
}

impl Display for AccountSummaryTags {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
        write!(f, "{}", self.display())
    }
}