PyAlgoEngine 0.8.0a7__tar.gz → 0.8.0a10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/PKG-INFO +1 -1
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/PyAlgoEngine.egg-info/PKG-INFO +1 -1
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/PyAlgoEngine.egg-info/SOURCES.txt +6 -1
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/__init__.py +1 -1
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/base/__init__.py +11 -12
- pyalgoengine-0.8.0a10/algo_engine/base/candlestick.pyi +111 -0
- pyalgoengine-0.8.0a10/algo_engine/base/market_data.pyi +47 -0
- pyalgoengine-0.8.0a10/algo_engine/base/market_data_buffer.pyi +87 -0
- pyalgoengine-0.8.0a10/algo_engine/base/tick.pyi +110 -0
- pyalgoengine-0.8.0a10/algo_engine/base/trade_utils.pyi +221 -0
- pyalgoengine-0.8.0a10/algo_engine/base/transaction.pyi +211 -0
- pyalgoengine-0.8.0a7/algo_engine/base/trade_utils.py +0 -693
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/LICENSE +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/PyAlgoEngine.egg-info/dependency_links.txt +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/PyAlgoEngine.egg-info/requires.txt +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/PyAlgoEngine.egg-info/top_level.txt +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/README.md +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/backtest/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/backtest/doc_server.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/backtest/tester.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/backtest/web_app.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/bokeh_server.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/demo/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/demo/test.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/sim_input/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/sim_input/client.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/sim_input/sim_keyboard.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/sim_input/sim_mouse.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/apps/sim_input/window.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/backtest/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/backtest/__main__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/backtest/metrics.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/backtest/replay.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/backtest/sim_match.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/base/console_utils.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/base/finance_decimal.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/base/market_utils_nt.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/base/market_utils_posix.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/base/technical_analysis.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/base/telemetrics.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/engine/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/engine/algo_engine.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/engine/event_engine.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/engine/market_engine.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/engine/trade_engine.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/monitor/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/monitor/advanced_data_interface.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/profile/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/profile/cn.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/strategy/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/strategy/strategy_engine.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/utils/__init__.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/utils/commit_regularizer.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/algo_engine/utils/data_utils.py +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/setup.cfg +0 -0
- {pyalgoengine-0.8.0a7 → pyalgoengine-0.8.0a10}/setup.py +0 -0
|
@@ -26,13 +26,18 @@ algo_engine/backtest/metrics.py
|
|
|
26
26
|
algo_engine/backtest/replay.py
|
|
27
27
|
algo_engine/backtest/sim_match.py
|
|
28
28
|
algo_engine/base/__init__.py
|
|
29
|
+
algo_engine/base/candlestick.pyi
|
|
29
30
|
algo_engine/base/console_utils.py
|
|
30
31
|
algo_engine/base/finance_decimal.py
|
|
32
|
+
algo_engine/base/market_data.pyi
|
|
33
|
+
algo_engine/base/market_data_buffer.pyi
|
|
31
34
|
algo_engine/base/market_utils_nt.py
|
|
32
35
|
algo_engine/base/market_utils_posix.py
|
|
33
36
|
algo_engine/base/technical_analysis.py
|
|
34
37
|
algo_engine/base/telemetrics.py
|
|
35
|
-
algo_engine/base/
|
|
38
|
+
algo_engine/base/tick.pyi
|
|
39
|
+
algo_engine/base/trade_utils.pyi
|
|
40
|
+
algo_engine/base/transaction.pyi
|
|
36
41
|
algo_engine/engine/__init__.py
|
|
37
42
|
algo_engine/engine/algo_engine.py
|
|
38
43
|
algo_engine/engine/event_engine.py
|
|
@@ -9,19 +9,13 @@ from ..profile import PROFILE
|
|
|
9
9
|
def set_logger(logger: logging.Logger):
|
|
10
10
|
global LOGGER
|
|
11
11
|
LOGGER = logger
|
|
12
|
-
|
|
13
|
-
if os.name == 'nt':
|
|
14
|
-
market_utils_nt.LOGGER = logger.getChild('MarketUtils')
|
|
15
|
-
else:
|
|
16
|
-
market_utils_posix.LOGGER = logger.getChild('MarketUtils')
|
|
17
|
-
|
|
18
12
|
trade_utils.LOGGER = logger.getChild('TradeUtils')
|
|
19
13
|
technical_analysis.LOGGER = logger.getChild('TA')
|
|
20
14
|
console_utils.LOGGER = logger.getChild('Console')
|
|
21
15
|
|
|
22
16
|
|
|
23
|
-
def check_cython_module() -> bool:
|
|
24
|
-
for name in
|
|
17
|
+
def check_cython_module(cython_module) -> bool:
|
|
18
|
+
for name in cython_module:
|
|
25
19
|
cython_ext = '.pyd' if os.name == 'nt' else '.so'
|
|
26
20
|
for file in pathlib.Path(__file__).parent.glob(f'*{cython_ext}'):
|
|
27
21
|
if file.name.startswith(name):
|
|
@@ -35,24 +29,29 @@ def check_cython_module() -> bool:
|
|
|
35
29
|
|
|
36
30
|
from .finance_decimal import FinancialDecimal
|
|
37
31
|
|
|
38
|
-
if check_cython_module():
|
|
32
|
+
if check_cython_module(['market_data', 'transaction', 'tick', 'candlestick', 'market_data_buffer']):
|
|
39
33
|
from .market_data import MarketData
|
|
40
34
|
from .transaction import TransactionDirection, TransactionOffset, TransactionSide, OrderType, TransactionData, TradeData, OrderData
|
|
41
35
|
from .tick import TickDataLite, TickData
|
|
42
36
|
from .candlestick import BarData, DailyBar
|
|
43
|
-
from .market_data_buffer import MarketDataBuffer
|
|
37
|
+
from .market_data_buffer import MarketDataBuffer, MarketDataRingBuffer, MarketDataConcurrentBuffer
|
|
44
38
|
else:
|
|
45
39
|
import_cmd = f'from .market_utils_{os.name} import TransactionSide, OrderType, MarketData, OrderBook, BarData, DailyBar, CandleStick, TickData, TransactionData, TradeData, OrderData, MarketDataBuffer, MarketDataRingBuffer'
|
|
46
40
|
eval(import_cmd)
|
|
47
41
|
|
|
42
|
+
if check_cython_module(['trade_utils']):
|
|
43
|
+
from .trade_utils import OrderState, TradeInstruction, TradeReport
|
|
44
|
+
else:
|
|
45
|
+
import_cmd = f'from .trade_utils_native import OrderState, TradeInstruction, TradeReport'
|
|
46
|
+
eval(import_cmd)
|
|
47
|
+
|
|
48
48
|
from .technical_analysis import TechnicalAnalysis
|
|
49
|
-
from .trade_utils import OrderState, TradeInstruction, TradeReport
|
|
50
49
|
from .console_utils import Progress, GetInput, GetArgs, count_ordinal, TerminalStyle, InteractiveShell, ShellTransfer
|
|
51
50
|
|
|
52
51
|
__all__ = [
|
|
53
52
|
'PROFILE',
|
|
54
53
|
'FinancialDecimal',
|
|
55
|
-
'TransactionDirection', 'TransactionOffset', 'TransactionSide', 'OrderType', 'MarketData', 'BarData', 'DailyBar', 'TickDataLite', 'TickData', 'TransactionData', 'TradeData', 'OrderData', 'MarketDataBuffer',
|
|
54
|
+
'TransactionDirection', 'TransactionOffset', 'TransactionSide', 'OrderType', 'MarketData', 'BarData', 'DailyBar', 'TickDataLite', 'TickData', 'TransactionData', 'TradeData', 'OrderData', 'MarketDataBuffer', 'MarketDataRingBuffer', 'MarketDataConcurrentBuffer',
|
|
56
55
|
# 'MarketDataMemoryBuffer', 'OrderBookBuffer', 'BarDataBuffer', 'TickDataBuffer', 'TransactionDataBuffer',
|
|
57
56
|
# 'MarketDataPointer', 'OrderBookPointer', 'BarDataPointer', 'TickDataPointer', 'TransactionDataPointer',
|
|
58
57
|
'TechnicalAnalysis',
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import date, datetime, timedelta
|
|
4
|
+
from typing import Any, Dict, Literal
|
|
5
|
+
|
|
6
|
+
from .market_data import MarketData
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BarData(MarketData):
|
|
10
|
+
_additional: Dict[str, Any]
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
ticker: str,
|
|
15
|
+
timestamp: float,
|
|
16
|
+
high_price: float,
|
|
17
|
+
low_price: float,
|
|
18
|
+
open_price: float,
|
|
19
|
+
close_price: float,
|
|
20
|
+
volume: float = ...,
|
|
21
|
+
notional: float = ...,
|
|
22
|
+
trade_count: int = ...,
|
|
23
|
+
start_timestamp: float = ...,
|
|
24
|
+
bar_span: timedelta | float | None = ...,
|
|
25
|
+
**kwargs: Any
|
|
26
|
+
) -> None: ...
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def from_buffer(cls, buffer: bytes | memoryview) -> BarData: ...
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def from_bytes(cls, data: bytes) -> BarData: ...
|
|
33
|
+
|
|
34
|
+
def __copy__(self) -> BarData: ...
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def high_price(self) -> float: ...
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def low_price(self) -> float: ...
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def open_price(self) -> float: ...
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def close_price(self) -> float: ...
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def volume(self) -> float: ...
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def notional(self) -> float: ...
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def trade_count(self) -> int: ...
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def start_timestamp(self) -> float: ...
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def bar_span_seconds(self) -> float: ...
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def bar_span(self) -> timedelta: ...
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def vwap(self) -> float: ...
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def bar_type(self) -> Literal['Hourly-Plus', 'Hourly', 'Minute-Plus', 'Minute', 'Sub-Minute']: ...
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def bar_end_time(self) -> datetime: ...
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def bar_start_time(self) -> datetime: ...
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class DailyBar(BarData):
|
|
80
|
+
def __init__(
|
|
81
|
+
self,
|
|
82
|
+
ticker: str,
|
|
83
|
+
market_date: date,
|
|
84
|
+
high_price: float,
|
|
85
|
+
low_price: float,
|
|
86
|
+
open_price: float,
|
|
87
|
+
close_price: float,
|
|
88
|
+
volume: float = ...,
|
|
89
|
+
notional: float = ...,
|
|
90
|
+
trade_count: int = ...,
|
|
91
|
+
bar_span: int = ...,
|
|
92
|
+
**kwargs: Any
|
|
93
|
+
) -> None: ...
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def market_date(self) -> date: ...
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def market_time(self) -> date: ...
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def bar_start_time(self) -> date: ...
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def bar_end_time(self) -> date: ...
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def bar_span(self) -> timedelta: ...
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def bar_type(self) -> Literal['Daily', 'Daily-Plus']: ...
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PyDataType(enum.IntEnum):
|
|
7
|
+
DTYPE_UNKNOWN: int
|
|
8
|
+
DTYPE_MARKET_DATA: int
|
|
9
|
+
DTYPE_TRANSACTION: int
|
|
10
|
+
DTYPE_ORDER: int
|
|
11
|
+
DTYPE_TICK_LITE: int
|
|
12
|
+
DTYPE_TICK: int
|
|
13
|
+
DTYPE_BAR: int
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MarketData:
|
|
17
|
+
_additional: dict[str, Any]
|
|
18
|
+
|
|
19
|
+
def __init__(self, ticker: str, timestamp: float, **kwargs: Any) -> None: ...
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def from_buffer(cls, buffer: bytes) -> 'MarketData': ...
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def from_bytes(cls, data: bytes) -> 'MarketData': ...
|
|
26
|
+
|
|
27
|
+
def __copy__(self) -> 'MarketData': ...
|
|
28
|
+
|
|
29
|
+
def to_bytes(self) -> bytes: ...
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def ticker(self) -> str: ...
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def timestamp(self) -> float: ...
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def dtype(self) -> int: ...
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def topic(self) -> str: ...
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def market_time(self) -> datetime: ...
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def market_price(self) -> float: ...
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from .candlestick import BarData
|
|
6
|
+
from .market_data import MarketData
|
|
7
|
+
from .tick import TickData, TickDataLite
|
|
8
|
+
from .transaction import TransactionData, OrderData
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MarketDataBuffer:
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
buffer: Any,
|
|
15
|
+
dtype: int = ...,
|
|
16
|
+
capacity: int = ...
|
|
17
|
+
) -> None: ...
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def from_buffer(cls, buffer: Any) -> MarketDataBuffer: ...
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def from_bytes(cls, data: bytes, buffer: Any) -> MarketDataBuffer: ...
|
|
24
|
+
|
|
25
|
+
def push(self, market_data: MarketData) -> None: ...
|
|
26
|
+
|
|
27
|
+
def sort(self, inplace: bool = ...) -> None: ...
|
|
28
|
+
|
|
29
|
+
def to_bytes(self) -> bytes: ...
|
|
30
|
+
|
|
31
|
+
def update(self, dtype: int, **kwargs: dict[str, Any]) -> None: ...
|
|
32
|
+
|
|
33
|
+
def __iter__(self) -> MarketDataBuffer: ...
|
|
34
|
+
|
|
35
|
+
def __next__(self) -> MarketData | TransactionData | OrderData | TickDataLite | TickData | BarData: ...
|
|
36
|
+
|
|
37
|
+
def __len__(self) -> int: ...
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class MarketDataRingBuffer(MarketDataBuffer):
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
buffer: Any,
|
|
44
|
+
dtype: int = ...,
|
|
45
|
+
capacity: int = ...
|
|
46
|
+
) -> None: ...
|
|
47
|
+
|
|
48
|
+
def is_empty(self) -> bool: ...
|
|
49
|
+
|
|
50
|
+
def is_full(self) -> bool: ...
|
|
51
|
+
|
|
52
|
+
def put(self, market_data: MarketData) -> None: ...
|
|
53
|
+
|
|
54
|
+
def get(self, idx: int) -> MarketData | TransactionData | OrderData | TickDataLite | TickData | BarData: ...
|
|
55
|
+
|
|
56
|
+
def listen(self) -> MarketData | TransactionData | OrderData | TickDataLite | TickData | BarData: ...
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def head(self) -> int: ...
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def tail(self) -> int: ...
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def count(self) -> int: ...
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class MarketDataConcurrentBuffer(MarketDataBuffer):
|
|
69
|
+
def __init__(
|
|
70
|
+
self,
|
|
71
|
+
buffer: Any,
|
|
72
|
+
n_workers: int,
|
|
73
|
+
dtype: int = ...,
|
|
74
|
+
capacity: int = ...
|
|
75
|
+
) -> None: ...
|
|
76
|
+
|
|
77
|
+
def is_empty(self, worker_id: int) -> bool: ...
|
|
78
|
+
|
|
79
|
+
def is_empty_all(self) -> bool: ...
|
|
80
|
+
|
|
81
|
+
def is_full(self) -> bool: ...
|
|
82
|
+
|
|
83
|
+
def put(self, market_data: MarketData) -> None: ...
|
|
84
|
+
|
|
85
|
+
def get(self, idx: int) -> MarketData | TransactionData | OrderData | TickDataLite | TickData | BarData: ...
|
|
86
|
+
|
|
87
|
+
def listen(self, worker_id: int, timeout: float = ...) -> MarketData | TransactionData | OrderData | TickDataLite | TickData | BarData: ...
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from .market_data import MarketData
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TickDataLite(MarketData):
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
ticker: str,
|
|
11
|
+
timestamp: float,
|
|
12
|
+
last_price: float,
|
|
13
|
+
bid_price: float,
|
|
14
|
+
bid_volume: float,
|
|
15
|
+
ask_price: float,
|
|
16
|
+
ask_volume: float,
|
|
17
|
+
total_traded_volume: float = ...,
|
|
18
|
+
total_traded_notional: float = ...,
|
|
19
|
+
total_trade_count: int = ...,
|
|
20
|
+
**kwargs: Any
|
|
21
|
+
) -> None: ...
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def last_price(self) -> float: ...
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def bid_price(self) -> float: ...
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def bid_volume(self) -> float: ...
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def ask_price(self) -> float: ...
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def ask_volume(self) -> float: ...
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def total_traded_volume(self) -> float: ...
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def total_traded_notional(self) -> float: ...
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def total_trade_count(self) -> int: ...
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def mid_price(self) -> float: ...
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def spread(self) -> float: ...
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def market_price(self) -> float: ...
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class OrderBook:
|
|
58
|
+
side: int
|
|
59
|
+
sorted: bool
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
side: int | None = ...,
|
|
64
|
+
price: Sequence[float] | None = ...,
|
|
65
|
+
volume: Sequence[float] | None = ...,
|
|
66
|
+
n_orders: Sequence[int] | None = ...,
|
|
67
|
+
is_sorted: bool = ...
|
|
68
|
+
) -> None: ...
|
|
69
|
+
|
|
70
|
+
def __iter__(self) -> OrderBook: ...
|
|
71
|
+
|
|
72
|
+
def __next__(self) -> tuple[float, float, int]: ...
|
|
73
|
+
|
|
74
|
+
def at_price(self, price: float) -> tuple[float, float, float]: ...
|
|
75
|
+
|
|
76
|
+
def at_level(self, index: int) -> tuple[float, float, float]: ...
|
|
77
|
+
|
|
78
|
+
def sort(self) -> None: ...
|
|
79
|
+
|
|
80
|
+
def to_bytes(self) -> bytes: ...
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def price(self) -> list[float]: ...
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def volume(self) -> list[float]: ...
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def n_orders(self) -> list[int]: ...
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class TickData(TickDataLite):
|
|
93
|
+
def __init__(
|
|
94
|
+
self,
|
|
95
|
+
ticker: str,
|
|
96
|
+
timestamp: float,
|
|
97
|
+
last_price: float,
|
|
98
|
+
total_traded_volume: float = ...,
|
|
99
|
+
total_traded_notional: float = ...,
|
|
100
|
+
total_trade_count: int = ...,
|
|
101
|
+
**kwargs: Any
|
|
102
|
+
) -> None: ...
|
|
103
|
+
|
|
104
|
+
def parse(self, kwargs: dict[str, Any]) -> None: ...
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def bid(self) -> OrderBook: ...
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def ask(self) -> OrderBook: ...
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import enum
|
|
4
|
+
import uuid
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
|
|
7
|
+
from .market_data import MarketData
|
|
8
|
+
from .transaction import OrderType, TransactionSide, TransactionData
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class OrderState(enum.IntEnum):
|
|
12
|
+
STATE_UNKNOWN: int
|
|
13
|
+
STATE_REJECTED: int
|
|
14
|
+
STATE_INVALID: int
|
|
15
|
+
STATE_PENDING: int
|
|
16
|
+
STATE_SENT: int
|
|
17
|
+
STATE_PLACED: int
|
|
18
|
+
STATE_PARTFILLED: int
|
|
19
|
+
STATE_FILLED: int
|
|
20
|
+
STATE_CANCELING: int
|
|
21
|
+
STATE_CANCELED: int
|
|
22
|
+
|
|
23
|
+
UNKNOWN: int
|
|
24
|
+
Rejected: int
|
|
25
|
+
Invalid: int
|
|
26
|
+
Pending: int
|
|
27
|
+
Sent: int
|
|
28
|
+
Placed: int
|
|
29
|
+
PartFilled: int
|
|
30
|
+
Filled: int
|
|
31
|
+
Canceling: int
|
|
32
|
+
Canceled: int
|
|
33
|
+
|
|
34
|
+
def __hash__(self) -> int: ...
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def is_working(self) -> bool: ...
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def is_done(self) -> bool: ...
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class TradeReport(MarketData):
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
ticker: str,
|
|
47
|
+
timestamp: float,
|
|
48
|
+
price: float,
|
|
49
|
+
volume: float,
|
|
50
|
+
side: int,
|
|
51
|
+
notional: float = ...,
|
|
52
|
+
multiplier: float = ...,
|
|
53
|
+
fee: float = ...,
|
|
54
|
+
order_id: str | int | bytes | uuid.UUID | None = ...,
|
|
55
|
+
trade_id: str | int | bytes | uuid.UUID | None = ...,
|
|
56
|
+
**kwargs
|
|
57
|
+
) -> None: ...
|
|
58
|
+
|
|
59
|
+
def __eq__(self, other: TradeReport) -> bool: ...
|
|
60
|
+
|
|
61
|
+
def __repr__(self) -> str: ...
|
|
62
|
+
|
|
63
|
+
def reset_order_id(self, order_id: str | int | bytes | uuid.UUID | None = ...) -> TradeReport: ...
|
|
64
|
+
|
|
65
|
+
def reset_trade_id(self, trade_id: str | int | bytes | uuid.UUID | None = ...) -> TradeReport: ...
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def from_buffer(cls, buffer: bytes) -> TradeReport: ...
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
def from_bytes(cls, data: bytes) -> TradeReport: ...
|
|
72
|
+
|
|
73
|
+
def copy(self) -> TradeReport: ...
|
|
74
|
+
|
|
75
|
+
def to_trade(self) -> TransactionData: ...
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def price(self) -> float: ...
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def volume(self) -> float: ...
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def side_int(self) -> int: ...
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def side(self) -> TransactionSide: ...
|
|
88
|
+
|
|
89
|
+
@property
|
|
90
|
+
def multiplier(self) -> float: ...
|
|
91
|
+
|
|
92
|
+
@property
|
|
93
|
+
def notional(self) -> float: ...
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def fee(self) -> float: ...
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def trade_id(self) -> str | int | bytes | uuid.UUID | None: ...
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def order_id(self) -> str | int | bytes | uuid.UUID | None: ...
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def market_price(self) -> float: ...
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def volume_flow(self) -> float: ...
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def notional_flow(self) -> float: ...
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def trade_time(self) -> datetime: ...
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class TradeInstruction(MarketData):
|
|
118
|
+
_dtype: int
|
|
119
|
+
trades: dict[str | int | bytes | uuid.UUID, TradeReport]
|
|
120
|
+
|
|
121
|
+
def __init__(
|
|
122
|
+
self,
|
|
123
|
+
ticker: str,
|
|
124
|
+
timestamp: float,
|
|
125
|
+
side: int,
|
|
126
|
+
volume: float,
|
|
127
|
+
order_type: int = ...,
|
|
128
|
+
limit_price: float = ...,
|
|
129
|
+
multiplier: float = ...,
|
|
130
|
+
order_id: str | int | bytes | uuid.UUID | None = ...,
|
|
131
|
+
**kwargs
|
|
132
|
+
) -> None: ...
|
|
133
|
+
|
|
134
|
+
def __eq__(self, other: TradeInstruction) -> bool: ...
|
|
135
|
+
|
|
136
|
+
def __repr__(self) -> str: ...
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def from_buffer(cls, buffer: bytes) -> TradeInstruction: ...
|
|
140
|
+
|
|
141
|
+
@classmethod
|
|
142
|
+
def from_bytes(cls, data: bytes) -> TradeInstruction: ...
|
|
143
|
+
|
|
144
|
+
def __copy__(self) -> TradeInstruction: ...
|
|
145
|
+
|
|
146
|
+
def reset(self) -> TradeInstruction: ...
|
|
147
|
+
|
|
148
|
+
def reset_order_id(self, order_id: str | int | bytes | uuid.UUID | None = ...) -> TradeInstruction: ...
|
|
149
|
+
|
|
150
|
+
def set_order_state(self, order_state: int, timestamp: float = ...) -> TradeInstruction: ...
|
|
151
|
+
|
|
152
|
+
def fill(self, trade_report: TradeReport) -> TradeInstruction: ...
|
|
153
|
+
|
|
154
|
+
def add_trade(self, trade_report: TradeReport) -> TradeInstruction: ...
|
|
155
|
+
|
|
156
|
+
def cancel_order(self, timestamp: float = ...) -> TradeInstruction: ...
|
|
157
|
+
|
|
158
|
+
def canceled(self, timestamp: float = ...) -> TradeInstruction: ...
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def is_working(self) -> bool: ...
|
|
162
|
+
|
|
163
|
+
@property
|
|
164
|
+
def is_done(self) -> bool: ...
|
|
165
|
+
|
|
166
|
+
@property
|
|
167
|
+
def limit_price(self) -> float: ...
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def volume(self) -> float: ...
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def side_int(self) -> int: ...
|
|
174
|
+
|
|
175
|
+
@property
|
|
176
|
+
def side(self) -> TransactionSide: ...
|
|
177
|
+
|
|
178
|
+
@property
|
|
179
|
+
def order_type_int(self) -> int: ...
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def order_type(self) -> OrderType: ...
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def order_state_int(self) -> int: ...
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def order_state(self) -> OrderState: ...
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def multiplier(self) -> float: ...
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def filled_volume(self) -> float: ...
|
|
195
|
+
|
|
196
|
+
@property
|
|
197
|
+
def working_volume(self) -> float: ...
|
|
198
|
+
|
|
199
|
+
@property
|
|
200
|
+
def filled_notional(self) -> float: ...
|
|
201
|
+
|
|
202
|
+
@property
|
|
203
|
+
def fee(self) -> float: ...
|
|
204
|
+
|
|
205
|
+
@property
|
|
206
|
+
def order_id(self) -> str | int | bytes | uuid.UUID | None: ...
|
|
207
|
+
|
|
208
|
+
@property
|
|
209
|
+
def average_price(self) -> float: ...
|
|
210
|
+
|
|
211
|
+
@property
|
|
212
|
+
def start_time(self) -> datetime: ...
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def placed_time(self) -> datetime | None: ...
|
|
216
|
+
|
|
217
|
+
@property
|
|
218
|
+
def canceled_time(self) -> datetime | None: ...
|
|
219
|
+
|
|
220
|
+
@property
|
|
221
|
+
def finished_time(self) -> datetime | None: ...
|