Files
aiomql/docs/lib/ticks.md
T

160 lines
7.0 KiB
Markdown
Raw Normal View History

2024-02-12 21:09:28 +01:00
# Tick and Ticks
2023-10-11 09:49:06 +01:00
Module for working with price ticks.
2024-02-12 21:09:28 +01:00
## Table of Contents
2024-11-10 12:25:50 +01:00
- [Tick](#tick.tick)
2024-02-12 21:09:28 +01:00
- [\_\_init\_\_](#tick.__init__)
2024-11-10 12:25:50 +01:00
- [set_attributes](#tick.set_attributes)
- [Ticks](#ticks.ticks)
- [\__init\__](#ticks.__init__)
2024-02-12 21:09:28 +01:00
- [ta](#ticks.ta)
2024-11-10 12:25:50 +01:00
- [ta_lib](#ticks.ta_lib)
2024-02-12 21:09:28 +01:00
- [data](#ticks.data)
- [rename](#ticks.rename)
2024-11-10 12:25:50 +01:00
<a id='tick.tick'></a>
2024-02-12 21:09:28 +01:00
## Tick
2023-10-11 09:49:06 +01:00
```python
class Tick()
```
Price Tick of a Financial Instrument.
2024-11-10 12:25:50 +01:00
#### Attributes:
2024-02-12 21:09:28 +01:00
| Name | Type | Description | Default |
|---------------|------------|-----------------------------------------------------------------------|---------|
| `symbol` | `Symbol` | The Financial Instrument as a Symbol Object | None |
| `time` | `datetime` | Time of the last prices update for the symbol | None |
| `bid` | `float` | Current Bid price | None |
| `ask` | `float` | Current Ask price | None |
| `last` | `float` | Price of the last deal (Last) | None |
| `volume` | `float` | Volume for the current Last price | None |
| `time_msc` | `int` | Time of the last prices update for the symbol in milliseconds | None |
| `flags` | `TickFlag` | Tick flags | None |
| `volume_real` | `float` | Volume for the current Last price | None |
| `Index` | `int` | Custom attribute representing the position of the tick in a sequence. | None |
2023-10-16 15:36:31 +01:00
2024-11-10 12:25:50 +01:00
2024-02-12 21:09:28 +01:00
<a id="tick.__init__"></a>
2024-11-10 12:25:50 +01:00
### \__init\__
2024-02-12 21:09:28 +01:00
```python
def __init__(self, **kwargs):
```
Initialize the Tick class. Set attributes from keyword arguments.The `bid`, `ask`, `last`, `time` and `volume` must be present
2024-11-10 12:25:50 +01:00
2024-02-12 21:09:28 +01:00
<a id="tick.set_attributes"></a>
2024-11-10 12:25:50 +01:00
### set_attributes
2023-10-11 09:49:06 +01:00
```python
def set_attributes(**kwargs)
```
Set attributes from keyword arguments
2024-11-10 12:25:50 +01:00
<a id="tick.dict"></a>
### dict
```python
def dict(exclude: set = None, include: set = None) -> dict
```
Return a dictionary of the tick attributes.
#### Parameters:
| Name | Type | Description | Default |
|-----------|-------|-----------------------------------------------------|---------|
| `exclude` | `set` | A set of attributes to exclude from the dictionary. | None |
| `include` | `set` | A set of attributes to include in the dictionary. | None |
<a id="ticks.ticks"></a>
2023-10-16 15:36:31 +01:00
## Ticks
2023-10-11 09:49:06 +01:00
```python
2024-11-10 12:25:50 +01:00
class Ticks
2023-10-11 09:49:06 +01:00
```
2024-02-12 21:09:28 +01:00
Container data class for price ticks. Arrange in chronological order. Saves data with a pandas DataFrame.
Supports iteration, slicing and assignment. Similar to `Candles` class but for price ticks.
2024-11-10 12:25:50 +01:00
#### Attributes:
| Name | Type | Description | Default |
|---------------|-------------|----------------------------------------------------------------------|---------|
| `data` | `DataFrame` | DataFrame of price ticks arranged in chronological order. | None |
| `time` | `Series` | Time of the last prices update for the symbol | None |
| `bid` | `Series` | Current Bid price | None |
| `ask` | `Series` | Current Ask price | None |
| `last` | `Series` | Price of the last deal (Last) | None |
| `volume` | `Series` | Volume for the current Last price | None |
| `time_msc` | `Series` | Time of the last prices update for the symbol in milliseconds | None |
| `flags` | `Series` | Tick flags | None |
| `volume_real` | `Series` | Volume for the current Last price | None |
| `Index` | `Series` | Custom attribute representing the position of the tick in a sequence | None |
2024-02-12 21:09:28 +01:00
2023-10-11 09:49:06 +01:00
2024-02-12 21:09:28 +01:00
<a id="ticks.__init__"></a>
2024-11-10 12:25:50 +01:00
### \__init\__
2023-10-11 09:49:06 +01:00
```python
def __init__(*, data: DataFrame | Iterable, flip=False)
```
Initialize the Ticks class. Creates a DataFrame of price ticks from the data argument.
2023-10-16 15:36:31 +01:00
#### Arguments:
2024-02-12 21:09:28 +01:00
| Name | Type | Description | Default |
|--------|---------------------------|---------------------------------------------------------------------------------------------|---------|
| `data` | `DataFrame` \| `Iterable` | Dataframe of price ticks or any iterable object that can be converted to a pandas DataFrame | None |
| `flip` | `bool` | If flip is True reverse data chronological order. | False |
2023-10-11 09:49:06 +01:00
2024-11-10 12:25:50 +01:00
2024-02-12 21:09:28 +01:00
<a id="ticks.ta"></a>
2023-10-16 15:36:31 +01:00
### ta
2023-10-11 09:49:06 +01:00
```python
@property
def ta()
```
Access to the pandas_ta library for performing technical analysis on the underlying data attribute.
2024-11-10 12:25:50 +01:00
#### Returns:
2024-02-12 21:09:28 +01:00
| Name | Type | Description |
|-------------|-------------|-----------------------|
| `pandas_ta` | `pandas_ta` | The pandas_ta library |
2023-10-11 09:49:06 +01:00
2024-11-10 12:25:50 +01:00
2024-02-12 21:09:28 +01:00
<a id="ticks.ta_lib"></a>
2024-11-10 12:25:50 +01:00
### ta_lib
2023-10-11 09:49:06 +01:00
```python
@property
def ta_lib()
```
Access to the ta library for performing technical analysis. Not dependent on the underlying data attribute.
2024-11-10 12:25:50 +01:00
#### Returns:
2024-02-12 21:09:28 +01:00
| Name | Type | Description |
|------|------|----------------|
| `ta` | `ta` | The ta library |
2023-10-11 09:49:06 +01:00
2024-11-10 12:25:50 +01:00
2024-02-12 21:09:28 +01:00
<a id="ticks.data"></a>
2023-10-16 15:36:31 +01:00
### data
2023-10-11 09:49:06 +01:00
```python
@property
def data() -> DataFrame
```
DataFrame of price ticks arranged in chronological order.
2024-11-10 12:25:50 +01:00
#### Returns:
2024-02-12 21:09:28 +01:00
| Name | Type | Description |
|--------|-------------|-----------------------------------------------------------|
| `data` | `DataFrame` | DataFrame of price ticks arranged in chronological order. |
2023-10-11 09:49:06 +01:00
2024-11-10 12:25:50 +01:00
2024-02-12 21:09:28 +01:00
<a id="ticks.rename"></a>
2023-10-16 15:36:31 +01:00
### rename
2023-10-11 09:49:06 +01:00
```python
def rename(inplace=True, **kwargs) -> _Ticks | None
```
Rename columns of the candle class.
2024-11-10 12:25:50 +01:00
#### Arguments:
2024-02-12 21:09:28 +01:00
| Name | Type | Description | Default |
|-----------|--------|-------------------------------------------------------------------------------------------|---------|
| `inplace` | `bool` | Rename the columns inplace or return a new instance of the class with the renamed columns | True |
| `kwargs` | | The new names of the columns | |
2024-11-10 12:25:50 +01:00
#### Returns:
2024-02-12 21:09:28 +01:00
| Type | Description |
|---------|---------------------------------------------------------------------------|
| `Ticks` | A new instance of the class with the renamed columns if inplace is False. |
| `None` | If inplace is True |