|
BBSTRADER 2.4.0
|
Namespace containing MetaTrader 5 (MT5) client definitions and wrapper classes. More...
Classes | |
| struct | AccountInfo |
| Information about the trading account. More... | |
| struct | BookInfo |
| Represents an entry in the Depth of Market (Order Book). More... | |
| class | MetaTraderClient |
| A client class that abstracts MetaTrader 5 functionality using injected handlers. More... | |
| struct | OrderCheckResult |
| Results of an order check (validation) operation. More... | |
| struct | OrderSentResult |
| Results of a sent order. More... | |
| struct | RateInfo |
| Represents a bar of historical data (OHLCV). More... | |
| struct | SymbolInfo |
| Comprehensive information about a specific financial instrument (Symbol). More... | |
| struct | TerminalInfo |
| Information regarding the terminal and connection status. More... | |
| struct | TickInfo |
| Represents a single tick (price update). More... | |
| struct | TradeDeal |
| Represents a historical deal (execution). More... | |
| struct | TradeOrder |
| Represents an active or historical order. More... | |
| struct | TradePosition |
| Represents an open position. More... | |
| struct | TradeRequest |
| Structure to send trade requests to the server. More... | |
Concepts | |
| concept | IsScopedEnum |
| Concept to check if a type is a scoped enumeration (Legacy fallback). | |
Typedefs | |
| using | str = const std::string |
| Alias for const std::string to simplify function signatures. | |
| using | VersionInfo = std::tuple< int32_t, int32_t, std::string > |
| Tuple representing version info: <major version, minor version, build date string>. | |
| using | LastErrorResult = std::tuple< int32_t, std::string > |
| Tuple representing the last error: <error code, error description>. | |
| using | DealsData = std::optional< std::vector< TradeDeal > > |
| Optional vector of TradeDeal objects. | |
| using | SymbolsData = std::optional< std::vector< SymbolInfo > > |
| Optional vector of SymbolInfo objects. | |
| using | BookData = std::optional< std::vector< BookInfo > > |
| Optional vector of BookInfo (Market Depth) objects. | |
| using | OrdersData = std::optional< std::vector< TradeOrder > > |
| Optional vector of TradeOrder objects. | |
| using | PositionsData = std::optional< std::vector< TradePosition > > |
| Optional vector of TradePosition objects. | |
| using | RateInfoType = std::optional< py::array_t< RateInfo > > |
| Optional Numpy array of RateInfo structures (OHLCV data). | |
| using | TickInfoType = std::optional< py::array_t< TickInfo > > |
| Optional Numpy array of TickInfo structures. | |
| using | DateTime = std::chrono::system_clock::time_point |
| System clock time point for date/time operations. | |
| using | InitializeAuto = std::function< bool()> |
| Callback to initialize the MT5 terminal automatically. | |
| using | InitializeWithPath = std::function< bool(str &)> |
| Callback to initialize the MT5 terminal with a specific path. | |
| using | InitializeFull = std::function< bool(str &, uint64_t, str &, str &, uint32_t, bool)> |
| Callback to initialize the MT5 terminal with full configuration options. | |
| using | Login = std::function< bool(uint64_t, str &, str &, uint32_t)> |
| Callback to login to an account. | |
| using | Shutdown = std::function< void()> |
| Callback to shut down the initialized terminal. | |
| using | GetVersion = std::function< std::optional< VersionInfo >()> |
| Callback to retrieve the terminal version. | |
| using | GetLastError = std::function< std::optional< LastErrorResult >()> |
| Callback to retrieve the last error code and description. | |
| using | GetTerminalInfo = std::function< std::optional< TerminalInfo >()> |
| Callback to retrieve static terminal information. | |
| using | GetAccountInfo = std::function< std::optional< AccountInfo >()> |
| Callback to retrieve account information. | |
| using | GetSymbolInfo = std::function< std::optional< SymbolInfo >(str &)> |
| Callback to retrieve information for a specific symbol. | |
| using | GetTickInfo = std::function< std::optional< TickInfo >(str &)> |
| Callback to retrieve the last tick for a specific symbol. | |
| using | GetTotalSymbols = std::function< std::optional< int32_t >()> |
| Callback to get the total count of available symbols. | |
| using | GetSymbolsAll = std::function< SymbolsData()> |
| Callback to retrieve all available symbols. | |
| using | SelectSymbol = std::function< bool(str &, bool)> |
| Callback to select or deselect a symbol in Market Watch. | |
| using | GetSymbolsByGroup = std::function< SymbolsData(str &)> |
| Callback to retrieve symbols belonging to a specific group. | |
| using | SubscribeBook = std::function< bool(str &)> |
| Callback to subscribe to the Market Book (Depth of Market) for a symbol. | |
| using | UnsubscribeBook = std::function< bool(str &)> |
| Callback to unsubscribe from the Market Book for a symbol. | |
| using | GetBookInfo = std::function< BookData(str &)> |
| Callback to get the current Market Book state for a symbol. | |
| using | GetRatesByDate = std::function< RateInfoType(str &, int32_t, int64_t, int32_t)> |
| Callback to get rates starting from a specific date. | |
| using | GetRatesByPos = std::function< RateInfoType(str &, int32_t, int32_t, int32_t)> |
| Callback to get rates starting from a specific index position. | |
| using | GetRatesByRange = std::function< RateInfoType(str &, int32_t, int64_t, int64_t)> |
| Callback to get rates within a time range. | |
| using | GetTicksByDate = std::function< TickInfoType(str &, int64_t, int32_t, int32_t)> |
| Callback to get ticks starting from a specific date. | |
| using | GetTicksByRange = std::function< TickInfoType(str &, int64_t, int64_t, int32_t)> |
| Callback to get ticks within a time range. | |
| using | GetOrdersAll = std::function< OrdersData()> |
| Callback to retrieve all current trade orders. | |
| using | GetOrdersBySymbol = std::function< OrdersData(str &)> |
| Callback to retrieve trade orders filtered by symbol. | |
| using | GetOrdersByGroup = std::function< OrdersData(str &)> |
| Callback to retrieve trade orders filtered by a specific group. | |
| using | GetOrderByTicket = std::function< std::optional< TradeOrder >(uint64_t)> |
| Callback to retrieve a specific order by its unique ticket ID. | |
| using | GetTotalOrders = std::function< std::optional< int32_t >()> |
| Callback to retrieve the total count of active orders. | |
| using | GetPositionsAll = std::function< PositionsData()> |
| Callback to retrieve all active trade positions. | |
| using | GetPositionsBySymbol = std::function< PositionsData(str &)> |
| Callback to retrieve active positions filtered by symbol. | |
| using | GetPositionsByGroup = std::function< PositionsData(str &)> |
| Callback to retrieve active positions filtered by group. | |
| using | GetPositionByTicket = std::function< std::optional< TradePosition >(uint64_t)> |
| Callback to retrieve a specific position by its unique ticket ID. | |
| using | GetTotalPositions = std::function< std::optional< int32_t >()> |
| Callback to retrieve the total count of active positions. | |
| using | CalculateMargin = std::function< std::optional< double >(int32_t, str &, double, double)> |
| Callback to calculate margin. | |
| using | CalculateProfit = std::function< std::optional< double >(int32_t, str &, double, double, double)> |
| Callback to calculate profit. | |
| using | CheckOrder = std::function< std::optional< OrderCheckResult >(const TradeRequest &)> |
| Callback to check an order request before sending. | |
| using | SendOrder = std::function< std::optional< OrderSentResult >(const TradeRequest &)> |
| Callback to send an order to the market. | |
| using | GetHistoryOrdersByRange = std::function< OrdersData(int64_t, int64_t)> |
| Callback to retrieve historical orders within a specific time range. | |
| using | GetHistoryOrdersByGroup = std::function< OrdersData(int64_t, int64_t, str &)> |
| Callback to retrieve historical orders within a specific time range and filter. | |
| using | GetHistoryOrderByTicket = std::function< std::optional< TradeOrder >(uint64_t)> |
| Callback to retrieve a specific historical order by its ticket ID. | |
| using | GetHistoryOrdersByPosId = std::function< OrdersData(uint64_t)> |
| Callback to retrieve all historical orders associated with a specific Position ID. | |
| using | GetHistoryOrdersTotal = std::function< std::optional< int32_t >(int64_t, int64_t)> |
| Callback to retrieve the total count of historical orders within a time range. | |
| using | GetHistoryDealsByRange = std::function< DealsData(int64_t, int64_t)> |
| Callback to retrieve historical deals (executions) within a time range. | |
| using | GetHistoryDealsByGroup = std::function< DealsData(int64_t, int64_t, str &)> |
| Callback to retrieve historical deals (executions) within a time range buy asset. | |
| using | GetHistoryDealsByTicket = std::function< DealsData(uint64_t)> |
| Callback to retrieve historical deals associated with a specific Order Ticket. | |
| using | GetHistoryDealsByPosId = std::function< DealsData(uint64_t)> |
| Callback to retrieve historical deals associated with a specific Position ID. | |
| using | GetHistoryDealsTotal = std::function< std::optional< int32_t >(int64_t, int64_t)> |
| Callback to retrieve the total count of historical deals within a time range. | |
Enumerations | |
| enum class | Timeframe : int32_t { M1 = 1 , M2 = 2 , M3 = 3 , M4 = 4 , M5 = 5 , M6 = 6 , M10 = 10 , M12 = 12 , M15 = 15 , M20 = 20 , M30 = 30 , H1 = 1 | 0x4000 , H2 = 2 | 0x4000 , H3 = 3 | 0x4000 , H4 = 4 | 0x4000 , H6 = 6 | 0x4000 , H8 = 8 | 0x4000 , H12 = 12 | 0x4000 , D1 = 24 | 0x4000 , W1 = 1 | 0x8000 , MN1 = 1 | 0xC000 } |
| Standard chart timeframes. More... | |
| enum class | OrderType : int32_t { BUY = 0 , SELL = 1 , BUY_LIMIT = 2 , SELL_LIMIT = 3 , BUY_STOP = 4 , SELL_STOP = 5 , BUY_STOP_LIMIT = 6 , SELL_STOP_LIMIT = 7 , CLOSE_BY = 8 } |
| Order types for market and pending orders. More... | |
| enum class | OrderState : int32_t { STARTED = 0 , PLACED = 1 , CANCELED = 2 , PARTIAL = 3 , FILLED = 4 , REJECTED = 5 , EXPIRED = 6 , REQUEST_ADD = 7 , REQUEST_MODIFY = 8 , REQUEST_CANCEL = 9 } |
| States of an order. More... | |
| enum class | OrderFilling : int32_t { FOK = 0 , IOC = 1 , RETURN = 2 , BOC = 3 } |
| Order filling policies. More... | |
| enum class | OrderReason : int32_t { CLIENT = 0 , MOBILE = 1 , WEB = 2 , EXPERT = 3 , SL = 4 , TP = 5 , SO = 6 } |
| Reason or source for the order placement. More... | |
| enum class | DealType : int32_t { BUY = 0 , SELL = 1 , BALANCE = 2 , CREDIT = 3 , CHARGE = 4 , CORRECTION = 5 , BONUS = 6 , COMMISSION = 7 , COMMISSION_DAILY = 8 , COMMISSION_MONTHLY = 9 , COMMISSION_AGENT_DAILY = 10 , COMMISSION_AGENT_MONTHLY = 11 , INTEREST = 12 , BUY_CANCELED = 13 , SELL_CANCELED = 14 , DIVIDEND = 15 , DIVIDEND_FRANKED = 16 , TAX = 17 } |
| Types of deals involved in trading. More... | |
| enum class | DealReason : int32_t { CLIENT = 0 , MOBILE = 1 , WEB = 2 , EXPERT = 3 , SL = 4 , TP = 5 , SO = 6 , ROLLOVER = 7 , VMARGIN = 8 , SPLIT = 9 } |
| Reason for the deal execution. More... | |
| enum class | TradeAction : int32_t { DEAL = 1 , PENDING = 5 , SLTP = 6 , MODIFY = 7 , REMOVE = 8 , CLOSE_BY = 10 } |
| Types of trade actions in a request. More... | |
| enum class | SymbolCalcMode : int32_t { FOREX = 0 , FUTURES = 1 , CFD = 2 , CFDINDEX = 3 , CFDLEVERAGE = 4 , FOREX_NO_LEVERAGE = 5 , EXCH_STOCKS = 32 , EXCH_FUTURES = 33 , EXCH_OPTIONS = 34 , EXCH_OPTIONS_MARGIN = 36 , EXCH_BONDS = 37 , EXCH_STOCKS_MOEX = 38 , EXCH_BONDS_MOEX = 39 , SERV_COLLATERAL = 64 } |
| Mode of symbol margin and profit calculation. More... | |
| enum class | SymbolTradeMode : int32_t { DISABLED = 0 , LONGONLY = 1 , SHORTONLY = 2 , CLOSEONLY = 3 , FULL = 4 } |
| Allowed trade modes for a symbol. More... | |
| enum class | SymbolSwapMode : int32_t { DISABLED = 0 , POINTS = 1 , CURRENCY_SYMBOL = 2 , CURRENCY_MARGIN = 3 , CURRENCY_DEPOSIT = 4 , INTEREST_CURRENT = 5 , INTEREST_OPEN = 6 , REOPEN_CURRENT = 7 , REOPEN_BID = 8 } |
| Swap calculation modes. More... | |
| enum class | DayOfWeek : int32_t { SUNDAY = 0 , MONDAY = 1 , TUESDAY = 2 , WEDNESDAY = 3 , THURSDAY = 4 , FRIDAY = 5 , SATURDAY = 6 } |
| Days of the week. | |
| enum class | SymbolGTCMode : int32_t { GTC = 0 , DAILY = 1 , DAILY_NO_STOPS = 2 } |
| Expiration modes for Good-Till-Canceled orders. | |
| enum class | OptionRight : int32_t { CALL = 0 , PUT = 1 } |
| Option right type. | |
| enum class | OptionMode : int32_t { EUROPEAN = 0 , AMERICAN = 1 } |
| Option style. | |
| enum class | AccountTradeMode : int32_t { DEMO = 0 , CONTEST = 1 , REAL = 2 } |
| Account trade mode (Demo/Real). | |
| enum class | AccountStopoutMode : int32_t { PERCENT = 0 , MONEY = 1 } |
| Stop-out calculation mode. | |
| enum class | AccountMarginMode : int32_t { RETAIL_NETTING = 0 , EXCHANGE = 1 , RETAIL_HEDGING = 2 } |
| Account margin calculation mode. | |
| enum class | BookType : int32_t { SELL = 1 , BUY = 2 , SELL_MARKET = 3 , BUY_MARKET = 4 } |
| Order book entry type. | |
| enum class | SymbolExecution : int32_t { REQUEST = 0 , INSTANT = 1 , MARKET = 2 , EXCHANGE = 3 } |
| Symbol execution mode. | |
| enum class | SymbolChartMode : int32_t { BID = 0 , LAST = 1 } |
| Symbol chart price base. | |
| enum class | DealEntry : int32_t { IN = 0 , OUT = 1 , INOUT = 2 , OUT_BY = 3 } |
| Deal entry direction. | |
| enum class | OrderTime : int32_t { GTC = 0 , DAY = 1 , SPECIFIED = 2 , SPECIFIED_DAY = 3 } |
| Order expiration time flags. | |
| enum class | PositionType : int32_t { BUY = 0 , SELL = 1 } |
| Position type. | |
| enum class | PositionReason : int32_t { CLIENT = 0 , MOBILE = 1 , WEB = 2 , EXPERT = 3 } |
| Reason for position creation. | |
| enum class | CopyTicks : int32_t { ALL = -1 , INFO = 1 , TRADE = 2 } |
| Flags for copying ticks. | |
| enum class | TickFlag : int32_t { BID = 0x02 , ASK = 0x04 , LAST = 0x08 , VOLUME = 0x10 , BUY = 0x20 , SELL = 0x40 } |
| Flags describing tick content. More... | |
| enum class | TradeRetcode : int32_t { REQUOTE = 10004 , REJECT = 10006 , CANCEL = 10007 , PLACED = 10008 , DONE = 10009 , DONE_PARTIAL = 10010 , ERROR = 10011 , TIMEOUT = 10012 , INVALID = 10013 , INVALID_VOLUME = 10014 , INVALID_PRICE = 10015 , INVALID_STOPS = 10016 , TRADE_DISABLED = 10017 , MARKET_CLOSED = 10018 , NO_MONEY = 10019 , PRICE_CHANGED = 10020 , PRICE_OFF = 10021 , INVALID_EXPIRATION = 10022 , ORDER_CHANGED = 10023 , TOO_MANY_REQUESTS = 10024 , NO_CHANGES = 10025 , SERVER_DISABLES_AT = 10026 , CLIENT_DISABLES_AT = 10027 , LOCKED = 10028 , FROZEN = 10029 , INVALID_FILL = 10030 , CONNECTION = 10031 , ONLY_REAL = 10032 , LIMIT_ORDERS = 10033 , LIMIT_VOLUME = 10034 , INVALID_ORDER = 10035 , POSITION_CLOSED = 10036 , INVALID_CLOSE_VOLUME = 10038 , CLOSE_ORDER_EXIST = 10039 , LIMIT_POSITIONS = 10040 , REJECT_CANCEL = 10041 , LONG_ONLY = 10042 , SHORT_ONLY = 10043 , CLOSE_ONLY = 10044 , FIFO_CLOSE = 10045 } |
| Return codes from the trade server. More... | |
| enum class | ReturnCode : int32_t { OK = 1 , FAIL = -1 , INVALID_PARAMS = -2 , NO_MEMORY = -3 , NOT_FOUND = -4 , INVALID_VERSION = -5 , AUTH_FAILED = -6 , UNSUPPORTED = -7 , AUTO_TRADING_DISABLED = -8 , INTERNAL_FAIL = -10000 , INTERNAL_FAIL_SEND = -10001 , INTERNAL_FAIL_RECEIVE = -10002 , INTERNAL_FAIL_INIT = -10003 , INTERNAL_FAIL_CONNECT = -10004 , INTERNAL_FAIL_TIMEOUT = -10005 } |
| Internal library return codes. More... | |
| enum class | SymbolType : int32_t { FOREX = 0 , FUTURES = 1 , STOCKS = 2 , BONDS = 3 , CRYPTO = 4 , ETFS = 5 , INDICES = 6 , COMMODITIES = 7 , OPTIONS = 8 , UNKNOWN = 9 } |
| Asset classes / Symbol types. More... | |
Functions | |
| TickFlag | operator| (TickFlag a, TickFlag b) |
| Overload for TickFlag bitwise combination. | |
| template<IsScopedEnum EnumClass> | |
| constexpr auto | operator+ (EnumClass a) noexcept |
| Unary + operator to extract the underlying integer value of a scoped enum. | |
Namespace containing MetaTrader 5 (MT5) client definitions and wrapper classes.
Namespace containing MetaTrader 5 (MT5) data structures, enumerations, and helper concepts.
|
strong |
|
strong |
Types of deals involved in trading.
|
strong |
|
strong |
|
strong |
States of an order.
|
strong |
Order types for market and pending orders.
|
strong |
Internal library return codes.
|
strong |
Mode of symbol margin and profit calculation.
|
strong |
Swap calculation modes.
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
Return codes from the trade server.
|
constexprnoexcept |
Unary + operator to extract the underlying integer value of a scoped enum.
| EnumClass | A scoped enumeration type. |
| a | The enum value. |