tbapi.api.interfaces.orders.iposition_base

 1from __future__ import annotations
 2from typing import TYPE_CHECKING
 3from tbapi.common.decorators import tb_interface
 4from tbapi.common.converters import to_python_datetime, to_net_datetime
 5from datetime import datetime
 6from Tickblaze.Scripts.Api.Interfaces.Orders import IPositionBase as _IPositionBase
 7from typing import Any, overload
 8from abc import ABC, abstractmethod
 9from tbapi.api.enums.position_status import PositionStatus
10from tbapi.api.enums.order_direction import OrderDirection
11from Tickblaze.Scripts.Api.Enums import PositionStatus as _PositionStatus
12from Tickblaze.Scripts.Api.Enums import OrderDirection as _OrderDirection
13if TYPE_CHECKING:
14    from tbapi.api.interfaces.isymbol import ISymbol
15
16@tb_interface(_IPositionBase)
17class IPositionBase():
18
19    @property
20    def status(self) -> PositionStatus:
21        """Gets the current status of the position."""
22        val = int(self._value.Status)
23        return PositionStatus(val)
24    @property
25    def entry_price(self) -> float:
26        """Gets the price at which the position was entered."""
27        val = self._value.EntryPrice
28        return val
29    @property
30    def exit_price(self) -> float:
31        """Gets the price at which the position was exited. This is zero for an open position."""
32        val = self._value.ExitPrice
33        return val
34    @property
35    def quantity(self) -> float:
36        """Gets the quantity of the position."""
37        val = self._value.Quantity
38        return val
39    @property
40    def commission(self) -> float:
41        """Gets the total commission incurred for the position."""
42        val = self._value.Commission
43        return val
44    @property
45    def direction(self) -> OrderDirection:
46        """Gets the direction of the position, indicating whether it is long or short."""
47        val = int(self._value.Direction)
48        return OrderDirection(val)
49    @property
50    def unrealized_profit_loss(self) -> float:
51        """The unrealized profit/loss of the position"""
52        val = self._value.UnrealizedProfitLoss
53        return val
54    @property
55    def realized_profit_loss(self) -> float:
56        """The realized profit/loss of the position"""
57        val = self._value.RealizedProfitLoss
58        return val
59    @property
60    def current_price(self) -> float:
61        """The positions current price"""
62        val = self._value.CurrentPrice
63        return val
64    @property
65    def symbol(self) -> ISymbol:
66        """Gets the trading symbol associated with the position."""
67        from tbapi.api.interfaces.isymbol import ISymbol
68        val = self._value.Symbol
69        return ISymbol(_existing=val)
70    @symbol.setter
71    def symbol(self, val: ISymbol):
72        tmp = self._value
73        tmp.Symbol = val._value
74        self._value = tmp
@tb_interface(_IPositionBase)
class IPositionBase:
22@tb_interface(_IPositionBase)
23class IPositionBase():
24
25    @property
26    def status(self) -> PositionStatus:
27        """Gets the current status of the position."""
28        val = int(self._value.Status)
29        return PositionStatus(val)
30    @property
31    def entry_price(self) -> float:
32        """Gets the price at which the position was entered."""
33        val = self._value.EntryPrice
34        return val
35    @property
36    def exit_price(self) -> float:
37        """Gets the price at which the position was exited. This is zero for an open position."""
38        val = self._value.ExitPrice
39        return val
40    @property
41    def quantity(self) -> float:
42        """Gets the quantity of the position."""
43        val = self._value.Quantity
44        return val
45    @property
46    def commission(self) -> float:
47        """Gets the total commission incurred for the position."""
48        val = self._value.Commission
49        return val
50    @property
51    def direction(self) -> OrderDirection:
52        """Gets the direction of the position, indicating whether it is long or short."""
53        val = int(self._value.Direction)
54        return OrderDirection(val)
55    @property
56    def unrealized_profit_loss(self) -> float:
57        """The unrealized profit/loss of the position"""
58        val = self._value.UnrealizedProfitLoss
59        return val
60    @property
61    def realized_profit_loss(self) -> float:
62        """The realized profit/loss of the position"""
63        val = self._value.RealizedProfitLoss
64        return val
65    @property
66    def current_price(self) -> float:
67        """The positions current price"""
68        val = self._value.CurrentPrice
69        return val
70    @property
71    def symbol(self) -> ISymbol:
72        """Gets the trading symbol associated with the position."""
73        from tbapi.api.interfaces.isymbol import ISymbol
74        val = self._value.Symbol
75        return ISymbol(_existing=val)
76    @symbol.setter
77    def symbol(self, val: ISymbol):
78        tmp = self._value
79        tmp.Symbol = val._value
80        self._value = tmp
IPositionBase(*args, **kwargs)
199        def __init__(self, *args, **kwargs):
200            pass
25    @property
26    def status(self) -> PositionStatus:
27        """Gets the current status of the position."""
28        val = int(self._value.Status)
29        return PositionStatus(val)

Gets the current status of the position.

entry_price: float
30    @property
31    def entry_price(self) -> float:
32        """Gets the price at which the position was entered."""
33        val = self._value.EntryPrice
34        return val

Gets the price at which the position was entered.

exit_price: float
35    @property
36    def exit_price(self) -> float:
37        """Gets the price at which the position was exited. This is zero for an open position."""
38        val = self._value.ExitPrice
39        return val

Gets the price at which the position was exited. This is zero for an open position.

quantity: float
40    @property
41    def quantity(self) -> float:
42        """Gets the quantity of the position."""
43        val = self._value.Quantity
44        return val

Gets the quantity of the position.

commission: float
45    @property
46    def commission(self) -> float:
47        """Gets the total commission incurred for the position."""
48        val = self._value.Commission
49        return val

Gets the total commission incurred for the position.

50    @property
51    def direction(self) -> OrderDirection:
52        """Gets the direction of the position, indicating whether it is long or short."""
53        val = int(self._value.Direction)
54        return OrderDirection(val)

Gets the direction of the position, indicating whether it is long or short.

unrealized_profit_loss: float
55    @property
56    def unrealized_profit_loss(self) -> float:
57        """The unrealized profit/loss of the position"""
58        val = self._value.UnrealizedProfitLoss
59        return val

The unrealized profit/loss of the position

realized_profit_loss: float
60    @property
61    def realized_profit_loss(self) -> float:
62        """The realized profit/loss of the position"""
63        val = self._value.RealizedProfitLoss
64        return val

The realized profit/loss of the position

current_price: float
65    @property
66    def current_price(self) -> float:
67        """The positions current price"""
68        val = self._value.CurrentPrice
69        return val

The positions current price

70    @property
71    def symbol(self) -> ISymbol:
72        """Gets the trading symbol associated with the position."""
73        from tbapi.api.interfaces.isymbol import ISymbol
74        val = self._value.Symbol
75        return ISymbol(_existing=val)

Gets the trading symbol associated with the position.