tbapi.api.bases.bar_type

 1from __future__ import annotations
 2from typing import TYPE_CHECKING
 3import clr
 4from tbapi.common.decorators import tb_class, tb_interface
 5from tbapi.common.converters import to_python_datetime, to_net_datetime
 6from datetime import datetime
 7from Tickblaze.Scripts.Api.Bases import BarType as _BarType
 8from typing import Any, overload
 9from abc import ABC, abstractmethod
10from tbapi.api.bases.symbol_script import SymbolScript
11from tbapi.api.bases.source_data_type import SourceDataType
12from tbapi.api.models.bar import Bar
13if TYPE_CHECKING:
14    from tbapi.api.models.symbol import Symbol
15    from tbapi.core.models.contract_settings import ContractSettings
16    from tbapi.api.bases.bar_type import BarType
17from tbapi.api.bases.source_data_type import SourceDataType
18_SourceDataType = _BarType.SourceDataType
19
20@tb_interface(_BarType)
21class BarType(SymbolScript):
22    """Represents a base class for defining custom bar types with metadata, bar series, and source data configuration."""
23
24    @staticmethod
25    def new(*args, **kwargs):
26        """Generic factory method for BarType. Use overloads for IDE type hints."""
27        return BarType(*args, **kwargs)
28
29    @property
30    def symbol(self) -> Symbol:
31        """The series underlying instrument"""
32        from tbapi.api.models.symbol import Symbol
33        val = self._value.Symbol
34        return Symbol(_existing=val)
35    @symbol.setter
36    def symbol(self, val: Symbol):
37        tmp = self._value
38        tmp.Symbol = val._value
39        self._value = tmp
40    @property
41    def is_eth(self) -> bool:
42        """The series hours (If false, hours are RTH)"""
43        val = self._value.IsETH
44        return val
45    @is_eth.setter
46    def is_eth(self, val: bool):
47        tmp = self._value
48        tmp.IsETH = val
49        self._value = tmp
50    @property
51    def contract_settings(self) -> ContractSettings:
52        """For futures symbols, details which kind of contract data this series represents (which specific contract if single contract, data merge rule otherwise)"""
53        from tbapi.core.models.contract_settings import ContractSettings
54        val = self._value.ContractSettings
55        return ContractSettings(_existing=val)
56    @contract_settings.setter
57    def contract_settings(self, val: ContractSettings):
58        tmp = self._value
59        tmp.ContractSettings = val._value
60        self._value = tmp
61    @property
62    def source(self) -> SourceDataType:
63        """The type of source data used to create the bar type."""
64        val = int(self._value.Source)
65        return SourceDataType(val)
66    @source.setter
67    def source(self, val: SourceDataType):
68        tmp = self._value
69        tmp.Source = _SourceDataType(val.value if hasattr(val, "value") else int(val))
70        self._value = tmp
71    @property
72    def input_parameter_display_string(self) -> str:
73        """A shorthand string to represent the input parameters, used in the data box, and anywhere else a short identifier is required"""
74        val = self._value.InputParameterDisplayString
75        return val
76
77    def add_bar(self, bar: Bar) -> None:
78        """Adds a new bar to the bar series.            The bar to add."""
79        result = self._value.AddBar(bar._value)
80        return result
81  
82    def update_bar(self, bar: Bar) -> None:
83        """Updates the most recent bar in the bar series.            The bar data to update."""
84        result = self._value.UpdateBar(bar._value)
85        return result
86  
87
88    @clr.clrmethod(None, [Bar])
89    def on_data_point(self, bar: Bar) -> None:
90        """Processes a data point to create or update a bar.            The bar data to process."""
91        ...
@tb_interface(_BarType)
class BarType(tbapi.api.bases.symbol_script.SymbolScript):
28@tb_interface(_BarType)
29class BarType(SymbolScript):
30    """Represents a base class for defining custom bar types with metadata, bar series, and source data configuration."""
31
32    @staticmethod
33    def new(*args, **kwargs):
34        """Generic factory method for BarType. Use overloads for IDE type hints."""
35        return BarType(*args, **kwargs)
36
37    @property
38    def symbol(self) -> Symbol:
39        """The series underlying instrument"""
40        from tbapi.api.models.symbol import Symbol
41        val = self._value.Symbol
42        return Symbol(_existing=val)
43    @symbol.setter
44    def symbol(self, val: Symbol):
45        tmp = self._value
46        tmp.Symbol = val._value
47        self._value = tmp
48    @property
49    def is_eth(self) -> bool:
50        """The series hours (If false, hours are RTH)"""
51        val = self._value.IsETH
52        return val
53    @is_eth.setter
54    def is_eth(self, val: bool):
55        tmp = self._value
56        tmp.IsETH = val
57        self._value = tmp
58    @property
59    def contract_settings(self) -> ContractSettings:
60        """For futures symbols, details which kind of contract data this series represents (which specific contract if single contract, data merge rule otherwise)"""
61        from tbapi.core.models.contract_settings import ContractSettings
62        val = self._value.ContractSettings
63        return ContractSettings(_existing=val)
64    @contract_settings.setter
65    def contract_settings(self, val: ContractSettings):
66        tmp = self._value
67        tmp.ContractSettings = val._value
68        self._value = tmp
69    @property
70    def source(self) -> SourceDataType:
71        """The type of source data used to create the bar type."""
72        val = int(self._value.Source)
73        return SourceDataType(val)
74    @source.setter
75    def source(self, val: SourceDataType):
76        tmp = self._value
77        tmp.Source = _SourceDataType(val.value if hasattr(val, "value") else int(val))
78        self._value = tmp
79    @property
80    def input_parameter_display_string(self) -> str:
81        """A shorthand string to represent the input parameters, used in the data box, and anywhere else a short identifier is required"""
82        val = self._value.InputParameterDisplayString
83        return val
84
85    def add_bar(self, bar: Bar) -> None:
86        """Adds a new bar to the bar series.            The bar to add."""
87        result = self._value.AddBar(bar._value)
88        return result
89  
90    def update_bar(self, bar: Bar) -> None:
91        """Updates the most recent bar in the bar series.            The bar data to update."""
92        result = self._value.UpdateBar(bar._value)
93        return result
94  
95
96    @clr.clrmethod(None, [Bar])
97    def on_data_point(self, bar: Bar) -> None:
98        """Processes a data point to create or update a bar.            The bar data to process."""
99        ...

Represents a base class for defining custom bar types with metadata, bar series, and source data configuration.

BarType(*args, **kwargs)
199        def __init__(self, *args, **kwargs):
200            pass
@staticmethod
def new(*args, **kwargs):
32    @staticmethod
33    def new(*args, **kwargs):
34        """Generic factory method for BarType. Use overloads for IDE type hints."""
35        return BarType(*args, **kwargs)

Generic factory method for BarType. Use overloads for IDE type hints.

symbol: tbapi.api.models.symbol.Symbol
37    @property
38    def symbol(self) -> Symbol:
39        """The series underlying instrument"""
40        from tbapi.api.models.symbol import Symbol
41        val = self._value.Symbol
42        return Symbol(_existing=val)

The series underlying instrument

is_eth: bool
48    @property
49    def is_eth(self) -> bool:
50        """The series hours (If false, hours are RTH)"""
51        val = self._value.IsETH
52        return val

The series hours (If false, hours are RTH)

58    @property
59    def contract_settings(self) -> ContractSettings:
60        """For futures symbols, details which kind of contract data this series represents (which specific contract if single contract, data merge rule otherwise)"""
61        from tbapi.core.models.contract_settings import ContractSettings
62        val = self._value.ContractSettings
63        return ContractSettings(_existing=val)

For futures symbols, details which kind of contract data this series represents (which specific contract if single contract, data merge rule otherwise)

69    @property
70    def source(self) -> SourceDataType:
71        """The type of source data used to create the bar type."""
72        val = int(self._value.Source)
73        return SourceDataType(val)

The type of source data used to create the bar type.

input_parameter_display_string: str
79    @property
80    def input_parameter_display_string(self) -> str:
81        """A shorthand string to represent the input parameters, used in the data box, and anywhere else a short identifier is required"""
82        val = self._value.InputParameterDisplayString
83        return val

A shorthand string to represent the input parameters, used in the data box, and anywhere else a short identifier is required

def add_bar(self, bar: tbapi.api.models.bar.Bar) -> None:
85    def add_bar(self, bar: Bar) -> None:
86        """Adds a new bar to the bar series.            The bar to add."""
87        result = self._value.AddBar(bar._value)
88        return result

Adds a new bar to the bar series. The bar to add.

def update_bar(self, bar: tbapi.api.models.bar.Bar) -> None:
90    def update_bar(self, bar: Bar) -> None:
91        """Updates the most recent bar in the bar series.            The bar data to update."""
92        result = self._value.UpdateBar(bar._value)
93        return result

Updates the most recent bar in the bar series. The bar data to update.

def on_data_point(unknown):

Method decorator for exposing python methods to .NET. The argument and return types must be specified as arguments to clrmethod.

e.g.::

class X(object):
    @clrmethod(int, [str])
    def test(self, x):
        return len(x)

Methods decorated this way can be called from .NET, e.g.::

dynamic x = getX(); // get an instance of X declared in Python
int z = x.test("hello"); // calls into python and returns len("hello")