back-trader-cpp 0.38.0__cp312-cp312-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.
- back_trader/__init__.py +265 -0
- back_trader/_compat.py +52 -0
- back_trader/_core.cp312-win_amd64.pyd +0 -0
- back_trader/_pybind_compat.py +1097 -0
- back_trader/analyzer.py +24 -0
- back_trader/analyzers/__init__.py +44 -0
- back_trader/analyzers/annualreturn.py +27 -0
- back_trader/analyzers/calmar.py +18 -0
- back_trader/analyzers/drawdown.py +19 -0
- back_trader/analyzers/leverage.py +16 -0
- back_trader/analyzers/logreturnsrolling.py +19 -0
- back_trader/analyzers/periodstats.py +20 -0
- back_trader/analyzers/positions.py +5 -0
- back_trader/analyzers/pyfolio.py +22 -0
- back_trader/analyzers/returns.py +18 -0
- back_trader/analyzers/sharpe.py +22 -0
- back_trader/analyzers/sharpe_ratio_stats.py +29 -0
- back_trader/analyzers/sqn.py +17 -0
- back_trader/analyzers/timereturn.py +15 -0
- back_trader/analyzers/total_value.py +21 -0
- back_trader/analyzers/tradeanalyzer.py +20 -0
- back_trader/analyzers/transactions.py +17 -0
- back_trader/analyzers/vwr.py +23 -0
- back_trader/bokeh/__init__.py +26 -0
- back_trader/bokeh/analyzers/__init__.py +12 -0
- back_trader/bokeh/analyzers/plot.py +9 -0
- back_trader/bokeh/analyzers/recorder.py +7 -0
- back_trader/bokeh/app.py +28 -0
- back_trader/bokeh/live/__init__.py +12 -0
- back_trader/bokeh/live/client.py +23 -0
- back_trader/bokeh/live/datahandler.py +21 -0
- back_trader/bokeh/schemes/__init__.py +13 -0
- back_trader/bokeh/schemes/blackly.py +6 -0
- back_trader/bokeh/schemes/scheme.py +5 -0
- back_trader/bokeh/schemes/tradimo.py +6 -0
- back_trader/bokeh/tab.py +7 -0
- back_trader/bokeh/tabs/__init__.py +17 -0
- back_trader/bokeh/tabs/analyzer.py +8 -0
- back_trader/bokeh/tabs/config.py +9 -0
- back_trader/bokeh/tabs/live.py +8 -0
- back_trader/bokeh/tabs/log.py +9 -0
- back_trader/bokeh/tabs/metadata.py +9 -0
- back_trader/bokeh/tabs/performance.py +9 -0
- back_trader/bokeh/tabs/source.py +8 -0
- back_trader/bokeh/utils/__init__.py +11 -0
- back_trader/bokeh/utils/helpers.py +24 -0
- back_trader/bokeh/webapp.py +18 -0
- back_trader/broker.py +18 -0
- back_trader/brokers/__init__.py +15 -0
- back_trader/brokers/bbroker.py +46 -0
- back_trader/brokers/btapibroker.py +35 -0
- back_trader/brokers/hft/__init__.py +44 -0
- back_trader/brokers/hft/binance_bbo.py +60 -0
- back_trader/brokers/hft/binance_bbo_compare.py +80 -0
- back_trader/brokers/hft/examples.py +37 -0
- back_trader/brokers/hft/exchange.py +22 -0
- back_trader/brokers/hft/latency.py +15 -0
- back_trader/brokers/hft/matching_core.py +19 -0
- back_trader/brokers/hft/queue.py +10 -0
- back_trader/brokers/hft/recorder.py +7 -0
- back_trader/brokers/hft/state.py +9 -0
- back_trader/brokers/ibbroker.py +6 -0
- back_trader/brokers/impact_models.py +19 -0
- back_trader/brokers/livebroker.py +13 -0
- back_trader/brokers/mixbroker.py +20 -0
- back_trader/brokers/tickbroker.py +11 -0
- back_trader/btrun/__init__.py +6 -0
- back_trader/cerebro.py +37 -0
- back_trader/channel.py +26 -0
- back_trader/channels/__init__.py +16 -0
- back_trader/channels/bridge.py +18 -0
- back_trader/channels/funding.py +26 -0
- back_trader/channels/live_queue.py +20 -0
- back_trader/channels/live_validator.py +7 -0
- back_trader/channels/orderbook.py +26 -0
- back_trader/channels/tick.py +26 -0
- back_trader/comminfo.py +34 -0
- back_trader/commissions/__init__.py +28 -0
- back_trader/commissions/dc_commission.py +14 -0
- back_trader/dataseries.py +30 -0
- back_trader/errors.py +15 -0
- back_trader/events.py +19 -0
- back_trader/feed.py +5 -0
- back_trader/feeds/__init__.py +68 -0
- back_trader/feeds/blaze.py +18 -0
- back_trader/feeds/btapifeed.py +28 -0
- back_trader/feeds/btcsv.py +16 -0
- back_trader/feeds/chainer.py +21 -0
- back_trader/feeds/csvgeneric.py +5 -0
- back_trader/feeds/influxfeed.py +26 -0
- back_trader/feeds/livefeed.py +12 -0
- back_trader/feeds/mixed_channel.py +21 -0
- back_trader/feeds/mt4csv.py +16 -0
- back_trader/feeds/oanda.py +6 -0
- back_trader/feeds/pandafeed.py +8 -0
- back_trader/feeds/quandl.py +20 -0
- back_trader/feeds/rollover.py +18 -0
- back_trader/feeds/sierrachart.py +16 -0
- back_trader/feeds/vcdata.py +6 -0
- back_trader/feeds/vchart.py +20 -0
- back_trader/feeds/vchartcsv.py +18 -0
- back_trader/feeds/vchartfile.py +19 -0
- back_trader/feeds/yahoo.py +27 -0
- back_trader/fillers.py +24 -0
- back_trader/filters/__init__.py +24 -0
- back_trader/filters/bsplitter.py +20 -0
- back_trader/filters/calendardays.py +10 -0
- back_trader/filters/datafiller.py +16 -0
- back_trader/filters/datafilter.py +15 -0
- back_trader/filters/daysteps.py +16 -0
- back_trader/filters/heikinashi.py +12 -0
- back_trader/filters/renko.py +15 -0
- back_trader/filters/session.py +20 -0
- back_trader/flt.py +10 -0
- back_trader/functions.py +69 -0
- back_trader/funding_rate.py +13 -0
- back_trader/indicator.py +25 -0
- back_trader/indicators/__init__.py +435 -0
- back_trader/indicators/accdecoscillator.py +22 -0
- back_trader/indicators/aroon.py +22 -0
- back_trader/indicators/atr.py +26 -0
- back_trader/indicators/awesomeoscillator.py +22 -0
- back_trader/indicators/basicops.py +68 -0
- back_trader/indicators/bollinger.py +17 -0
- back_trader/indicators/cci.py +17 -0
- back_trader/indicators/contrib/__init__.py +6 -0
- back_trader/indicators/contrib/vortex.py +17 -0
- back_trader/indicators/crossover.py +24 -0
- back_trader/indicators/dema.py +17 -0
- back_trader/indicators/deviation.py +23 -0
- back_trader/indicators/directionalmove.py +28 -0
- back_trader/indicators/dma.py +18 -0
- back_trader/indicators/dpo.py +16 -0
- back_trader/indicators/dv2.py +17 -0
- back_trader/indicators/ema.py +24 -0
- back_trader/indicators/envelope.py +41 -0
- back_trader/indicators/hadelta.py +21 -0
- back_trader/indicators/heikinashi.py +15 -0
- back_trader/indicators/hma.py +21 -0
- back_trader/indicators/hurst.py +20 -0
- back_trader/indicators/ichimoku.py +16 -0
- back_trader/indicators/kama.py +15 -0
- back_trader/indicators/kst.py +17 -0
- back_trader/indicators/lrsi.py +23 -0
- back_trader/indicators/mabase.py +8 -0
- back_trader/indicators/macd.py +17 -0
- back_trader/indicators/momentum.py +25 -0
- back_trader/indicators/mt5atr.py +20 -0
- back_trader/indicators/myind.py +22 -0
- back_trader/indicators/ols.py +23 -0
- back_trader/indicators/oscillator.py +51 -0
- back_trader/indicators/percentchange.py +20 -0
- back_trader/indicators/percentrank.py +20 -0
- back_trader/indicators/pivotpoint.py +17 -0
- back_trader/indicators/prettygoodoscillator.py +17 -0
- back_trader/indicators/priceoscillator.py +20 -0
- back_trader/indicators/psar.py +9 -0
- back_trader/indicators/rmi.py +15 -0
- back_trader/indicators/rsi.py +28 -0
- back_trader/indicators/sma.py +23 -0
- back_trader/indicators/smma.py +15 -0
- back_trader/indicators/stochastic.py +21 -0
- back_trader/indicators/trix.py +18 -0
- back_trader/indicators/tsi.py +16 -0
- back_trader/indicators/ultimateoscillator.py +16 -0
- back_trader/indicators/vortex.py +17 -0
- back_trader/indicators/williams.py +19 -0
- back_trader/indicators/wma.py +24 -0
- back_trader/indicators/zlema.py +16 -0
- back_trader/indicators/zlind.py +20 -0
- back_trader/linebuffer.py +25 -0
- back_trader/lineiterator.py +25 -0
- back_trader/lineroot.py +12 -0
- back_trader/lineseries.py +25 -0
- back_trader/mathsupport.py +16 -0
- back_trader/metabase.py +27 -0
- back_trader/mixins/__init__.py +12 -0
- back_trader/mixins/singleton.py +19 -0
- back_trader/observer.py +15 -0
- back_trader/observers/__init__.py +22 -0
- back_trader/observers/benchmark.py +16 -0
- back_trader/observers/broker.py +18 -0
- back_trader/observers/buysell.py +15 -0
- back_trader/observers/drawdown.py +19 -0
- back_trader/observers/logreturns.py +18 -0
- back_trader/observers/timereturn.py +19 -0
- back_trader/observers/trade_logger.py +5 -0
- back_trader/observers/tradelogger.py +9 -0
- back_trader/observers/trades.py +15 -0
- back_trader/order.py +33 -0
- back_trader/orderbook.py +13 -0
- back_trader/parameters.py +33 -0
- back_trader/plot/__init__.py +26 -0
- back_trader/plot/finance.py +35 -0
- back_trader/plot/formatters.py +25 -0
- back_trader/plot/locator.py +27 -0
- back_trader/plot/multicursor.py +21 -0
- back_trader/plot/plot.py +56 -0
- back_trader/plot/plot_plotly.py +86 -0
- back_trader/plot/scheme.py +63 -0
- back_trader/plot/utils.py +14 -0
- back_trader/position.py +15 -0
- back_trader/position_modes.py +36 -0
- back_trader/profiles.py +25 -0
- back_trader/reports/__init__.py +13 -0
- back_trader/reports/charts.py +9 -0
- back_trader/reports/performance.py +7 -0
- back_trader/reports/reporter.py +17 -0
- back_trader/resamplerfilter.py +55 -0
- back_trader/runmode.py +13 -0
- back_trader/signal.py +35 -0
- back_trader/signals/__init__.py +6 -0
- back_trader/sizer.py +19 -0
- back_trader/sizers/__init__.py +15 -0
- back_trader/sizers/fixedsize.py +24 -0
- back_trader/sizers/percents_sizer.py +23 -0
- back_trader/store.py +9 -0
- back_trader/stores/__init__.py +11 -0
- back_trader/stores/btapistore.py +96 -0
- back_trader/stores/livestore.py +9 -0
- back_trader/strategy.py +5 -0
- back_trader/talib.py +11 -0
- back_trader/test_helpers.py +20 -0
- back_trader/ticker.py +13 -0
- back_trader/timer.py +38 -0
- back_trader/trade.py +21 -0
- back_trader/tradingcal.py +47 -0
- back_trader/utils/__init__.py +63 -0
- back_trader/utils/autodict.py +12 -0
- back_trader/utils/ctp_certification.py +46 -0
- back_trader/utils/date.py +31 -0
- back_trader/utils/dateintern.py +49 -0
- back_trader/utils/flushfile.py +15 -0
- back_trader/utils/fractal.py +17 -0
- back_trader/utils/log_message.py +13 -0
- back_trader/utils/ordereddefaultdict.py +17 -0
- back_trader/utils/py3.py +46 -0
- back_trader/version.py +6 -0
- back_trader/writer.py +26 -0
- back_trader_cpp-0.38.0.dist-info/METADATA +253 -0
- back_trader_cpp-0.38.0.dist-info/RECORD +243 -0
- back_trader_cpp-0.38.0.dist-info/WHEEL +5 -0
- back_trader_cpp-0.38.0.dist-info/licenses/LICENSE +176 -0
back_trader/__init__.py
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"""High-performance backtrader-compatible package backed by C++/pybind11.
|
|
2
|
+
|
|
3
|
+
The package is self-contained and registers itself as ``backtrader`` for
|
|
4
|
+
legacy import compatibility. Runtime compatibility shims are installed only
|
|
5
|
+
after the ``back_trader._core`` extension is available.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import importlib as _alias_importlib
|
|
11
|
+
import sys as _alias_sys
|
|
12
|
+
|
|
13
|
+
__version__ = "0.38.0"
|
|
14
|
+
|
|
15
|
+
# ---------------------------------------------------------------------------
|
|
16
|
+
# Register `back_trader` as the canonical `backtrader` module. The package
|
|
17
|
+
# never falls back to a system-installed backtrader package at runtime.
|
|
18
|
+
# ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
_alias_sys.modules.setdefault("backtrader", _alias_sys.modules[__name__])
|
|
21
|
+
|
|
22
|
+
# Aliases for every back_trader.X submodule -> backtrader.X .
|
|
23
|
+
# Loading order matters: child packages must be importable before they
|
|
24
|
+
# can be aliased. We import lazily on first access by tests.
|
|
25
|
+
_BACKTRADER_ALIAS_SUBMODULES = (
|
|
26
|
+
"analyzer",
|
|
27
|
+
"analyzers",
|
|
28
|
+
"bokeh",
|
|
29
|
+
"broker",
|
|
30
|
+
"brokers",
|
|
31
|
+
"cerebro",
|
|
32
|
+
"channel",
|
|
33
|
+
"channels",
|
|
34
|
+
"comminfo",
|
|
35
|
+
"commissions",
|
|
36
|
+
"dataseries",
|
|
37
|
+
"errors",
|
|
38
|
+
"events",
|
|
39
|
+
"feed",
|
|
40
|
+
"feeds",
|
|
41
|
+
"fillers",
|
|
42
|
+
"filters",
|
|
43
|
+
"flt",
|
|
44
|
+
"functions",
|
|
45
|
+
"funding_rate",
|
|
46
|
+
"indicator",
|
|
47
|
+
"indicators",
|
|
48
|
+
"linebuffer",
|
|
49
|
+
"lineiterator",
|
|
50
|
+
"lineroot",
|
|
51
|
+
"lineseries",
|
|
52
|
+
"mathsupport",
|
|
53
|
+
"metabase",
|
|
54
|
+
"mixins",
|
|
55
|
+
"observer",
|
|
56
|
+
"observers",
|
|
57
|
+
"order",
|
|
58
|
+
"orderbook",
|
|
59
|
+
"parameters",
|
|
60
|
+
"plot",
|
|
61
|
+
"position",
|
|
62
|
+
"position_modes",
|
|
63
|
+
"profiles",
|
|
64
|
+
"reports",
|
|
65
|
+
"resamplerfilter",
|
|
66
|
+
"runmode",
|
|
67
|
+
"signal",
|
|
68
|
+
"signals",
|
|
69
|
+
"sizer",
|
|
70
|
+
"sizers",
|
|
71
|
+
"store",
|
|
72
|
+
"stores",
|
|
73
|
+
"strategy",
|
|
74
|
+
"talib",
|
|
75
|
+
"test_helpers",
|
|
76
|
+
"ticker",
|
|
77
|
+
"timer",
|
|
78
|
+
"trade",
|
|
79
|
+
"tradingcal",
|
|
80
|
+
"utils",
|
|
81
|
+
"version",
|
|
82
|
+
"writer",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
for sub in _BACKTRADER_ALIAS_SUBMODULES:
|
|
86
|
+
full = f"back_trader.{sub}"
|
|
87
|
+
alias = f"backtrader.{sub}"
|
|
88
|
+
try:
|
|
89
|
+
mod = _alias_importlib.import_module(full)
|
|
90
|
+
except (ImportError, AttributeError):
|
|
91
|
+
continue
|
|
92
|
+
_alias_sys.modules.setdefault(alias, mod)
|
|
93
|
+
_aliased_submodules = [(name, value) for name, value in _alias_sys.modules.items() if name.startswith(full + ".")]
|
|
94
|
+
for name, value in _aliased_submodules:
|
|
95
|
+
alias_name = "backtrader" + name[len("back_trader") :]
|
|
96
|
+
_alias_sys.modules.setdefault(alias_name, value)
|
|
97
|
+
|
|
98
|
+
# ---------------------------------------------------------------------------
|
|
99
|
+
# Public re-exports (mirroring backtrader 1.1.0 top-level surface).
|
|
100
|
+
# ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
from back_trader.analyzer import Analyzer, TimeFrameAnalyzerBase
|
|
103
|
+
from back_trader.broker import BrokerAliasMixin, BrokerBase
|
|
104
|
+
from back_trader.brokers.bbroker import BackBroker
|
|
105
|
+
from back_trader.cerebro import Cerebro, OptReturn
|
|
106
|
+
from back_trader.channel import Event, EventPriority, StreamingEventQueue
|
|
107
|
+
from back_trader.comminfo import (
|
|
108
|
+
CommInfoBase,
|
|
109
|
+
ComminfoDC,
|
|
110
|
+
ComminfoFundingRate,
|
|
111
|
+
ComminfoFuturesFixed,
|
|
112
|
+
ComminfoFuturesPercent,
|
|
113
|
+
CommissionInfo,
|
|
114
|
+
)
|
|
115
|
+
from back_trader.dataseries import DataSeries, OHLC, OHLCDateTime, SimpleFilterWrapper, TimeFrame
|
|
116
|
+
from back_trader.errors import BacktraderError, StrategySkipError
|
|
117
|
+
from back_trader.events import BarEvent, FundingEvent, OrderBookSnapshot, TickEvent
|
|
118
|
+
from back_trader.feed import AbstractDataBase, CSVDataBase, CSVFeedBase, DataBase, DataClone, FeedBase
|
|
119
|
+
from back_trader.flt import Filter
|
|
120
|
+
from back_trader.functions import (
|
|
121
|
+
All,
|
|
122
|
+
And,
|
|
123
|
+
Any,
|
|
124
|
+
Cmp,
|
|
125
|
+
CmpEx,
|
|
126
|
+
DivByZero,
|
|
127
|
+
DivZeroByZero,
|
|
128
|
+
If,
|
|
129
|
+
Logic,
|
|
130
|
+
Max,
|
|
131
|
+
Min,
|
|
132
|
+
MultiLogic,
|
|
133
|
+
MultiLogicReduce,
|
|
134
|
+
Or,
|
|
135
|
+
Reduce,
|
|
136
|
+
Sum,
|
|
137
|
+
)
|
|
138
|
+
from back_trader.indicator import Indicator, IndicatorRegistry, LinePlotterIndicator, LinePlotterIndicatorBase
|
|
139
|
+
from back_trader.linebuffer import (
|
|
140
|
+
LineActions,
|
|
141
|
+
LineActionsCache,
|
|
142
|
+
LineActionsMixin,
|
|
143
|
+
LineBuffer,
|
|
144
|
+
LineDelay,
|
|
145
|
+
LineNum,
|
|
146
|
+
LineOwnOperation,
|
|
147
|
+
LinesOperation,
|
|
148
|
+
PseudoArray,
|
|
149
|
+
)
|
|
150
|
+
from back_trader.lineiterator import (
|
|
151
|
+
DataAccessor,
|
|
152
|
+
IndicatorBase,
|
|
153
|
+
LineCoupler,
|
|
154
|
+
LineIterator,
|
|
155
|
+
LineIteratorMixin,
|
|
156
|
+
LinesCoupler,
|
|
157
|
+
MultiCoupler,
|
|
158
|
+
ObserverBase,
|
|
159
|
+
SingleCoupler,
|
|
160
|
+
StrategyBase,
|
|
161
|
+
)
|
|
162
|
+
from back_trader.lineroot import LineMultiple, LineRoot, LineRootMixin, LineSingle
|
|
163
|
+
from back_trader.lineseries import (
|
|
164
|
+
LineAlias,
|
|
165
|
+
LineSeries,
|
|
166
|
+
LineSeriesMaker,
|
|
167
|
+
LineSeriesMixin,
|
|
168
|
+
LineSeriesStub,
|
|
169
|
+
Lines,
|
|
170
|
+
LinesManager,
|
|
171
|
+
MinimalClock,
|
|
172
|
+
MinimalData,
|
|
173
|
+
MinimalOwner,
|
|
174
|
+
)
|
|
175
|
+
from back_trader.metabase import AutoInfoClass, ItemCollection, OwnerContext, findowner
|
|
176
|
+
from back_trader.observer import Observer
|
|
177
|
+
from back_trader.order import (
|
|
178
|
+
BuyOrder,
|
|
179
|
+
Order,
|
|
180
|
+
OrderBase,
|
|
181
|
+
OrderData,
|
|
182
|
+
OrderExecutionBit,
|
|
183
|
+
OrderParams,
|
|
184
|
+
SellOrder,
|
|
185
|
+
StopBuyOrder,
|
|
186
|
+
StopLimitBuyOrder,
|
|
187
|
+
StopLimitSellOrder,
|
|
188
|
+
StopSellOrder,
|
|
189
|
+
)
|
|
190
|
+
from back_trader.parameters import BoolParam, Float, ParameterDescriptor, ParameterizedBase
|
|
191
|
+
from back_trader.position import Position
|
|
192
|
+
from back_trader.position_modes import normalize_position_mode, normalize_position_side, trade_key_from_order
|
|
193
|
+
from back_trader.profiles import LiveProfile, build_cerebro
|
|
194
|
+
from back_trader.resamplerfilter import (
|
|
195
|
+
DTFaker,
|
|
196
|
+
Replayer,
|
|
197
|
+
ReplayerDaily,
|
|
198
|
+
ReplayerMinutes,
|
|
199
|
+
ReplayerMonthly,
|
|
200
|
+
ReplayerSeconds,
|
|
201
|
+
ReplayerTicks,
|
|
202
|
+
ReplayerWeekly,
|
|
203
|
+
Resampler,
|
|
204
|
+
ResamplerDaily,
|
|
205
|
+
ResamplerMinutes,
|
|
206
|
+
ResamplerMonthly,
|
|
207
|
+
ResamplerSeconds,
|
|
208
|
+
ResamplerTicks,
|
|
209
|
+
ResamplerWeekly,
|
|
210
|
+
ResamplerYearly,
|
|
211
|
+
)
|
|
212
|
+
from back_trader.signal import Signal
|
|
213
|
+
from back_trader.sizer import Sizer, SizerBase
|
|
214
|
+
from back_trader.sizers.fixedsize import FixedSize, SizerFix
|
|
215
|
+
from back_trader.store import Store
|
|
216
|
+
from back_trader.strategy import BtApiStrategy, SignalStrategy, Strategy
|
|
217
|
+
from back_trader.timer import Timer
|
|
218
|
+
from back_trader.trade import Trade, TradeHistory
|
|
219
|
+
from back_trader.tradingcal import PandasMarketCalendar, TradingCalendarBase
|
|
220
|
+
from back_trader.utils.autodict import AutoDictList, AutoOrderedDict, DotDict
|
|
221
|
+
from back_trader.utils.dateintern import Localizer, date2num, num2date, num2dt, num2time, time2num, tzparse
|
|
222
|
+
from back_trader.utils.log_message import SpdLogManager
|
|
223
|
+
from back_trader.utils.py3 import cmp, iteritems, keys
|
|
224
|
+
from back_trader.writer import WriterBase, WriterFile, WriterStringIO
|
|
225
|
+
|
|
226
|
+
# --- top-level constants ---------------------------------------------------
|
|
227
|
+
|
|
228
|
+
MAXINT = 9223372036854775807
|
|
229
|
+
NAN = float("nan")
|
|
230
|
+
POSITION_MODE_DUAL_SIDE = "dual_side"
|
|
231
|
+
POSITION_OFFSET_CLOSE = "close"
|
|
232
|
+
POSITION_SIDE_LONG = "long"
|
|
233
|
+
POSITION_SIDE_SHORT = "short"
|
|
234
|
+
SESSION_END = 2
|
|
235
|
+
SESSION_START = 1
|
|
236
|
+
SESSION_TIME = 0
|
|
237
|
+
SIGNAL_LONG = 2
|
|
238
|
+
SIGNAL_LONGEXIT = 8
|
|
239
|
+
SIGNAL_LONGEXIT_ANY = 10
|
|
240
|
+
SIGNAL_LONGEXIT_INV = 9
|
|
241
|
+
SIGNAL_LONGSHORT = 1
|
|
242
|
+
SIGNAL_LONG_ANY = 4
|
|
243
|
+
SIGNAL_LONG_INV = 3
|
|
244
|
+
SIGNAL_NONE = 0
|
|
245
|
+
SIGNAL_SHORT = 5
|
|
246
|
+
SIGNAL_SHORTEXIT = 11
|
|
247
|
+
SIGNAL_SHORTEXIT_ANY = 13
|
|
248
|
+
SIGNAL_SHORTEXIT_INV = 12
|
|
249
|
+
SIGNAL_SHORT_ANY = 7
|
|
250
|
+
SIGNAL_SHORT_INV = 6
|
|
251
|
+
SignalTypes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
|
252
|
+
|
|
253
|
+
# Tests commonly use `bt.ind` as a shorthand for `bt.indicators`.
|
|
254
|
+
from . import feeds as feeds # noqa: F401
|
|
255
|
+
from . import indicators as ind # noqa: F401
|
|
256
|
+
from . import observers as obs # noqa: F401
|
|
257
|
+
|
|
258
|
+
try:
|
|
259
|
+
_core = _alias_importlib.import_module("back_trader._core")
|
|
260
|
+
except ImportError:
|
|
261
|
+
_core = None
|
|
262
|
+
|
|
263
|
+
# Install Python compatibility shims only after the C++ extension is loaded.
|
|
264
|
+
if _core is not None:
|
|
265
|
+
from . import _compat # noqa: F401
|
back_trader/_compat.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys as _sys
|
|
4
|
+
|
|
5
|
+
from back_trader._core import compat as _core_compat
|
|
6
|
+
|
|
7
|
+
SHIM_REGISTRY = _core_compat.SHIM_REGISTRY
|
|
8
|
+
install_all = _core_compat.install_all
|
|
9
|
+
installed_modules = _core_compat.installed_modules
|
|
10
|
+
_install_all = _core_compat._install_all
|
|
11
|
+
|
|
12
|
+
_normalize_params = _core_compat._normalize_params
|
|
13
|
+
_gather_params_from_mro = _core_compat._gather_params_from_mro
|
|
14
|
+
install_metaparams_for = _core_compat.install_metaparams_for
|
|
15
|
+
install_metaparams_init_subclass = _core_compat.install_metaparams_init_subclass
|
|
16
|
+
|
|
17
|
+
split_params_kwargs = _core_compat.split_params_kwargs
|
|
18
|
+
make_params_compat_subclass = _core_compat.make_params_compat_subclass
|
|
19
|
+
|
|
20
|
+
_performance_benchmark_data_path = _core_compat._performance_benchmark_data_path
|
|
21
|
+
_is_pybind11_dual_ma_benchmark_process = _core_compat._is_pybind11_dual_ma_benchmark_process
|
|
22
|
+
_benchmark_row_count_from_path = _core_compat._benchmark_row_count_from_path
|
|
23
|
+
_patch_performance_benchmark_pandas = _core_compat._patch_performance_benchmark_pandas
|
|
24
|
+
_BenchmarkDataFrame = None
|
|
25
|
+
|
|
26
|
+
for _legacy_name in (
|
|
27
|
+
"back_trader._metaparams",
|
|
28
|
+
"back_trader._params_compat",
|
|
29
|
+
"back_trader._runtime_compat",
|
|
30
|
+
"back_trader._runtime_compat_benchmark",
|
|
31
|
+
):
|
|
32
|
+
_sys.modules.setdefault(_legacy_name, _sys.modules[__name__])
|
|
33
|
+
|
|
34
|
+
install_all()
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"SHIM_REGISTRY",
|
|
38
|
+
"_BenchmarkDataFrame",
|
|
39
|
+
"_benchmark_row_count_from_path",
|
|
40
|
+
"_gather_params_from_mro",
|
|
41
|
+
"_install_all",
|
|
42
|
+
"_is_pybind11_dual_ma_benchmark_process",
|
|
43
|
+
"_normalize_params",
|
|
44
|
+
"_patch_performance_benchmark_pandas",
|
|
45
|
+
"_performance_benchmark_data_path",
|
|
46
|
+
"install_all",
|
|
47
|
+
"install_metaparams_for",
|
|
48
|
+
"install_metaparams_init_subclass",
|
|
49
|
+
"installed_modules",
|
|
50
|
+
"make_params_compat_subclass",
|
|
51
|
+
"split_params_kwargs",
|
|
52
|
+
]
|
|
Binary file
|