Positions
Table of contents
Positions
Get and handle Open positions.
Attributes
| Name |
Type |
Description |
positions |
tuple[TradePosition, ...] |
Financial instrument name. |
mt5 |
MetaTrader |
MetaTrader instance. |
__init__
Initialize a position instance
get_positions
Get open positions
Returns
| Type |
Description |
tuple[TradePosition, ...] |
A list of open trade positions |
get_position_by_ticket
Get a position by ticket id.
Parameters:
| Name |
Type |
Description |
ticket |
int |
Position ticket |
Returns:
| Type |
Description |
TradePosition |
Trade position |
get_positions_by_symbol
Filter positions by symbols
Parameters:
| Name |
Type |
Description |
symbol |
str |
Symbol |
Returns:
| Type |
Description |
tuple[TradePosition, ...] |
Trade position |
close
Close a position using its details.
Parameters:
| Name |
Type |
Description |
ticket |
int |
Position ticket. |
symbol |
str |
Financial instrument name. |
price |
float |
Closing price. |
volume |
float |
Volume to close. |
order_type |
OrderType |
Order type. |
Returns:
| Type |
Description |
OrderSendResult |
The result of the order sent to close the position |
close_position
Close a position by position object.
Parameters:
| Name |
Type |
Description |
position |
TradePosition |
Position object |
Returns:
| Type |
Description |
OrderSendResult |
The result of the order sent to close the position |
close_position_by_ticket
Close a position by position object.
Parameters:
| Name |
Type |
Description |
position |
TradePosition |
Position object |
Returns:
| Type |
Description |
OrderSendResult |
The result of the order sent to close the position |
close_all
Close all open positions for the trading account.
Returns:
| Type |
Description |
int |
Return total number of closed trades |