tbapi.api.models.bar
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 Bar as _Bar 7from typing import Any, overload 8from abc import ABC, abstractmethod 9 10@tb_class(_Bar) 11class Bar(): 12 """Represents a single bar of market data, including the open, high, low, close prices, volume, and time.""" 13 14 @overload 15 @staticmethod 16 def new() -> "Bar": 17 """Constructor overload with arguments: """ 18 ... 19 @overload 20 @staticmethod 21 def new(time: datetime, open: float, high: float, low: float, close: float, volume: float) -> "Bar": 22 """Constructor overload with arguments: time, open, high, low, close, volume""" 23 ... 24 @staticmethod 25 def new(*args, **kwargs): 26 """Generic factory method for Bar. Use overloads for IDE type hints.""" 27 return Bar(*args, **kwargs) 28 29 @property 30 def time(self) -> datetime: 31 val = self._value.Time 32 return to_python_datetime(val) 33 @time.setter 34 def time(self, val: datetime): 35 tmp = self._value 36 tmp.Time = to_net_datetime(val) 37 self._value = tmp 38 @property 39 def open(self) -> float: 40 val = self._value.Open 41 return val 42 @open.setter 43 def open(self, val: float): 44 tmp = self._value 45 tmp.Open = val 46 self._value = tmp 47 @property 48 def high(self) -> float: 49 val = self._value.High 50 return val 51 @high.setter 52 def high(self, val: float): 53 tmp = self._value 54 tmp.High = val 55 self._value = tmp 56 @property 57 def low(self) -> float: 58 val = self._value.Low 59 return val 60 @low.setter 61 def low(self, val: float): 62 tmp = self._value 63 tmp.Low = val 64 self._value = tmp 65 @property 66 def close(self) -> float: 67 val = self._value.Close 68 return val 69 @close.setter 70 def close(self, val: float): 71 tmp = self._value 72 tmp.Close = val 73 self._value = tmp 74 @property 75 def volume(self) -> float: 76 val = self._value.Volume 77 return val 78 @volume.setter 79 def volume(self, val: float): 80 tmp = self._value 81 tmp.Volume = val 82 self._value = tmp 83 @property 84 def is_complete(self) -> bool: 85 val = self._value.IsComplete 86 return val 87 @is_complete.setter 88 def is_complete(self, val: bool): 89 tmp = self._value 90 tmp.IsComplete = val 91 self._value = tmp 92 @property 93 def is_historical(self) -> bool: 94 val = self._value.IsHistorical 95 return val 96 @is_historical.setter 97 def is_historical(self, val: bool): 98 tmp = self._value 99 tmp.IsHistorical = val 100 self._value = tmp 101 @property 102 def body_ratio(self) -> float: 103 """Returns the ratio of the candle body to overall bar height ratio""" 104 val = self._value.BodyRatio 105 return val 106 @property 107 def end_time(self) -> datetime: 108 """The end time of the bar""" 109 val = self._value.EndTime 110 return to_python_datetime(val) 111 @end_time.setter 112 def end_time(self, val: datetime): 113 tmp = self._value 114 tmp.EndTime = to_net_datetime(val) 115 self._value = tmp
@tb_class(_Bar)
class
Bar:
18@tb_class(_Bar) 19class Bar(): 20 """Represents a single bar of market data, including the open, high, low, close prices, volume, and time.""" 21 22 @overload 23 @staticmethod 24 def new() -> "Bar": 25 """Constructor overload with arguments: """ 26 ... 27 @overload 28 @staticmethod 29 def new(time: datetime, open: float, high: float, low: float, close: float, volume: float) -> "Bar": 30 """Constructor overload with arguments: time, open, high, low, close, volume""" 31 ... 32 @staticmethod 33 def new(*args, **kwargs): 34 """Generic factory method for Bar. Use overloads for IDE type hints.""" 35 return Bar(*args, **kwargs) 36 37 @property 38 def time(self) -> datetime: 39 val = self._value.Time 40 return to_python_datetime(val) 41 @time.setter 42 def time(self, val: datetime): 43 tmp = self._value 44 tmp.Time = to_net_datetime(val) 45 self._value = tmp 46 @property 47 def open(self) -> float: 48 val = self._value.Open 49 return val 50 @open.setter 51 def open(self, val: float): 52 tmp = self._value 53 tmp.Open = val 54 self._value = tmp 55 @property 56 def high(self) -> float: 57 val = self._value.High 58 return val 59 @high.setter 60 def high(self, val: float): 61 tmp = self._value 62 tmp.High = val 63 self._value = tmp 64 @property 65 def low(self) -> float: 66 val = self._value.Low 67 return val 68 @low.setter 69 def low(self, val: float): 70 tmp = self._value 71 tmp.Low = val 72 self._value = tmp 73 @property 74 def close(self) -> float: 75 val = self._value.Close 76 return val 77 @close.setter 78 def close(self, val: float): 79 tmp = self._value 80 tmp.Close = val 81 self._value = tmp 82 @property 83 def volume(self) -> float: 84 val = self._value.Volume 85 return val 86 @volume.setter 87 def volume(self, val: float): 88 tmp = self._value 89 tmp.Volume = val 90 self._value = tmp 91 @property 92 def is_complete(self) -> bool: 93 val = self._value.IsComplete 94 return val 95 @is_complete.setter 96 def is_complete(self, val: bool): 97 tmp = self._value 98 tmp.IsComplete = val 99 self._value = tmp 100 @property 101 def is_historical(self) -> bool: 102 val = self._value.IsHistorical 103 return val 104 @is_historical.setter 105 def is_historical(self, val: bool): 106 tmp = self._value 107 tmp.IsHistorical = val 108 self._value = tmp 109 @property 110 def body_ratio(self) -> float: 111 """Returns the ratio of the candle body to overall bar height ratio""" 112 val = self._value.BodyRatio 113 return val 114 @property 115 def end_time(self) -> datetime: 116 """The end time of the bar""" 117 val = self._value.EndTime 118 return to_python_datetime(val) 119 @end_time.setter 120 def end_time(self, val: datetime): 121 tmp = self._value 122 tmp.EndTime = to_net_datetime(val) 123 self._value = tmp
Represents a single bar of market data, including the open, high, low, close prices, volume, and time.
@staticmethod
def
new(*args, **kwargs):
32 @staticmethod 33 def new(*args, **kwargs): 34 """Generic factory method for Bar. Use overloads for IDE type hints.""" 35 return Bar(*args, **kwargs)
Generic factory method for Bar. Use overloads for IDE type hints.