Account Info
CAccountInfo
Source code in strategytester5\trade_classes\AccountInfo.py
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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
balance
property
Gets the account balance.
company
property
Gets the broker/company name.
credit
property
Gets the account credit.
currency
property
Gets the deposit currency.
equity
property
Gets the account equity.
free_margin
property
Gets the free margin.
leverage
property
Gets the account leverage.
limit_orders
property
Gets the maximum number of allowed pending orders.
login
property
Gets the account number (Login).
margin
property
Gets the reserved margin.
margin_call
property
Gets the margin call level.
margin_level
property
Gets the margin level.
margin_mode
property
Gets the margin calculation mode (ACCOUNT_MARGIN_MODE_*).
margin_mode_description
property
Gets the margin calculation mode as a human-readable string.
margin_stopout
property
Gets the stop-out level.
name
property
Gets the client name.
profit
property
Gets the current profit for the account.
server
property
Gets the trade server name.
stopout_mode
property
Gets the stop-out mode (ACCOUNT_STOPOUT_MODE_*).
stopout_mode_description
property
Gets the stop-out mode as a human-readable string.
trade_allowed
property
Returns True if trading is allowed for the account.
trade_expert
property
Returns True if automated trading is allowed for the account.
trade_mode
property
Gets the trade mode (ACCOUNT_TRADE_MODE_*).
trade_mode_description
property
Gets the trade mode as a human-readable string.
__init__(terminal)
A lightweight Python wrapper that resembles the MQL5 Standard Library class
CAccountInfo and provides convenient, read-only access to the properties of
the currently connected MetaTrader 5 trading account.
This class caches the result of mt5.account_info() at construction time.
The returned values reflect the account state at the time of initialization
(balance, equity, margin, etc.). If you need up-to-date values after trading
activity or price changes, re-instantiate the class or implement a refresh.
Args
terminal : MetaTrader5 module-like or simulated/overloaded MetaTrader5 instance.
Raises
RuntimeError
If account information cannot be retrieved (i.e., account_info() returns None).
Notes
Method groups mirror the MQL5 layout: - Integer properties: Login, TradeMode, Leverage, StopoutMode, MarginMode, etc. - Double properties: Balance, Equity, Margin, FreeMargin, etc. - String properties: Name, Server, Currency, Company - Checks / calculations: MarginCheck, OrderProfitCheck, FreeMarginCheck, MaxLotCheck
Source code in strategytester5\trade_classes\AccountInfo.py
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 | |
free_margin_check(symbol, order_type, volume, price)
Returns free margin left after opening the position, or None if margin check fails.
Source code in strategytester5\trade_classes\AccountInfo.py
204 205 206 207 208 209 | |
margin_check(symbol, order_type, volume, price)
Gets the amount of margin required to execute trade operation
Source code in strategytester5\trade_classes\AccountInfo.py
211 212 213 214 215 216 | |
max_lot_check(symbol, order_type, price, percent=100.0)
Estimates the maximum tradable volume based on available margin.
Args
percent : float Percentage of free margin to use (0..100).
Returns
Optional[float] Estimated maximum lot size, or None if margin cannot be estimated.
Source code in strategytester5\trade_classes\AccountInfo.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
order_profit_check(symbol, order_type, volume, price_open, price_close)
Evaluates profit for the given open/close prices (approximate, ignores commissions/swaps).
Source code in strategytester5\trade_classes\AccountInfo.py
197 198 199 200 201 202 | |
print_all()
Print all @property values of the class.
Source code in strategytester5\trade_classes\AccountInfo.py
237 238 239 240 241 242 243 244 245 246 247 | |