akquant 0.1.4__cp310-abi3-win_amd64.whl

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.

Potentially problematic release.


This version of akquant might be problematic. Click here for more details.

akquant/__init__.py ADDED
@@ -0,0 +1,98 @@
1
+ import typing
2
+
3
+ from . import akquant as _akquant
4
+ from .akquant import * # noqa: F403
5
+ from .backtest import BacktestResult, plot_result, run_backtest # type: ignore
6
+ from .config import strategy_config
7
+ from .data import DataLoader
8
+ from .indicator import Indicator, IndicatorSet
9
+ from .log import get_logger, register_logger
10
+ from .sizer import AllInSizer, FixedSize, PercentSizer, Sizer
11
+ from .strategy import Strategy
12
+ from .utils import load_bar_from_df, prepare_dataframe
13
+
14
+ __doc__ = _akquant.__doc__
15
+ if hasattr(_akquant, "__all__"): # noqa: F405
16
+ __all__ = _akquant.__all__ + [ # noqa: F405
17
+ "load_bar_from_df",
18
+ "prepare_dataframe",
19
+ "Sizer",
20
+ "FixedSize",
21
+ "PercentSizer",
22
+ "AllInSizer",
23
+ "Strategy",
24
+ "DataLoader",
25
+ "get_logger",
26
+ "register_logger",
27
+ "strategy_config",
28
+ "Indicator",
29
+ "IndicatorSet",
30
+ "run_backtest",
31
+ "plot_result",
32
+ "BacktestResult",
33
+ ]
34
+ else:
35
+ __all__ = [
36
+ "load_bar_from_df",
37
+ "prepare_dataframe",
38
+ "Sizer",
39
+ "FixedSize",
40
+ "PercentSizer",
41
+ "AllInSizer",
42
+ "Strategy",
43
+ "DataLoader",
44
+ "get_logger",
45
+ "register_logger",
46
+ "strategy_config",
47
+ "Indicator",
48
+ "IndicatorSet",
49
+ "run_backtest",
50
+ "plot_result",
51
+ "BacktestResult",
52
+ ]
53
+
54
+
55
+ def create_bar(
56
+ timestamp: int,
57
+ open_px: float,
58
+ high_px: float,
59
+ low_px: float,
60
+ close_px: float,
61
+ volume: float,
62
+ symbol: str,
63
+ ) -> Bar: # noqa: F405
64
+ """创建 Bar 对象的辅助函数."""
65
+ return Bar(timestamp, open_px, high_px, low_px, close_px, volume, symbol) # noqa: F405
66
+
67
+
68
+ def _engine_set_timezone_name(self: Engine, tz_name: str) -> None: # noqa: F405
69
+ """
70
+ 通过时区名称设置引擎时区.
71
+
72
+ :param tz_name: 时区名称,例如 "Asia/Shanghai", "UTC", "US/Eastern"
73
+ """
74
+ import datetime
75
+
76
+ try:
77
+ import zoneinfo
78
+
79
+ tz: typing.Union[datetime.tzinfo, typing.Any] = zoneinfo.ZoneInfo(tz_name)
80
+ except ImportError:
81
+ import pytz
82
+
83
+ tz = pytz.timezone(tz_name)
84
+
85
+ # Get offset for current time (approximate is usually fine for constant
86
+ # offset zones, but for DST aware zones, we might want a specific date.
87
+ # For simplicity and standard market hours, we use current date or a fixed date)
88
+ now = datetime.datetime.now(tz)
89
+ utc_offset = now.utcoffset()
90
+ if utc_offset is None:
91
+ offset = 0
92
+ else:
93
+ offset = int(utc_offset.total_seconds())
94
+ self.set_timezone(offset)
95
+
96
+
97
+ # Patch Engine class
98
+ Engine.set_timezone_name = _engine_set_timezone_name # type: ignore # noqa: F405
akquant/akquant.pyd ADDED
Binary file