Symbol Info
CSymbolInfo
Source code in strategytester5\trade_classes\SymbolInfo.py
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | |
ask
property
Returns the current ask price.
ask_high
property
Gets the maximal Ask price for a day.
ask_low
property
Gets the minimal Ask price for a day.
bank
property
Feeder of the current quote
bid
property
Returns the current bid price.
bid_high
property
Gets the maximal Bid price for a day.
bid_low
property
Gets the minimal Bid price for a day.
contract_size
property
Trade contract size
currency_base
property
Base currency of the symbol.
currency_margin
property
Margin currency for the symbol
currency_profit
property
Profit currency for the symbol
description
property
Symbol description
digits
property
Digits after a decimal point for the symbol prices.
expiration_time
property
Date of the symbol trade end (usually used for futures)
filling_mode
property
Flags of allowed order filling modes for the symbol (bit field).
freeze_level
property
Gets the freezing distance for trade operations in points.
is_synchronized
property
Checks the symbol synchronization with server.
last
property
Gets the current Last price.
last_high
property
Gets the maximal Last price for a day.
last_low
property
Gets the minimal Last price for a day.
lots_limit
property
Maximum allowed aggregate volume of an open position and pending orders in one direction (buy or sell) for the symbol. For example, with the limitation of 5 lots, you can have an open buy position with the volume of 5 lots and place a pending order Sell Limit with the volume of 5 lots. But in this case you cannot place a Buy Limit pending order (since the total volume in one direction will exceed the limitation) or place Sell Limit with the volume more than 5 lots.
lots_max
property
Maximum allowed volume of a position in lots.
lots_min
property
Minimum allowed volume of a position in lots.
lots_step
property
Minimal volume change step for deal executions.
margin_hedged
property
Contract size or margin value per one lot of hedged positions (oppositely directed positions of one symbol). Two margin calculation methods are possible for hedged positions. The calculation method is defined by the broker.
Basic calculation:
- If the initial margin (margin_initial) is specified for a symbol, the hedged margin is specified as an absolute value (in monetary terms).
- If the initial margin is not specified (equal to 0), SYMBOL_MARGIN_HEDGED is equal to the size of the contract, that will be used to calculate the margin by the appropriate formula in accordance with the type of the financial instrument (trade_calc_mode).
Calculation for the largest position:
- The SYMBOL_MARGIN_HEDGED value is not taken into account.
- The volume of all short and all long positions of a symbol is calculated.
- For each direction, a weighted average open price and a weighted average rate of conversion to the deposit currency is calculated.
- Next, using the appropriate formula chosen in accordance with the symbol type (trade_calc_mode) the margin is calculated for the short and the long part.
- The largest one of the values is used as the margin.
margin_hedged_use_leg
property
Boolean flag to enable (true) or disable (false) the hedged margin calculation mode for the largest of the overlapped positions (buy and sell positions of the same symbol).
If the flag is enabled, the margin for the largest position is calculated using the SYMBOL_MARGIN_HEDGED value. If the flag is disabled, the margin for the largest position is calculated using the SYMBOL_MARGIN_INITIAL value.
margin_initial
property
Initial margin means the amount in the margin currency required for opening a position with the volume of one lot. It is used for checking a client's assets when he or she enters the market.
The SymbolInfoMarginRate() function provides data on the amount of charged margin depending on the order type and direction.
margin_maintenance
property
The maintenance margin. If it is set, it sets the margin amount in the margin currency of the symbol, charged from one lot. It is used for checking a client's assets when his/her account state changes. If the maintenance margin is equal to 0, the initial margin is used.
The SymbolInfoMarginRate() function provides data on the amount of charged margin depending on the order type and direction.
order_mode
property
Flags of allowed order types for the symbol (bit field).
page
property
The address of the web page containing symbol information.
This address will be displayed as a link when viewing symbol properties in the terminal
path
property
Path to the symbol tree. For example, "Forex\EURUSD" or "CFD\Apple Inc.
point
property
Symbol point value/The smallest price change for the symbol.
session_aw
property
Average weighted price of the current session
session_buy_orders
property
Number of buy orders at the moment (in the current session).
session_buy_orders_volume
property
Current volume of Buy orders
session_close
property
Closing price of the current session
session_deals
property
Number of deals in the current session.
session_interest
property
Summary open interest
session_open
property
Opening price of the current session
session_price_limit_max
property
Maximal price for the current session
session_price_limit_min
property
Minimal price for the current session
session_price_settlement
property
Settlement price of the current session
session_sell_orders
property
Number of sell orders at the moment (in the current session).
session_sell_orders_volume
property
Current volume of Sell orders
session_turnover
property
Summary turnover of the current session
spread
property
Gets the amount of spread in points.
spread_float
property
Gets the floating spread flag.
start_time
property
Date of the symbol trade beginning (usually used for futures)
stops_level
property
Gets the minimal indent for orders in points.
swap_long
property
Gets the swap for long positions.
swap_mode
property
A method of swap calculation at position transfer.
swap_mode_description
property
A description of methods of swap calculation at position transfer.
swap_rollover_3days
property
The day of week to charge 3-day swap rollover
swap_rollover_3days_description
property
A description (string) of the day of week to charge 3-day swap rollover
swap_short
property
Gets the swap for short positions.
symbol
property
Gets the current symbol name.
tick_size
property
Minimal price change / The size of a single tick for the symbol.
tick_value
property
The value of a single tick for the symbol.
tick_value_loss
property
Calculated tick price for a losing position
tick_value_profit
property
Calculated tick price for a profitable position
ticks_book_depth
property
Gets the depth of ticks saving.
time
property
Gets the time of the last quote as UTC datetime.
time_msc
property
Gets the time of the last quote in milliseconds.
trade_calc_mode
property
Contract price calculation mode
trade_calc_mode_description
property
A description of contract price calculation modes.
trade_execution
property
Possible deal execution modes for a given symbol.
trade_execution_description
property
A description of possible deal execution modes for a given symbol.
trade_mode
property
Symbol trading modes (restrictions)
trade_mode_description
property
A description of symbol trading modes (restrictions)
volume
property
Gets the volume of the last deal.
volume_high
property
Gets the maximal volume for a day.
volume_low
property
Gets the minimal volume for a day.
volume_real
property
Gets the real volume of the last deal.
__init__(symbol, terminal)
A lightweight Python wrapper that resembles the MQL5 Standard Library class
CSymbolInfo and provides convenient, read-only access to MetaTrader 5
symbol properties.
This class stores a symbol name, cached symbol information, and cached tick
information. Symbol data can be refreshed via refresh(), while quote/tick
data can be refreshed via refresh_rates().
Parameters
terminal : Initialize native MetaTrader5 API or the simulated one from the StrategyTester instance
Notes
name(symbol_name)assigns the symbol and refreshes its static info.refresh_rates()updates the cached tick/quote values.- If tick data is not refreshed yet, tick-related properties return their default cached values.
- Time values are returned as timezone-aware UTC datetimes where applicable.
Source code in strategytester5\trade_classes\SymbolInfo.py
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 | |
check_market_watch()
Checks if the symbol is selected in Market Watch and adds it to the Market Watch if necessary.
Source code in strategytester5\trade_classes\SymbolInfo.py
126 127 128 129 130 131 132 133 134 135 | |
info_double(prop_name)
Gets the value of a specified double type property.
Parameters
prop_name : str Name of the symbol info attribute.
Returns
Optional[float] Float value if present, otherwise None.
Source code in strategytester5\trade_classes\SymbolInfo.py
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | |
info_integer(prop_name)
Gets the value of a specified integer type property.
Parameters
prop_name : str Name of the symbol info attribute.
Returns
Optional[int] Integer value if present, otherwise None.
Source code in strategytester5\trade_classes\SymbolInfo.py
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | |
info_string(prop_name)
Gets the value of a specified string type property.
Parameters
prop_name : str Name of the symbol info attribute.
Returns
Optional[str] String value if present, otherwise None.
Source code in strategytester5\trade_classes\SymbolInfo.py
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | |
normalize_price(price)
Returns the value of price normalized using the symbol properties.
Parameters
price : float Price to normalize.
Returns
float Normalized price based on symbol digits.
Source code in strategytester5\trade_classes\SymbolInfo.py
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
print_all()
Print all @property values of the class.
Source code in strategytester5\trade_classes\SymbolInfo.py
727 728 729 730 | |
refresh()
Refreshes the symbol data by fetching symbol information from the terminal.
Returns
bool True if successful.
Raises
RuntimeError If symbol information could not be retrieved.
Source code in strategytester5\trade_classes\SymbolInfo.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
refresh_rates()
Refreshes the symbol quotes/gets the latest tick information from the market using symbol_info_tick(symbol).
Returns
bool True if successful, False otherwise.
Source code in strategytester5\trade_classes\SymbolInfo.py
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 | |
select(select=True)
Gets/sets the Market Watch symbol flag.
Parameters
select : bool, optional True to select the symbol in Market Watch, False to deselect.
Returns
bool True if successful, otherwise False.
Source code in strategytester5\trade_classes\SymbolInfo.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
to_dict()
Return all @property values as a dictionary.
Source code in strategytester5\trade_classes\SymbolInfo.py
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | |