tbapi.api.models.bar_period
1from __future__ import annotations 2from typing import TYPE_CHECKING 3from tbapi.common.decorators import tb_class, tb_interface 4from tbapi.common.converters import to_python_datetime, to_net_datetime 5from datetime import datetime 6from Tickblaze.Scripts.Api.Models import BarPeriod as _BarPeriod 7from typing import Any, overload 8from abc import ABC, abstractmethod 9from tbapi.api.models.source_type import SourceType 10from tbapi.api.models.period_type import PeriodType 11if TYPE_CHECKING: 12 from tbapi.api.models.bar_period import BarPeriod 13from tbapi.api.models.source_type import SourceType 14from tbapi.api.models.period_type import PeriodType 15_SourceType = _BarPeriod.SourceType 16_PeriodType = _BarPeriod.PeriodType 17 18@tb_class(_BarPeriod) 19class BarPeriod(): 20 """Represents the period of a bar, including its source type, period type, and size. The source of the bar period (e.g., Ask, Bid, Trade). The type of period for the bar (e.g., Day, Week, Minute). The size of the bar period (e.g., 5 minutes, 1 day).""" 21 22 @overload 23 @staticmethod 24 def new(Source: SourceType, Type: PeriodType, Size: float) -> "BarPeriod": 25 """Constructor overload with arguments: Source, Type, Size""" 26 ... 27 @staticmethod 28 def new(*args, **kwargs): 29 """Generic factory method for BarPeriod. Use overloads for IDE type hints.""" 30 return BarPeriod(*args, **kwargs) 31 32 @property 33 def source(self) -> SourceType: 34 """The source of the bar period (e.g., Ask, Bid, Trade).""" 35 val = int(self._value.Source) 36 return SourceType(val) 37 @source.setter 38 def source(self, val: SourceType): 39 tmp = self._value 40 tmp.Source = _SourceType(val.value if hasattr(val, "value") else int(val)) 41 self._value = tmp 42 @property 43 def type(self) -> PeriodType: 44 """The type of period for the bar (e.g., Day, Week, Minute).""" 45 val = int(self._value.Type) 46 return PeriodType(val) 47 @type.setter 48 def type(self, val: PeriodType): 49 tmp = self._value 50 tmp.Type = _PeriodType(val.value if hasattr(val, "value") else int(val)) 51 self._value = tmp 52 @property 53 def size(self) -> float: 54 """The size of the bar period (e.g., 5 minutes, 1 day).""" 55 val = self._value.Size 56 return val 57 @size.setter 58 def size(self, val: float): 59 tmp = self._value 60 tmp.Size = val 61 self._value = tmp
@tb_class(_BarPeriod)
class
BarPeriod:
26@tb_class(_BarPeriod) 27class BarPeriod(): 28 """Represents the period of a bar, including its source type, period type, and size. The source of the bar period (e.g., Ask, Bid, Trade). The type of period for the bar (e.g., Day, Week, Minute). The size of the bar period (e.g., 5 minutes, 1 day).""" 29 30 @overload 31 @staticmethod 32 def new(Source: SourceType, Type: PeriodType, Size: float) -> "BarPeriod": 33 """Constructor overload with arguments: Source, Type, Size""" 34 ... 35 @staticmethod 36 def new(*args, **kwargs): 37 """Generic factory method for BarPeriod. Use overloads for IDE type hints.""" 38 return BarPeriod(*args, **kwargs) 39 40 @property 41 def source(self) -> SourceType: 42 """The source of the bar period (e.g., Ask, Bid, Trade).""" 43 val = int(self._value.Source) 44 return SourceType(val) 45 @source.setter 46 def source(self, val: SourceType): 47 tmp = self._value 48 tmp.Source = _SourceType(val.value if hasattr(val, "value") else int(val)) 49 self._value = tmp 50 @property 51 def type(self) -> PeriodType: 52 """The type of period for the bar (e.g., Day, Week, Minute).""" 53 val = int(self._value.Type) 54 return PeriodType(val) 55 @type.setter 56 def type(self, val: PeriodType): 57 tmp = self._value 58 tmp.Type = _PeriodType(val.value if hasattr(val, "value") else int(val)) 59 self._value = tmp 60 @property 61 def size(self) -> float: 62 """The size of the bar period (e.g., 5 minutes, 1 day).""" 63 val = self._value.Size 64 return val 65 @size.setter 66 def size(self, val: float): 67 tmp = self._value 68 tmp.Size = val 69 self._value = tmp
Represents the period of a bar, including its source type, period type, and size. The source of the bar period (e.g., Ask, Bid, Trade). The type of period for the bar (e.g., Day, Week, Minute). The size of the bar period (e.g., 5 minutes, 1 day).
@staticmethod
def
new(*args, **kwargs):
35 @staticmethod 36 def new(*args, **kwargs): 37 """Generic factory method for BarPeriod. Use overloads for IDE type hints.""" 38 return BarPeriod(*args, **kwargs)
Generic factory method for BarPeriod. Use overloads for IDE type hints.
40 @property 41 def source(self) -> SourceType: 42 """The source of the bar period (e.g., Ask, Bid, Trade).""" 43 val = int(self._value.Source) 44 return SourceType(val)
The source of the bar period (e.g., Ask, Bid, Trade).