back-trader-python 1.4.0__py3-none-any.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.
Files changed (465) hide show
  1. back_trader_python-1.4.0.dist-info/METADATA +1491 -0
  2. back_trader_python-1.4.0.dist-info/RECORD +465 -0
  3. back_trader_python-1.4.0.dist-info/WHEEL +5 -0
  4. back_trader_python-1.4.0.dist-info/licenses/LICENSE +674 -0
  5. back_trader_python-1.4.0.dist-info/top_level.txt +1 -0
  6. backtrader/__init__.py +148 -0
  7. backtrader/_cerebro/__init__.py +5 -0
  8. backtrader/_cerebro/channel.py +382 -0
  9. backtrader/_cerebro/execution.py +377 -0
  10. backtrader/_cerebro/lifecycle.py +143 -0
  11. backtrader/_cerebro/notifications.py +150 -0
  12. backtrader/_cerebro/presentation.py +230 -0
  13. backtrader/_cerebro/registry.py +593 -0
  14. backtrader/_cerebro/runnext.py +551 -0
  15. backtrader/_cerebro/runonce.py +142 -0
  16. backtrader/analyzer.py +594 -0
  17. backtrader/analyzers/__init__.py +50 -0
  18. backtrader/analyzers/annualreturn.py +226 -0
  19. backtrader/analyzers/calmar.py +165 -0
  20. backtrader/analyzers/drawdown.py +287 -0
  21. backtrader/analyzers/leverage.py +112 -0
  22. backtrader/analyzers/logreturnsrolling.py +190 -0
  23. backtrader/analyzers/periodstats.py +153 -0
  24. backtrader/analyzers/positions.py +119 -0
  25. backtrader/analyzers/pyfolio.py +470 -0
  26. backtrader/analyzers/returns.py +192 -0
  27. backtrader/analyzers/sharpe.py +307 -0
  28. backtrader/analyzers/sharpe_ratio_stats.py +534 -0
  29. backtrader/analyzers/sqn.py +112 -0
  30. backtrader/analyzers/timereturn.py +192 -0
  31. backtrader/analyzers/total_value.py +75 -0
  32. backtrader/analyzers/tradeanalyzer.py +278 -0
  33. backtrader/analyzers/transactions.py +141 -0
  34. backtrader/analyzers/vwr.py +245 -0
  35. backtrader/bokeh/__init__.py +155 -0
  36. backtrader/bokeh/analyzers/__init__.py +13 -0
  37. backtrader/bokeh/analyzers/plot.py +192 -0
  38. backtrader/bokeh/analyzers/recorder.py +181 -0
  39. backtrader/bokeh/app.py +1094 -0
  40. backtrader/bokeh/live/__init__.py +11 -0
  41. backtrader/bokeh/live/client.py +352 -0
  42. backtrader/bokeh/live/datahandler.py +346 -0
  43. backtrader/bokeh/plot_adapter.py +200 -0
  44. backtrader/bokeh/schemes/__init__.py +14 -0
  45. backtrader/bokeh/schemes/blackly.py +76 -0
  46. backtrader/bokeh/schemes/scheme.py +150 -0
  47. backtrader/bokeh/schemes/tradimo.py +82 -0
  48. backtrader/bokeh/tab.py +125 -0
  49. backtrader/bokeh/tabs/__init__.py +30 -0
  50. backtrader/bokeh/tabs/analyzer.py +120 -0
  51. backtrader/bokeh/tabs/config.py +154 -0
  52. backtrader/bokeh/tabs/live.py +109 -0
  53. backtrader/bokeh/tabs/log.py +185 -0
  54. backtrader/bokeh/tabs/metadata.py +182 -0
  55. backtrader/bokeh/tabs/performance.py +359 -0
  56. backtrader/bokeh/tabs/source.py +70 -0
  57. backtrader/bokeh/utils/__init__.py +8 -0
  58. backtrader/bokeh/utils/helpers.py +167 -0
  59. backtrader/bokeh/webapp.py +164 -0
  60. backtrader/broker.py +478 -0
  61. backtrader/brokers/__init__.py +36 -0
  62. backtrader/brokers/bbroker.py +2576 -0
  63. backtrader/brokers/btapibroker.py +8227 -0
  64. backtrader/brokers/hft/__init__.py +89 -0
  65. backtrader/brokers/hft/binance_bbo.py +625 -0
  66. backtrader/brokers/hft/binance_bbo_compare.py +1398 -0
  67. backtrader/brokers/hft/examples.py +1228 -0
  68. backtrader/brokers/hft/exchange.py +380 -0
  69. backtrader/brokers/hft/latency.py +309 -0
  70. backtrader/brokers/hft/matching_core.py +572 -0
  71. backtrader/brokers/hft/queue.py +238 -0
  72. backtrader/brokers/hft/recorder.py +88 -0
  73. backtrader/brokers/hft/state.py +138 -0
  74. backtrader/brokers/impact_models.py +118 -0
  75. backtrader/brokers/mixbroker.py +895 -0
  76. backtrader/brokers/tickbroker.py +1991 -0
  77. backtrader/btrun/__init__.py +12 -0
  78. backtrader/btrun/btrun.py +1218 -0
  79. backtrader/cerebro.py +828 -0
  80. backtrader/channel.py +682 -0
  81. backtrader/channels/__init__.py +23 -0
  82. backtrader/channels/bridge.py +186 -0
  83. backtrader/channels/funding.py +248 -0
  84. backtrader/channels/live_queue.py +216 -0
  85. backtrader/channels/live_validator.py +294 -0
  86. backtrader/channels/orderbook.py +257 -0
  87. backtrader/channels/tick.py +202 -0
  88. backtrader/comminfo.py +665 -0
  89. backtrader/commissions/__init__.py +106 -0
  90. backtrader/commissions/ctpoption.py +993 -0
  91. backtrader/configs/account_config_example.yaml +8 -0
  92. backtrader/dataseries.py +379 -0
  93. backtrader/errors.py +106 -0
  94. backtrader/events.py +980 -0
  95. backtrader/feed.py +1523 -0
  96. backtrader/feeds/__init__.py +75 -0
  97. backtrader/feeds/barrier.py +2006 -0
  98. backtrader/feeds/blaze.py +118 -0
  99. backtrader/feeds/btapifeed.py +1538 -0
  100. backtrader/feeds/btcsv.py +203 -0
  101. backtrader/feeds/chainer.py +114 -0
  102. backtrader/feeds/cryptohftdata.py +164 -0
  103. backtrader/feeds/csvgeneric.py +1205 -0
  104. backtrader/feeds/ctpcohort.py +1051 -0
  105. backtrader/feeds/influxfeed.py +158 -0
  106. backtrader/feeds/livefeed.py +71 -0
  107. backtrader/feeds/mixed_channel.py +108 -0
  108. backtrader/feeds/mt4csv.py +42 -0
  109. backtrader/feeds/pandafeed.py +381 -0
  110. backtrader/feeds/quandl.py +256 -0
  111. backtrader/feeds/rollover.py +229 -0
  112. backtrader/feeds/sierrachart.py +30 -0
  113. backtrader/feeds/vchart.py +162 -0
  114. backtrader/feeds/vchartcsv.py +84 -0
  115. backtrader/feeds/vchartfile.py +153 -0
  116. backtrader/feeds/yahoo.py +399 -0
  117. backtrader/fillers.py +148 -0
  118. backtrader/filters/__init__.py +34 -0
  119. backtrader/filters/bsplitter.py +127 -0
  120. backtrader/filters/calendardays.py +121 -0
  121. backtrader/filters/datafiller.py +192 -0
  122. backtrader/filters/datafilter.py +74 -0
  123. backtrader/filters/daysteps.py +96 -0
  124. backtrader/filters/heikinashi.py +63 -0
  125. backtrader/filters/renko.py +164 -0
  126. backtrader/filters/session.py +289 -0
  127. backtrader/flt.py +80 -0
  128. backtrader/functions.py +960 -0
  129. backtrader/indicator.py +449 -0
  130. backtrader/indicators/__init__.py +148 -0
  131. backtrader/indicators/accdecoscillator.py +110 -0
  132. backtrader/indicators/aroon.py +300 -0
  133. backtrader/indicators/atr.py +315 -0
  134. backtrader/indicators/awesomeoscillator.py +122 -0
  135. backtrader/indicators/basicops.py +834 -0
  136. backtrader/indicators/bollinger.py +223 -0
  137. backtrader/indicators/cci.py +89 -0
  138. backtrader/indicators/channels_ext.py +83 -0
  139. backtrader/indicators/contrib/__init__.py +228 -0
  140. backtrader/indicators/contrib/absolutely_no_lag_lwma.py +28 -0
  141. backtrader/indicators/contrib/absolutely_no_lag_lwma_color.py +44 -0
  142. backtrader/indicators/contrib/accumulation_distribution_line.py +92 -0
  143. backtrader/indicators/contrib/adx_cross_hull_style_indicator.py +249 -0
  144. backtrader/indicators/contrib/adxdmi.py +34 -0
  145. backtrader/indicators/contrib/ai_acceleration_deceleration_oscillator.py +34 -0
  146. backtrader/indicators/contrib/altr_trend_signal_v22.py +85 -0
  147. backtrader/indicators/contrib/anchored_momentum_line.py +115 -0
  148. backtrader/indicators/contrib/any_range_cld_tail_indicator.py +82 -0
  149. backtrader/indicators/contrib/aroon_horn_sign_indicator.py +96 -0
  150. backtrader/indicators/contrib/aroon_oscillator_sign_alert.py +50 -0
  151. backtrader/indicators/contrib/arrows_curves_indicator.py +112 -0
  152. backtrader/indicators/contrib/as_ctrend_indicator.py +143 -0
  153. backtrader/indicators/contrib/asimmetric_stoch_nr_indicator.py +187 -0
  154. backtrader/indicators/contrib/atr_normalize_histogram.py +118 -0
  155. backtrader/indicators/contrib/average_change_candle.py +165 -0
  156. backtrader/indicators/contrib/bb_squeeze_indicator.py +60 -0
  157. backtrader/indicators/contrib/bezier_st_dev_indicator.py +135 -0
  158. backtrader/indicators/contrib/binary_wave_indicator.py +233 -0
  159. backtrader/indicators/contrib/blau_c_momentum_indicator.py +123 -0
  160. backtrader/indicators/contrib/blau_cmi_indicator.py +141 -0
  161. backtrader/indicators/contrib/blau_csi.py +76 -0
  162. backtrader/indicators/contrib/blau_ergodic.py +53 -0
  163. backtrader/indicators/contrib/blau_t_stoch_i.py +72 -0
  164. backtrader/indicators/contrib/blau_ts_stochastic.py +85 -0
  165. backtrader/indicators/contrib/blau_tvi.py +55 -0
  166. backtrader/indicators/contrib/brain_trend2_indicator.py +128 -0
  167. backtrader/indicators/contrib/brain_trend_signal_proxy.py +47 -0
  168. backtrader/indicators/contrib/brake_parb_indicator.py +85 -0
  169. backtrader/indicators/contrib/breakout_bars_trend_v2.py +121 -0
  170. backtrader/indicators/contrib/bsi_indicator.py +87 -0
  171. backtrader/indicators/contrib/bulls_bears_eyes.py +67 -0
  172. backtrader/indicators/contrib/bulls_power.py +56 -0
  173. backtrader/indicators/contrib/bw_wise_man1_signal.py +102 -0
  174. backtrader/indicators/contrib/bykov_trend_indicator.py +85 -0
  175. backtrader/indicators/contrib/candle_stop_color.py +46 -0
  176. backtrader/indicators/contrib/candles_x_smoothed_indicator.py +69 -0
  177. backtrader/indicators/contrib/candlesticks_bw.py +45 -0
  178. backtrader/indicators/contrib/caudate_x_period_candle_color.py +56 -0
  179. backtrader/indicators/contrib/cci_histogram_indicator.py +53 -0
  180. backtrader/indicators/contrib/cci_woodies_indicator.py +80 -0
  181. backtrader/indicators/contrib/center_of_gravity_candle_indicator.py +83 -0
  182. backtrader/indicators/contrib/center_of_gravity_indicator.py +70 -0
  183. backtrader/indicators/contrib/cg_oscillator.py +40 -0
  184. backtrader/indicators/contrib/close_line_cci.py +38 -0
  185. backtrader/indicators/contrib/close_price_fractals.py +47 -0
  186. backtrader/indicators/contrib/color3rd_gen_xma_indicator.py +122 -0
  187. backtrader/indicators/contrib/color_bb_candles_indicator.py +108 -0
  188. backtrader/indicators/contrib/color_coppock_indicator.py +157 -0
  189. backtrader/indicators/contrib/color_hma.py +71 -0
  190. backtrader/indicators/contrib/color_j_variation_indicator.py +53 -0
  191. backtrader/indicators/contrib/color_metro_de_marker_indicator.py +78 -0
  192. backtrader/indicators/contrib/color_metro_stochastic_indicator.py +93 -0
  193. backtrader/indicators/contrib/color_metro_wpr_indicator.py +85 -0
  194. backtrader/indicators/contrib/color_schaff_de_marker_trend_cycle.py +92 -0
  195. backtrader/indicators/contrib/color_schaff_trend_cycle_indicator.py +203 -0
  196. backtrader/indicators/contrib/color_step_xccx_indicator.py +193 -0
  197. backtrader/indicators/contrib/color_x2_ma.py +49 -0
  198. backtrader/indicators/contrib/color_x_derivative.py +63 -0
  199. backtrader/indicators/contrib/color_zerolag_de_marker.py +84 -0
  200. backtrader/indicators/contrib/corrected_average_indicator.py +127 -0
  201. backtrader/indicators/contrib/darvas_boxes_system.py +73 -0
  202. backtrader/indicators/contrib/dema_range_channel_color.py +42 -0
  203. backtrader/indicators/contrib/derivative_indicator.py +95 -0
  204. backtrader/indicators/contrib/digital_ft01_indicator.py +112 -0
  205. backtrader/indicators/contrib/digital_macd.py +200 -0
  206. backtrader/indicators/contrib/donchian_channels_system.py +45 -0
  207. backtrader/indicators/contrib/dots_indicator.py +93 -0
  208. backtrader/indicators/contrib/ef_distance_indicator.py +82 -0
  209. backtrader/indicators/contrib/ema_rsi_va.py +80 -0
  210. backtrader/indicators/contrib/envelopes_jp_alonso.py +32 -0
  211. backtrader/indicators/contrib/f2a_ao_indicator.py +120 -0
  212. backtrader/indicators/contrib/fatl_filter.py +179 -0
  213. backtrader/indicators/contrib/fibo_candles_indicator.py +78 -0
  214. backtrader/indicators/contrib/fine_tuning_ma.py +100 -0
  215. backtrader/indicators/contrib/fisher_org_v1.py +102 -0
  216. backtrader/indicators/contrib/fisher_org_v1_sign.py +118 -0
  217. backtrader/indicators/contrib/force_index_ema.py +96 -0
  218. backtrader/indicators/contrib/force_index_ema_2.py +27 -0
  219. backtrader/indicators/contrib/forecast_oscilator.py +145 -0
  220. backtrader/indicators/contrib/fractal_amambk.py +81 -0
  221. backtrader/indicators/contrib/frama_series.py +84 -0
  222. backtrader/indicators/contrib/frasm_av2_indicator.py +104 -0
  223. backtrader/indicators/contrib/go_indicator.py +93 -0
  224. backtrader/indicators/contrib/hlr_indicator.py +95 -0
  225. backtrader/indicators/contrib/hma.py +50 -0
  226. backtrader/indicators/contrib/i4_drfv2.py +34 -0
  227. backtrader/indicators/contrib/i4_drfv3.py +38 -0
  228. backtrader/indicators/contrib/i_anch_mom_indicator.py +72 -0
  229. backtrader/indicators/contrib/i_de_marker_sign_indicator.py +64 -0
  230. backtrader/indicators/contrib/i_gap_indicator.py +45 -0
  231. backtrader/indicators/contrib/i_stoch_komposter_indicator.py +77 -0
  232. backtrader/indicators/contrib/i_trend_indicator.py +125 -0
  233. backtrader/indicators/contrib/iamma_indicator.py +39 -0
  234. backtrader/indicators/contrib/indexed_moving_average.py +33 -0
  235. backtrader/indicators/contrib/instantaneous_trend_filter_indicator.py +51 -0
  236. backtrader/indicators/contrib/inverse_reaction_indicator.py +41 -0
  237. backtrader/indicators/contrib/irsi_sign_indicator.py +95 -0
  238. backtrader/indicators/contrib/iwpr_sign_indicator.py +59 -0
  239. backtrader/indicators/contrib/j_brain_trend1_sig_indicator.py +233 -0
  240. backtrader/indicators/contrib/j_tpo_proxy.py +32 -0
  241. backtrader/indicators/contrib/jma_slope_indicator.py +73 -0
  242. backtrader/indicators/contrib/kalman_filter_indicator.py +119 -0
  243. backtrader/indicators/contrib/kalman_filter_line.py +127 -0
  244. backtrader/indicators/contrib/kama_indicator.py +150 -0
  245. backtrader/indicators/contrib/karacatica_indicator.py +99 -0
  246. backtrader/indicators/contrib/kdj_indicator.py +59 -0
  247. backtrader/indicators/contrib/kwan_ccc_indicator.py +195 -0
  248. backtrader/indicators/contrib/kwan_nrp_indicator.py +113 -0
  249. backtrader/indicators/contrib/kwan_rdp_indicator.py +192 -0
  250. backtrader/indicators/contrib/laguerre_adx_indicator.py +85 -0
  251. backtrader/indicators/contrib/laguerre_filter_indicator.py +66 -0
  252. backtrader/indicators/contrib/laguerre_plus_di_proxy.py +57 -0
  253. backtrader/indicators/contrib/laguerre_roc_indicator.py +81 -0
  254. backtrader/indicators/contrib/le_man_signal_indicator.py +63 -0
  255. backtrader/indicators/contrib/linear_reg_slope_v2_indicator.py +136 -0
  256. backtrader/indicators/contrib/loco_indicator.py +88 -0
  257. backtrader/indicators/contrib/lrma_indicator.py +185 -0
  258. backtrader/indicators/contrib/lsma_angle_indicator.py +106 -0
  259. backtrader/indicators/contrib/ma_rounding_channel_indicator.py +149 -0
  260. backtrader/indicators/contrib/macd2_indicator.py +61 -0
  261. backtrader/indicators/contrib/macd_candle_indicator.py +80 -0
  262. backtrader/indicators/contrib/malr_indicator.py +77 -0
  263. backtrader/indicators/contrib/momentum_candle_sign_indicator.py +51 -0
  264. backtrader/indicators/contrib/moving_average_fn_indicator.py +139 -0
  265. backtrader/indicators/contrib/mt5_stochastic_close_close.py +57 -0
  266. backtrader/indicators/contrib/muv_nor_diff_cloud_indicator.py +107 -0
  267. backtrader/indicators/contrib/non_lag_dot_indicator.py +124 -0
  268. backtrader/indicators/contrib/nrtr_extr_indicator.py +95 -0
  269. backtrader/indicators/contrib/nrtr_indicator.py +95 -0
  270. backtrader/indicators/contrib/p_channel_system.py +40 -0
  271. backtrader/indicators/contrib/percent_envelope.py +37 -0
  272. backtrader/indicators/contrib/percentage_crossover_channel.py +47 -0
  273. backtrader/indicators/contrib/pivot_zig_zag_proxy.py +47 -0
  274. backtrader/indicators/contrib/price_channel_stop_indicator.py +104 -0
  275. backtrader/indicators/contrib/price_extreme_channel.py +35 -0
  276. backtrader/indicators/contrib/qqe_cloud_indicator.py +129 -0
  277. backtrader/indicators/contrib/ravi_indicator.py +40 -0
  278. backtrader/indicators/contrib/raw_close_close_stochastic.py +74 -0
  279. backtrader/indicators/contrib/rd_trend_trigger_indicator.py +51 -0
  280. backtrader/indicators/contrib/renko_level.py +85 -0
  281. backtrader/indicators/contrib/renko_line_break.py +91 -0
  282. backtrader/indicators/contrib/rftl_indicator.py +41 -0
  283. backtrader/indicators/contrib/rkd_indicator.py +53 -0
  284. backtrader/indicators/contrib/roc2_vg_indicator.py +68 -0
  285. backtrader/indicators/contrib/rsi_histogram_indicator.py +43 -0
  286. backtrader/indicators/contrib/rsi_slowdown.py +57 -0
  287. backtrader/indicators/contrib/rsioma_v2.py +41 -0
  288. backtrader/indicators/contrib/rvi_histogram_indicator.py +107 -0
  289. backtrader/indicators/contrib/safe_adx.py +89 -0
  290. backtrader/indicators/contrib/shared_strategy_indicators.py +1651 -0
  291. backtrader/indicators/contrib/sidus_indicator.py +105 -0
  292. backtrader/indicators/contrib/silver_trend_indicator.py +79 -0
  293. backtrader/indicators/contrib/sliding_range_color.py +56 -0
  294. backtrader/indicators/contrib/slow_stoch.py +42 -0
  295. backtrader/indicators/contrib/smoothed_adx_indicator.py +86 -0
  296. backtrader/indicators/contrib/smoothed_rsi.py +31 -0
  297. backtrader/indicators/contrib/spearman_rank_correlation_histogram.py +60 -0
  298. backtrader/indicators/contrib/stalin_indicator.py +152 -0
  299. backtrader/indicators/contrib/starter_laguerre_filter.py +62 -0
  300. backtrader/indicators/contrib/step_manrtr_indicator.py +137 -0
  301. backtrader/indicators/contrib/stochastic_histogram_indicator.py +143 -0
  302. backtrader/indicators/contrib/t3_alarm_indicator.py +125 -0
  303. backtrader/indicators/contrib/t3_average.py +76 -0
  304. backtrader/indicators/contrib/t3_indicator.py +40 -0
  305. backtrader/indicators/contrib/the20s_v020_signal.py +93 -0
  306. backtrader/indicators/contrib/three_candles_indicator.py +70 -0
  307. backtrader/indicators/contrib/three_line_break_indicator.py +64 -0
  308. backtrader/indicators/contrib/time_line.py +57 -0
  309. backtrader/indicators/contrib/trading_channel_index_proxy.py +48 -0
  310. backtrader/indicators/contrib/trend_arrows_indicator.py +109 -0
  311. backtrader/indicators/contrib/trend_continuation_indicator.py +127 -0
  312. backtrader/indicators/contrib/trend_intensity_index_proxy.py +51 -0
  313. backtrader/indicators/contrib/trend_manager_indicator.py +39 -0
  314. backtrader/indicators/contrib/tri_x_candle_indicator.py +51 -0
  315. backtrader/indicators/contrib/trigger_line.py +66 -0
  316. backtrader/indicators/contrib/triple_ema_rate.py +34 -0
  317. backtrader/indicators/contrib/trvi_indicator.py +194 -0
  318. backtrader/indicators/contrib/two_pb_ideal_xosma_indicator.py +127 -0
  319. backtrader/indicators/contrib/ultra_absolutely_no_lag_lwma_color.py +92 -0
  320. backtrader/indicators/contrib/ultra_wpr_indicator.py +173 -0
  321. backtrader/indicators/contrib/up_down_candle_strength.py +68 -0
  322. backtrader/indicators/contrib/vinin_i_trend_indicator.py +139 -0
  323. backtrader/indicators/contrib/volume_weighted_ma_indicator.py +78 -0
  324. backtrader/indicators/contrib/volume_weighted_ma_st_dev_indicator.py +111 -0
  325. backtrader/indicators/contrib/vwap_close_indicator.py +65 -0
  326. backtrader/indicators/contrib/vwma_candle.py +57 -0
  327. backtrader/indicators/contrib/vwma_digit_system.py +70 -0
  328. backtrader/indicators/contrib/wami.py +43 -0
  329. backtrader/indicators/contrib/wprsi_signal_indicator.py +105 -0
  330. backtrader/indicators/contrib/x_de_marker_histogram_vol_direct_indicator.py +145 -0
  331. backtrader/indicators/contrib/x_fisher_indicator.py +64 -0
  332. backtrader/indicators/contrib/xcci_histogram_vol_direct_indicator.py +56 -0
  333. backtrader/indicators/contrib/xcci_histogram_vol_indicator.py +85 -0
  334. backtrader/indicators/contrib/xma_ichimoku.py +163 -0
  335. backtrader/indicators/contrib/xma_ishimoku_channel_indicator.py +65 -0
  336. backtrader/indicators/contrib/xma_ishimoku_line.py +68 -0
  337. backtrader/indicators/contrib/xma_range_bands_indicator.py +107 -0
  338. backtrader/indicators/contrib/xmacd_indicator.py +70 -0
  339. backtrader/indicators/contrib/xrsi_de_marker_histogram.py +67 -0
  340. backtrader/indicators/contrib/xrsi_histogram_vol_direct_indicator.py +52 -0
  341. backtrader/indicators/contrib/xrsi_histogram_vol_indicator.py +81 -0
  342. backtrader/indicators/contrib/xrvi_indicator.py +130 -0
  343. backtrader/indicators/contrib/zero_lag_macd.py +36 -0
  344. backtrader/indicators/contrib/zig_zag_recent_pivot_signal.py +90 -0
  345. backtrader/indicators/contrib/zpf_indicator.py +115 -0
  346. backtrader/indicators/crossover.py +337 -0
  347. backtrader/indicators/dema.py +175 -0
  348. backtrader/indicators/demarker.py +270 -0
  349. backtrader/indicators/deviation.py +284 -0
  350. backtrader/indicators/directionalmove.py +1071 -0
  351. backtrader/indicators/dma.py +112 -0
  352. backtrader/indicators/dpo.py +96 -0
  353. backtrader/indicators/dv2.py +56 -0
  354. backtrader/indicators/ema.py +145 -0
  355. backtrader/indicators/envelope.py +475 -0
  356. backtrader/indicators/hadelta.py +198 -0
  357. backtrader/indicators/heikinashi.py +153 -0
  358. backtrader/indicators/hma.py +153 -0
  359. backtrader/indicators/hurst.py +151 -0
  360. backtrader/indicators/ichimoku.py +267 -0
  361. backtrader/indicators/kama.py +181 -0
  362. backtrader/indicators/kst.py +159 -0
  363. backtrader/indicators/lrsi.py +125 -0
  364. backtrader/indicators/mabase.py +147 -0
  365. backtrader/indicators/macd.py +322 -0
  366. backtrader/indicators/momentum.py +267 -0
  367. backtrader/indicators/moneyflow.py +237 -0
  368. backtrader/indicators/mt5atr.py +124 -0
  369. backtrader/indicators/myind.py +179 -0
  370. backtrader/indicators/obv.py +94 -0
  371. backtrader/indicators/ols.py +265 -0
  372. backtrader/indicators/oscillator.py +161 -0
  373. backtrader/indicators/percentchange.py +83 -0
  374. backtrader/indicators/percentrank.py +46 -0
  375. backtrader/indicators/pivotpoint.py +469 -0
  376. backtrader/indicators/prettygoodoscillator.py +113 -0
  377. backtrader/indicators/priceops_ext.py +123 -0
  378. backtrader/indicators/priceoscillator.py +262 -0
  379. backtrader/indicators/psar.py +212 -0
  380. backtrader/indicators/rmi.py +69 -0
  381. backtrader/indicators/rsi.py +440 -0
  382. backtrader/indicators/sma.py +141 -0
  383. backtrader/indicators/smma.py +116 -0
  384. backtrader/indicators/spread.py +54 -0
  385. backtrader/indicators/stochastic.py +263 -0
  386. backtrader/indicators/supertrend.py +436 -0
  387. backtrader/indicators/trend_ext.py +105 -0
  388. backtrader/indicators/trix.py +202 -0
  389. backtrader/indicators/tsi.py +155 -0
  390. backtrader/indicators/ultimateoscillator.py +158 -0
  391. backtrader/indicators/vortex.py +62 -0
  392. backtrader/indicators/williams.py +194 -0
  393. backtrader/indicators/wma.py +103 -0
  394. backtrader/indicators/zlema.py +135 -0
  395. backtrader/indicators/zlind.py +104 -0
  396. backtrader/linebuffer.py +3155 -0
  397. backtrader/lineiterator.py +2911 -0
  398. backtrader/lineroot.py +1106 -0
  399. backtrader/lineseries.py +2559 -0
  400. backtrader/live_trading/__init__.py +31 -0
  401. backtrader/live_trading/interface.py +404 -0
  402. backtrader/mathsupport.py +94 -0
  403. backtrader/metabase.py +1804 -0
  404. backtrader/mixins/__init__.py +21 -0
  405. backtrader/mixins/singleton.py +118 -0
  406. backtrader/observer.py +106 -0
  407. backtrader/observers/__init__.py +45 -0
  408. backtrader/observers/benchmark.py +126 -0
  409. backtrader/observers/broker.py +184 -0
  410. backtrader/observers/buysell.py +144 -0
  411. backtrader/observers/drawdown.py +161 -0
  412. backtrader/observers/logreturns.py +113 -0
  413. backtrader/observers/timereturn.py +86 -0
  414. backtrader/observers/trade_logger.py +2972 -0
  415. backtrader/observers/tradelogger.py +6 -0
  416. backtrader/observers/trades.py +258 -0
  417. backtrader/order.py +1114 -0
  418. backtrader/parameters.py +2345 -0
  419. backtrader/plot/__init__.py +54 -0
  420. backtrader/plot/finance.py +1022 -0
  421. backtrader/plot/formatters.py +200 -0
  422. backtrader/plot/locator.py +353 -0
  423. backtrader/plot/multicursor.py +495 -0
  424. backtrader/plot/plot.py +2500 -0
  425. backtrader/plot/plot_plotly.py +1351 -0
  426. backtrader/plot/scheme.py +253 -0
  427. backtrader/plot/utils.py +104 -0
  428. backtrader/position.py +290 -0
  429. backtrader/position_modes.py +132 -0
  430. backtrader/profiles.py +254 -0
  431. backtrader/reports/__init__.py +39 -0
  432. backtrader/reports/charts.py +371 -0
  433. backtrader/reports/performance.py +620 -0
  434. backtrader/reports/reporter.py +660 -0
  435. backtrader/resamplerfilter.py +1001 -0
  436. backtrader/signal.py +118 -0
  437. backtrader/signals/__init__.py +17 -0
  438. backtrader/sizer.py +114 -0
  439. backtrader/sizers/__init__.py +26 -0
  440. backtrader/sizers/fixedsize.py +161 -0
  441. backtrader/sizers/percents_sizer.py +119 -0
  442. backtrader/store.py +221 -0
  443. backtrader/stores/__init__.py +33 -0
  444. backtrader/stores/btapistore.py +15506 -0
  445. backtrader/stores/livestore.py +137 -0
  446. backtrader/stores/vchartfile.py +96 -0
  447. backtrader/strategy.py +3655 -0
  448. backtrader/talib.py +280 -0
  449. backtrader/test_helpers.py +96 -0
  450. backtrader/timer.py +358 -0
  451. backtrader/trade.py +442 -0
  452. backtrader/tradingcal.py +361 -0
  453. backtrader/utils/__init__.py +68 -0
  454. backtrader/utils/autodict.py +251 -0
  455. backtrader/utils/date.py +71 -0
  456. backtrader/utils/dateintern.py +509 -0
  457. backtrader/utils/flushfile.py +94 -0
  458. backtrader/utils/fractal.py +101 -0
  459. backtrader/utils/get_metrics.py +101 -0
  460. backtrader/utils/load_data.py +209 -0
  461. backtrader/utils/log_message.py +998 -0
  462. backtrader/utils/ordereddefaultdict.py +75 -0
  463. backtrader/utils/py3.py +296 -0
  464. backtrader/version.py +21 -0
  465. backtrader/writer.py +372 -0
@@ -0,0 +1,1491 @@
1
+ Metadata-Version: 2.4
2
+ Name: back-trader-python
3
+ Version: 1.4.0
4
+ Summary: Python Algorithmic Trading Backtesting Framework
5
+ Home-page: https://github.com/cloudQuant/backtrader
6
+ Author: cloudQuant
7
+ Author-email: yunjinqi@qq.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy<2.0.0,>=1.20.0; python_version < "3.13"
21
+ Requires-Dist: numpy>=2.1.0; python_version >= "3.13"
22
+ Requires-Dist: pytz>=2021.1
23
+ Requires-Dist: pandas>=1.3.0
24
+ Requires-Dist: matplotlib>=3.3.0
25
+ Requires-Dist: scipy>=1.5.0
26
+ Requires-Dist: statsmodels>=0.12.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest; extra == "dev"
29
+ Requires-Dist: pytest-cov; extra == "dev"
30
+ Requires-Dist: pytest-xdist; extra == "dev"
31
+ Requires-Dist: pytest-html; extra == "dev"
32
+ Requires-Dist: pytest-timeout; extra == "dev"
33
+ Requires-Dist: pytest-asyncio; extra == "dev"
34
+ Requires-Dist: ruff; extra == "dev"
35
+ Requires-Dist: black; extra == "dev"
36
+ Requires-Dist: isort; extra == "dev"
37
+ Requires-Dist: plotly; extra == "dev"
38
+ Requires-Dist: seaborn; extra == "dev"
39
+ Requires-Dist: dash; extra == "dev"
40
+ Requires-Dist: bokeh; extra == "dev"
41
+ Requires-Dist: pyecharts; extra == "dev"
42
+ Requires-Dist: scikit-learn; extra == "dev"
43
+ Requires-Dist: hmmlearn>=0.3.3; extra == "dev"
44
+ Requires-Dist: mysql-connector-python; extra == "dev"
45
+ Requires-Dist: python-dotenv; extra == "dev"
46
+ Requires-Dist: psutil; extra == "dev"
47
+ Requires-Dist: PyYAML; extra == "dev"
48
+ Requires-Dist: python-docx>=0.8.11; extra == "dev"
49
+ Requires-Dist: websockets; extra == "dev"
50
+ Requires-Dist: aiohttp; extra == "dev"
51
+ Requires-Dist: cryptography>=3.4; extra == "dev"
52
+ Provides-Extra: plotting
53
+ Requires-Dist: plotly; extra == "plotting"
54
+ Requires-Dist: bokeh; extra == "plotting"
55
+ Requires-Dist: dash; extra == "plotting"
56
+ Requires-Dist: pyecharts; extra == "plotting"
57
+ Provides-Extra: cryptohftdata
58
+ Requires-Dist: cryptohftdata<1.0.0,>=0.4.0; extra == "cryptohftdata"
59
+ Provides-Extra: live
60
+ Requires-Dist: cryptography>=3.4; extra == "live"
61
+ Dynamic: author
62
+ Dynamic: author-email
63
+ Dynamic: classifier
64
+ Dynamic: description
65
+ Dynamic: description-content-type
66
+ Dynamic: home-page
67
+ Dynamic: license-file
68
+ Dynamic: provides-extra
69
+ Dynamic: requires-dist
70
+ Dynamic: requires-python
71
+ Dynamic: summary
72
+
73
+ <div align="center">
74
+
75
+ # 🚀 Backtrader
76
+
77
+ **Professional Python Algorithmic Trading Backtesting Framework**
78
+
79
+ [![Version](https://img.shields.io/badge/Version-1.4.0-blue.svg)](https://github.com/cloudQuant/backtrader)
80
+ [![Python](https://img.shields.io/badge/Python-3.8%2B-green.svg)](https://www.python.org/)
81
+ [![License](https://img.shields.io/badge/License-GPLv3-orange.svg)](https://www.gnu.org/licenses/gpl-3.0)
82
+ [![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey.svg)](#)
83
+
84
+ **English** | [**中文**](#-中文文档)
85
+
86
+ [📖 Documentation (EN)](https://backtrader.readthedocs.io/en/latest/) ·
87
+ [📖 中文文档](https://backtrader-zh.readthedocs.io/zh-cn/latest/) ·
88
+ [🌐 GitHub Pages](https://cloudquant.github.io/backtrader/)
89
+
90
+ [🐛 Report Bug](https://github.com/cloudQuant/backtrader/issues) ·
91
+ [💬 Discussions](https://github.com/cloudQuant/backtrader/discussions)
92
+
93
+ </div>
94
+
95
+ ---
96
+
97
+ ## Installation
98
+
99
+ Install the pure-Python package directly from PyPI:
100
+
101
+ ```bash
102
+ pip install back-trader-python
103
+ ```
104
+
105
+ > **Note**: `back-trader-python` is the PyPI distribution name; the import name remains `backtrader` (`import backtrader as bt`).
106
+
107
+ For the pybind11-accelerated C++ wheel (order-of-magnitude faster backtests):
108
+
109
+ ```bash
110
+ pip install back-trader-cpp
111
+ ```
112
+
113
+ https://pypi.org/project/back-trader-python/ · https://pypi.org/project/back-trader-cpp/
114
+
115
+ Both support Python 3.8+ (the C++ wheel covers 3.8-3.14) on macOS, Windows, and Linux.
116
+
117
+ ## C++ and pybind11 Performance Highlights
118
+
119
+ - 117 strategy benchmark cases, with the C++ version reaching 117/117 success and 0 metric mismatches;
120
+ - C++ total-time median speedup: 128.82x;
121
+ - C++ run-time median speedup: 235.78x;
122
+ - pybind11 total-time median speedup: 43.39x;
123
+ - pybind11 run-time median speedup: 57.60x.
124
+
125
+ ---
126
+
127
+ ## 📋 Table of Contents
128
+
129
+ - [Installation](#installation)
130
+ - [C++ and pybind11 Performance Highlights](#c-and-pybind11-performance-highlights)
131
+ - [Performance Snapshot](#-performance-snapshot)
132
+ - [Introduction](#-introduction)
133
+ - [Project Ecosystem](#-project-ecosystem)
134
+ - [Key Features](#-key-features)
135
+ - [Quick Installation](#-quick-installation)
136
+ - [5-Minute Quickstart](#-5-minute-quickstart)
137
+ - [Core Concepts](#-core-concepts)
138
+ - [Built-in Components](#-built-in-components)
139
+ - [Advanced Topics](#-advanced-topics)
140
+ - [Project Architecture](#-project-architecture)
141
+ - [Testing](#-testing)
142
+ - [Repository Maintenance Notes](#-repository-maintenance-notes)
143
+ - [API Documentation](#-api-documentation)
144
+ - [FAQ](#-faq)
145
+ - [Contributing](#-contributing)
146
+ - [License](#-license)
147
+ - [中文文档](#-中文文档)
148
+
149
+ ---
150
+
151
+ ## ⚡ Performance Snapshot
152
+
153
+ The active `dev` branch carries the optimization work originally developed on the
154
+ `development` branch. Running the **full 1,271-strategy regression suite**
155
+ (`tests/functional/strategies`, `-n 8`) against the installed engine, `dev`
156
+ completes in **about half the time** of `master`.
157
+
158
+ ### 📊 Benchmark Results (full strategy suite)
159
+
160
+ | Metric | Master Branch | Dev Branch | Improvement |
161
+ | --- | --- | --- | --- |
162
+ | **Total Execution Time** | 438.96s (7m18s) | 236.36s (3m56s) | **-46.2%** |
163
+ | **Speedup** | 1.00x | **1.86x** | ✓ |
164
+ | **Strategies Tested** | 1,271 | 1,271 | ✓ |
165
+ | **Test Pass Rate** | 100% (1271 passed) | 100% (1271 passed) | ✓ |
166
+
167
+ > *Benchmark: `pytest tests/functional/strategies -n 8` on identical hardware
168
+ > (macOS, Python 3.11, 8 parallel xdist workers). Master measured via
169
+ > `--use-installed-backtrader` against the master build.*
170
+
171
+ An earlier internal benchmark on a smaller 119-strategy sample showed a
172
+ comparable ~45% reduction (553.12s → 305.36s).
173
+
174
+ ### 📈 Performance by Strategy Type
175
+
176
+ | Strategy Category | Avg Speedup | Example |
177
+ | --- | --- | --- |
178
+ | Simple MA Cross | 40-45% | `test_03_two_ma`: 2.6s → 1.5s |
179
+ | Multi-Indicator | 45-50% | `test_09_dual_thrust`: 59.2s → 26.9s |
180
+ | Multi-Data | 42-48% | `test_02_multi_extend_data`: 23.5s → 12.6s |
181
+ | Complex Strategies | 38-42% | `test_08_kelter_strategy`: 36.9s → 11.3s |
182
+
183
+ ---
184
+
185
+ ## 🎯 Introduction
186
+
187
+ Backtrader is a powerful and flexible Python framework for backtesting trading strategies.
188
+ This project is based on [backtrader](https://www.backtrader.com/) with extensive
189
+ optimizations and feature enhancements, supporting **low-frequency, mid-frequency, and
190
+ high-frequency** strategy development, backtesting, and live trading.
191
+
192
+ ### Why Choose Backtrader?
193
+
194
+ | Comparison | Backtrader | Other Frameworks |
195
+ | --- | --- | --- |
196
+ | Learning Curve | ⭐⭐ Gentle | ⭐⭐⭐⭐ Steep |
197
+ | Development Efficiency | ⭐⭐⭐⭐⭐ Very High | ⭐⭐⭐ Average |
198
+ | Built-in Indicators | 50+ | 10-30 |
199
+ | Data Source Support | 20+ | 5-10 |
200
+ | Community Activity | ⭐⭐⭐⭐ Active | ⭐⭐ Average |
201
+ | Documentation | ⭐⭐⭐⭐⭐ Complete | ⭐⭐⭐ Average |
202
+
203
+ ### Project Branches
204
+
205
+ - **`master`**: Original Backtrader baseline; only original-baseline bug, compatibility, and
206
+ security hotfixes belong here
207
+ - **`dev`**: Daily development entry for routine features, fixes, tests, documentation, and
208
+ refactors
209
+ - **`development`**: Improved and optimized release branch; controlled `dev` promotions and
210
+ CI/CD run here
211
+
212
+ ---
213
+
214
+ ## 🌐 Project Ecosystem
215
+
216
+ The CloudQuant Backtrader ecosystem spans the core engine plus five companion
217
+ projects — AI-assisted strategy development (skills, MCP, agent), a web-based
218
+ research & trading platform, and a quantitative analytics library:
219
+
220
+ | Project | Description |
221
+ | --- | --- |
222
+ | [`cloudQuant/backtrader`](https://github.com/cloudQuant/backtrader) | **Core engine (this repository)** — high-performance Python framework for backtesting and live trading across all frequencies. |
223
+ | [`cloudQuant/backtrader-skills`](https://github.com/cloudQuant/backtrader-skills) | Offline author/review/test skills for AI agents — turns registered local datasets and typed `StrategySpec v1` specs into pytest strategies or three-file bundles, reviews candidates without importing them, and runs approved candidates in isolated child processes. |
224
+ | [`cloudQuant/backtrader-mcp`](https://github.com/cloudQuant/backtrader-mcp) | Local-first MCP server — typed tools, resources, and prompts for building and running reproducible strategies: immutable datasets, private drafts, and bounded subprocess runs with durable status and reports. |
225
+ | [`cloudQuant/backtrader-agent`](https://github.com/cloudQuant/backtrader-agent) | Offline-first strategy-authoring agent runtime — canonical strategy specifications, static review, hash-bound approvals, fixed child-process execution, and recoverable session provenance. |
226
+ | [`cloudQuant/backtrader_web`](https://github.com/cloudQuant/backtrader_web) | **"AI for Investor"** — Vue 3 + FastAPI web platform for the full strategy lifecycle: research, strategy generation, backtesting, paper trading, live execution, and market-data management. |
227
+ | [`cloudQuant/fincore`](https://github.com/cloudQuant/fincore) | Quantitative performance & risk analytics library — 150+ financial metrics, portfolio optimization, Monte Carlo simulation, and performance attribution. |
228
+
229
+ The three AI products (skills, MCP, agent) implement the same end-to-end
230
+ strategy workflow through different host integration surfaces; none requires
231
+ either of the other two. Install, test, release, and contribute to each product
232
+ in its own repository — the Backtrader core repository neither vendors nor
233
+ initializes those products.
234
+
235
+ ---
236
+
237
+ ## ✨ Key Features
238
+
239
+ ### 🚀 High-Performance Multi-Frequency Backtesting Engine
240
+
241
+ ```text
242
+ Three backtesting modes supported:
243
+ ├── runonce (Vectorized) - Batch computation, optimal performance
244
+ ├── runnext (Event-driven) - Bar-by-bar, suitable for complex logic
245
+ └── Tick-level backtesting - Tick data support with tick+bar mixed mode
246
+
247
+ Trading frequency spectrum:
248
+ ├── Low-frequency - Daily/weekly bars, position trading
249
+ ├── Mid-frequency - Minute/hour bars, intraday trading
250
+ └── High-frequency - Tick-level data, market microstructure
251
+ ```
252
+
253
+ ### 📊 Rich Visualization
254
+
255
+ - **Plotly Interactive Charts**: Supports 100k+ data points with zoom, pan, hover
256
+ - **Bokeh Real-time Charts**: Real-time data updates and multi-tab support
257
+ - **Matplotlib Static Charts**: Classic plotting for papers and reports
258
+
259
+ ### 📈 Professional Reports
260
+
261
+ One-click generation of professional reports including:
262
+
263
+ - Equity curves and drawdown charts
264
+ - Sharpe ratio, Calmar ratio, SQN rating
265
+ - Detailed trade statistics and P&L analysis
266
+ - Export to HTML, PDF, JSON formats
267
+
268
+ ### 🔧 50+ Built-in Technical Indicators
269
+
270
+ Covering moving averages, momentum, volatility, trend indicators, and more.
271
+
272
+ ### 🔄 Tick-Level & Mixed-Frequency Trading
273
+
274
+ - **Tick-level backtesting**: Process individual tick data for high-frequency strategy research
275
+ - **Tick + Bar mixed mode**: Combine tick and bar data in the same strategy
276
+ - **Seamless live trading**: Same strategy code works for backtesting and live trading
277
+ - **Full spectrum coverage**: Low-frequency (daily), mid-frequency (minute), and high-frequency (tick) — all unified
278
+
279
+ ### 📝 TradeLogger - Real-time Trade Logging
280
+
281
+ Comprehensive observer for real-time logging during backtests:
282
+
283
+ - **Real-time file writing**: Logs are appended on every bar (not just at the end)
284
+ - **`current_position.json`**: Updated after each bar with the latest holdings
285
+ - **Strategy indicators**: Optionally log strategy-calculated indicators in data files
286
+ - **Configurable format**: Tab-separated `.log` (default) or standard `.csv`
287
+ - **MySQL persistence**: Order/trade/position logs saved to MySQL (`bt_order`, `bt_trade`, `bt_position`)
288
+ - **Generic in-memory report**: `snapshot()` provides a detached real-time status view and
289
+ `final_report()` returns the immutable report frozen after the strategy stops. It works with
290
+ any Backtrader broker, store, feed, or strategy and does not require file or MySQL logging.
291
+ Core brokers expose cached cash, value, and positions through a local-only report-state API,
292
+ so a snapshot does not trigger a live account request. This guarantee covers the in-memory
293
+ report API; enabled legacy file sinks retain their own broker-read behavior.
294
+
295
+ ```python
296
+ cerebro.addobserver(
297
+ bt.observers.TradeLogger,
298
+ obsname='trade_logger',
299
+ log_dir='logs',
300
+ log_indicators=True,
301
+ file_format='log', # 'log' or 'csv'
302
+ # mysql_enabled=True, # optional MySQL persistence
303
+ # mysql_database='backtrder_web',
304
+ )
305
+
306
+ # Inside a strategy: self.stats.trade_logger.snapshot()
307
+ # After cerebro.run(): strategies[0].stats.trade_logger.final_report()
308
+ ```
309
+
310
+ ### 📦 Modular Architecture
311
+
312
+ Strategies, indicators, analyzers, and data sources can be independently extended.
313
+
314
+ ### 🌍 20+ Data Source Support
315
+
316
+ CSV, Pandas, Yahoo Finance, Interactive Brokers, CCXT cryptocurrency, CTP futures, and more.
317
+
318
+ ---
319
+
320
+ ## 📥 Quick Installation
321
+
322
+ ### Requirements
323
+
324
+ - **Python**: 3.8+ (3.11 recommended for ~15% performance boost)
325
+ - **OS**: Windows / macOS / Linux
326
+ - **RAM**: 4GB+ recommended
327
+
328
+ ### From PyPI (Primary)
329
+
330
+ ```bash
331
+ pip install back-trader-python
332
+ ```
333
+
334
+ Then `import backtrader as bt` — the distribution name is `back-trader-python`, the import name stays `backtrader`.
335
+
336
+ For the C++/pybind11-accelerated wheel: `pip install back-trader-cpp`.
337
+
338
+ ### From Source (Developers)
339
+
340
+ ```bash
341
+ git clone https://github.com/cloudQuant/backtrader.git
342
+ cd backtrader
343
+ pip install -r requirements.txt
344
+ pip install -U .
345
+ ```
346
+
347
+ ### Verify Installation
348
+
349
+ ```python
350
+ import backtrader as bt
351
+ print(f"Backtrader version: {bt.__version__}")
352
+ # Output: Backtrader version: 1.4.0
353
+ ```
354
+
355
+ ### Run Tests
356
+
357
+ ```bash
358
+ pytest tests -n 4
359
+ ```
360
+
361
+ ---
362
+
363
+ ## 🎓 5-Minute Quickstart
364
+
365
+ ### Step 1: Understand the Workflow
366
+
367
+ ```text
368
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
369
+ │ Prepare │ -> │ Write │ -> │ Run │
370
+ │ Data │ │ Strategy │ │ Backtest │
371
+ └─────────────┘ └─────────────┘ └─────────────┘
372
+ │ │ │
373
+ v v v
374
+ CSV/Pandas/API Extend Strategy cerebro.run()
375
+ Implement next()
376
+ ```
377
+
378
+ ### Step 2: Write Your First Strategy
379
+
380
+ ```python
381
+ import backtrader as bt
382
+
383
+
384
+ class SmaCrossStrategy(bt.Strategy):
385
+ """Moving Average Crossover Strategy:
386
+
387
+ - Buy when fast SMA crosses above slow SMA
388
+ - Sell when fast SMA crosses below slow SMA
389
+ """
390
+ params = (
391
+ ('fast_period', 10),
392
+ ('slow_period', 30),
393
+ )
394
+
395
+ def __init__(self):
396
+ self.fast_sma = bt.indicators.SMA(self.data.close, period=self.params.fast_period)
397
+ self.slow_sma = bt.indicators.SMA(self.data.close, period=self.params.slow_period)
398
+ self.crossover = bt.indicators.CrossOver(self.fast_sma, self.slow_sma)
399
+
400
+ def next(self):
401
+ if not self.position:
402
+ if self.crossover > 0:
403
+ self.buy()
404
+ elif self.crossover < 0:
405
+ self.close()
406
+ ```
407
+
408
+ ### Step 3: Prepare Data
409
+
410
+ ```python
411
+ # Option 1: Load from CSV file
412
+ data = bt.feeds.GenericCSVData(
413
+ dataname='your_data.csv',
414
+ datetime=0, open=1, high=2, low=3, close=4, volume=5,
415
+ openinterest=-1, dtformat='%Y-%m-%d',
416
+ )
417
+
418
+ # Option 2: Load from Pandas DataFrame
419
+ import pandas as pd
420
+ df = pd.read_csv('your_data.csv', parse_dates=['date'], index_col='date')
421
+ data = bt.feeds.PandasData(dataname=df)
422
+
423
+ # Option 3: Download from Yahoo Finance
424
+ from datetime import datetime
425
+ data = bt.feeds.YahooFinanceData(
426
+ dataname='AAPL',
427
+ fromdate=datetime(2020, 1, 1),
428
+ todate=datetime(2023, 12, 31),
429
+ )
430
+
431
+ # Option 4: Load exchange-native crypto history from CryptoHFTData
432
+ # Install first with: pip install -e '.[cryptohftdata]'
433
+ data = bt.feeds.CryptoHFTData(
434
+ dataname='BTCUSDT',
435
+ exchange='binance_futures',
436
+ fromdate=datetime(2026, 7, 1),
437
+ todate=datetime(2026, 7, 2),
438
+ timeframe=bt.TimeFrame.Minutes,
439
+ )
440
+ ```
441
+
442
+ ### Step 4: Run Backtest
443
+
444
+ ```python
445
+ cerebro = bt.Cerebro()
446
+ cerebro.adddata(data)
447
+ cerebro.addstrategy(SmaCrossStrategy)
448
+ cerebro.broker.setcash(100000)
449
+ cerebro.broker.setcommission(commission=0.0003)
450
+
451
+ cerebro.addanalyzer(bt.analyzers.SharpeRatio, _name='sharpe')
452
+ cerebro.addanalyzer(bt.analyzers.DrawDown, _name='drawdown')
453
+
454
+ print(f'Starting: {cerebro.broker.getvalue():,.2f}')
455
+ results = cerebro.run()
456
+ print(f'Final: {cerebro.broker.getvalue():,.2f}')
457
+
458
+ strat = results[0]
459
+ print(f"Sharpe: {strat.analyzers.sharpe.get_analysis().get('sharperatio', 'N/A')}")
460
+ print(f"Max DD: {strat.analyzers.drawdown.get_analysis()['max']['drawdown']:.2f}%")
461
+ ```
462
+
463
+ ### Step 5: Visualize Results
464
+
465
+ ```python
466
+ # Plotly interactive charts (recommended)
467
+ cerebro.plot(backend='plotly', style='candle')
468
+
469
+ # Save to HTML
470
+ from backtrader.plot import PlotlyPlot
471
+ plotter = PlotlyPlot(style='candle')
472
+ figs = plotter.plot(results[0])
473
+ figs[0].write_html('backtest_chart.html')
474
+ ```
475
+
476
+ ---
477
+
478
+ ## 📚 Core Concepts
479
+
480
+ ### 1. Cerebro - The Engine
481
+
482
+ ```python
483
+ cerebro = bt.Cerebro()
484
+ cerebro.adddata(data)
485
+ cerebro.addstrategy(Strategy)
486
+ cerebro.addanalyzer(Analyzer)
487
+ cerebro.broker.setcash(100000)
488
+ results = cerebro.run()
489
+ cerebro.plot()
490
+ ```
491
+
492
+ ### 2. Strategy
493
+
494
+ ```python
495
+ class MyStrategy(bt.Strategy):
496
+ params = (('period', 20),)
497
+
498
+ def __init__(self):
499
+ self.sma = bt.indicators.SMA(period=self.params.period)
500
+
501
+ def next(self):
502
+ if self.data.close[0] > self.sma[0]:
503
+ self.buy()
504
+
505
+ def notify_order(self, order):
506
+ if order.status == order.Completed:
507
+ print(f'Order executed at {order.executed.price}')
508
+ ```
509
+
510
+ ### 3. Lines - Data Structure
511
+
512
+ ```python
513
+ self.data.close[0] # Current bar
514
+ self.data.close[-1] # Previous bar
515
+ self.data.open[0] # Current open
516
+ self.data.high[0] # Current high
517
+ self.data.volume[0] # Current volume
518
+ ```
519
+
520
+ ### 4. Order Types
521
+
522
+ ```python
523
+ self.buy() # Market buy
524
+ self.sell(price=100, exectype=bt.Order.Limit) # Limit sell
525
+ self.buy_bracket(price=100, stopprice=95, limitprice=110) # Bracket order
526
+ self.order_target_percent(target=0.5) # Target 50% position
527
+ ```
528
+
529
+ ---
530
+
531
+ ## 📦 Built-in Components
532
+
533
+ ### Technical Indicators (50+)
534
+
535
+ | Category | Indicators |
536
+ | --- | --- |
537
+ | **Moving Averages** | SMA, EMA, WMA, DEMA, TEMA, KAMA, HMA, ZLEMA |
538
+ | **Momentum** | RSI, ROC, Momentum, Williams %R, Ultimate Oscillator |
539
+ | **Volatility** | ATR, Bollinger Bands, Standard Deviation |
540
+ | **Trend** | ADX, Aroon, Parabolic SAR, Ichimoku, DPO |
541
+ | **Oscillators** | MACD, Stochastic, CCI, TSI, TRIX |
542
+
543
+ ### Analyzers (17+)
544
+
545
+ | Analyzer | Purpose |
546
+ | --- | --- |
547
+ | `SharpeRatio` | Risk-adjusted returns |
548
+ | `DrawDown` | Maximum drawdown |
549
+ | `TradeAnalyzer` | Trade statistics |
550
+ | `Returns` | Return analysis |
551
+ | `SQN` | System Quality Number |
552
+
553
+ ### Data Sources (20+)
554
+
555
+ | Data Source | Description |
556
+ | --- | --- |
557
+ | `GenericCSVData` | Generic CSV files |
558
+ | `PandasData` | Pandas DataFrame |
559
+ | `YahooFinanceData` | Yahoo Finance |
560
+ | `IBData` | Interactive Brokers |
561
+ | `CCXTFeed` | Cryptocurrency |
562
+
563
+ ---
564
+
565
+ ## 🔬 Advanced Topics
566
+
567
+ ### Parameter Optimization
568
+
569
+ ```python
570
+ cerebro.optstrategy(
571
+ SmaCrossStrategy,
572
+ fast_period=range(5, 20, 5),
573
+ slow_period=range(20, 60, 10),
574
+ )
575
+ results = cerebro.run(maxcpus=4)
576
+ ```
577
+
578
+ ### Multiple Data Sources
579
+
580
+ ```python
581
+ cerebro.adddata(data1)
582
+ cerebro.adddata(data2)
583
+
584
+ # In strategy
585
+ price1 = self.datas[0].close[0]
586
+ price2 = self.datas[1].close[0]
587
+ ```
588
+
589
+ ### Custom Indicators
590
+
591
+ ```python
592
+ class MyIndicator(bt.Indicator):
593
+ lines = ('myline',)
594
+ params = (('period', 20),)
595
+
596
+ def __init__(self):
597
+ self.lines.myline = bt.indicators.SMA(self.data, period=self.params.period)
598
+ ```
599
+
600
+ ### Professional Reports
601
+
602
+ ```python
603
+ cerebro.add_report_analyzers(riskfree_rate=0.02)
604
+ cerebro.run()
605
+ cerebro.generate_report('report.html', user='Trader', memo='Strategy Report')
606
+ ```
607
+
608
+ ### Logging
609
+
610
+ Backtrader uses a single logging entry point and is **silent by default** — it
611
+ emits nothing until you opt in, and it never touches the root logger or a host
612
+ application's logging setup.
613
+
614
+ ```python
615
+ import backtrader as bt
616
+
617
+ # Opt in: console + optional rotating file. Idempotent.
618
+ bt.configure_logging(level="INFO", log_file="run.log")
619
+
620
+ logger = bt.get_logger(__name__) # -> "backtrader.<module>"
621
+ logger.info("strategy started")
622
+
623
+ bt.set_level("DEBUG") # raise verbosity at runtime
624
+ bt.reset_logging() # back to the silent default (tests)
625
+ ```
626
+
627
+ | Level | When |
628
+ | --- | --- |
629
+ | `CRITICAL` | engine cannot continue |
630
+ | `ERROR` | recoverable failure (order rejected, data load failed) |
631
+ | `WARNING` | degraded / auto-corrected behavior |
632
+ | `INFO` | milestones (start/stop, fills) |
633
+ | `DEBUG` | per-bar diagnostics |
634
+
635
+ Framework code routes through `backtrader.utils.log_message.get_logger` rather
636
+ than the stdlib `logging` directly. See `docs/LOGGING_GUIDELINES.md` for the
637
+ full conventions (hot-path guard, exception-logging rules, print-vs-logging).
638
+
639
+ ---
640
+
641
+ ## 🏗 Project Architecture
642
+
643
+ ```text
644
+ backtrader/
645
+ ├── backtrader/ # Core codebase
646
+ │ ├── cerebro.py # Main engine
647
+ │ ├── strategy.py # Strategy base
648
+ │ ├── indicator.py # Indicator base
649
+ │ ├── analyzer.py # Analyzer base
650
+ │ ├── feed.py # Data feed base
651
+ │ ├── broker.py # Broker base
652
+ │ ├── indicators/ # 52 technical indicators
653
+ │ ├── analyzers/ # 17 analyzers
654
+ │ ├── feeds/ # 21 data sources
655
+ │ ├── plot/ # Visualization
656
+ │ └── reports/ # Report generation
657
+ ├── examples/ # Example code
658
+ ├── tests/ # Test cases (3,200+ tests)
659
+ ├── scripts/ # Install, test, benchmark, and maintenance helpers
660
+ └── docs/ # Documentation
661
+ ```
662
+
663
+ ---
664
+
665
+ ## 🧪 Testing
666
+
667
+ The repository ships with **3,200+ tests** covering unit, functional,
668
+ integration, and performance suites. The functional strategy directory alone
669
+ contains **1,271 inlined regression tests** spanning 22 strategy categories
670
+ (trend following, mean reversion, asset allocation, machine learning, options,
671
+ pairs trading, etc.).
672
+
673
+ ### Test Tiers (Fast / Slow / Full)
674
+
675
+ The strategy regression suite is large (~10 min for the full run), so tests are
676
+ split into tiers by measured per-file duration. The fastest ~35% of strategy
677
+ tests stay in the fast loop; the slowest ~65% are auto-tagged `slow` (no test
678
+ files are edited — the split is applied dynamically from a committed durations
679
+ file in `conftest.py`).
680
+
681
+ ```bash
682
+ # Fast dev loop (~3.5 min): all non-strategy tests + the fastest ~35% of
683
+ # strategy tests. Best for "did my change break anything" iteration.
684
+ make test-fast # == pytest tests -m "not slow" -n 8 -q
685
+
686
+ # Slow tier (~7 min): only the slowest ~65% of strategy tests that test-fast skips
687
+ make test-slow # == pytest tests -m slow -n 8 -q
688
+
689
+ # Strategy regression only (all 1,271 strategy tests, ~4 min on `dev`)
690
+ make test-strategies # == pytest tests/functional/strategies -n 8 -q
691
+
692
+ # Full suite — everything in parallel (~10 min)
693
+ make test-all # == pytest tests -n 8 -q
694
+ ```
695
+
696
+ Tune how many strategy tests stay in the fast loop with `BT_SLOW_PERCENTILE`
697
+ (default `35`, i.e. keep the fastest 35%):
698
+
699
+ ```bash
700
+ # Stricter sub-3-minute loop — keep only the fastest ~25% of strategy tests
701
+ BT_SLOW_PERCENTILE=25 make test-fast
702
+
703
+ # Broader coverage — keep the fastest ~50%
704
+ BT_SLOW_PERCENTILE=50 make test-fast
705
+ ```
706
+
707
+ Refresh the duration data after adding/removing strategy tests:
708
+
709
+ ```bash
710
+ python scripts/refresh_strategy_durations.py
711
+ ```
712
+
713
+ ### Run All Tests Directly
714
+
715
+ ```bash
716
+ pytest tests -n 8
717
+
718
+ # Wrapper scripts live under scripts/
719
+ bash scripts/run_tests.sh -n 8
720
+ scripts\run_tests.bat -n 8
721
+ ```
722
+
723
+ ### Helper Scripts
724
+
725
+ Root-level install and test wrappers have been consolidated under `scripts/`.
726
+ Use these paths from the repository root:
727
+
728
+ ```bash
729
+ bash scripts/install_unix.sh
730
+ scripts\install_win.bat
731
+ bash scripts/run_tests.sh
732
+ scripts\run_tests.bat
733
+ ```
734
+
735
+ `mypy-report.txt` is a CI-generated temporary file. It is intentionally not
736
+ tracked; the GitHub Actions mypy gate recreates it during each lint job.
737
+
738
+ ### Run a Specific Category
739
+
740
+ ```bash
741
+ # Run only the strategies suite (1,271 tests, ~4 minutes on `dev`, ~7 on `master`)
742
+ pytest tests/functional/strategies -n 8
743
+
744
+ # Run a single strategy file
745
+ pytest tests/functional/strategies/others/test_0019_pattern_detection.py
746
+
747
+ # Run only the slow / fast tier explicitly
748
+ pytest tests -m slow -n 8
749
+ pytest tests -m "not slow" -n 8
750
+ ```
751
+
752
+ ### Choosing Which `backtrader` to Test Against
753
+
754
+ When you run pytest from the repository root, `import backtrader` resolves to
755
+ the local repo copy by default (the `backtrader/` directory next to
756
+ `conftest.py`). This is what you want during development.
757
+
758
+ If you also have an older or release version installed via
759
+ `pip install backtrader`, you can switch the test suite to that copy on demand:
760
+
761
+ ```bash
762
+ # Default — uses the local repo copy (development)
763
+ pytest tests/functional/strategies -n 8
764
+
765
+ # Switch to the installed (site-packages) copy via env var
766
+ BACKTRADER_USE_INSTALLED=1 pytest tests/functional/strategies -n 8
767
+
768
+ # Or via CLI flag
769
+ pytest tests/functional/strategies -n 8 --use-installed-backtrader
770
+ ```
771
+
772
+ The active `backtrader.__file__` is printed in the pytest session header so
773
+ you can confirm which copy each run picked up. The switch works under
774
+ `pytest-xdist` parallel mode as well.
775
+
776
+ ### Test Data
777
+
778
+ Test fixtures live under `tests/datas/`. The MT5-formatted daily CSVs live in
779
+ `tests/datas/mt5_1d_data/` and cover the symbols referenced by the inlined
780
+ regression suite (XAUUSD, XAGUSD, IVV, IEF, GLD, IWM, etc.).
781
+
782
+ ---
783
+
784
+ ## Repository Maintenance Notes
785
+
786
+ - The canonical changelog is [`CHANGELOG.md`](CHANGELOG.md). Historical
787
+ `ChangeLog.md` and version-specific root changelog files were consolidated.
788
+ - Generated reports such as `mypy-report.txt` are ignored and should not be
789
+ committed.
790
+ - Legacy local workflow metadata under `.windsurf/workflows` and obsolete
791
+ `.kiro/steering` files are not part of the tracked project guidance.
792
+ - Helper entrypoints are kept in `scripts/`; avoid reintroducing duplicate
793
+ root-level install or test scripts.
794
+
795
+ ---
796
+
797
+ ## 📖 API Documentation
798
+
799
+ ### Online Documentation
800
+
801
+ - **ReadTheDocs (EN)**: <https://backtrader.readthedocs.io/en/latest/>
802
+ - **ReadTheDocs (ZH)**: <https://backtrader-zh.readthedocs.io/zh-cn/latest/>
803
+ - **GitHub Pages**: <https://cloudquant.github.io/backtrader/>
804
+
805
+ ### Build Local Documentation
806
+
807
+ ```bash
808
+ cd docs
809
+ pip install -r requirements.txt
810
+ make html
811
+ make serve
812
+ ```
813
+
814
+ ### Quick API Reference
815
+
816
+ ```python
817
+ import backtrader as bt
818
+
819
+ # Cerebro
820
+ cerebro = bt.Cerebro()
821
+ cerebro.adddata(data)
822
+ cerebro.addstrategy(Strategy)
823
+ cerebro.broker.setcash(100000)
824
+ results = cerebro.run()
825
+ cerebro.plot()
826
+
827
+ # Strategy methods
828
+ self.buy(size=100)
829
+ self.sell(size=100)
830
+ self.close()
831
+ self.order_target_percent(target=0.5)
832
+
833
+ # Common indicators
834
+ bt.indicators.SMA(data, period=20)
835
+ bt.indicators.RSI(data, period=14)
836
+ bt.indicators.MACD(data)
837
+ bt.indicators.BollingerBands(data)
838
+ ```
839
+
840
+ ---
841
+
842
+ ## ❓ FAQ
843
+
844
+ ### Q1: How to set slippage?
845
+
846
+ ```python
847
+ cerebro.broker.set_slippage_fixed(0.01) # Fixed slippage
848
+ cerebro.broker.set_slippage_perc(0.001) # Percentage slippage
849
+ ```
850
+
851
+ ### Q2: How to limit trade size?
852
+
853
+ ```python
854
+ class FixedSizer(bt.Sizer):
855
+ params = (('stake', 100),)
856
+
857
+ def _getsizing(self, comminfo, cash, data, isbuy):
858
+ return self.params.stake
859
+
860
+
861
+ cerebro.addsizer(FixedSizer, stake=100)
862
+ ```
863
+
864
+ ### Q3: How to get all transactions?
865
+
866
+ ```python
867
+ cerebro.addanalyzer(bt.analyzers.Transactions, _name='txn')
868
+ results = cerebro.run()
869
+ transactions = results[0].analyzers.txn.get_analysis()
870
+ ```
871
+
872
+ ### Q4: Backtest too slow?
873
+
874
+ ```python
875
+ cerebro.run(runonce=True) # Use vectorized mode (default)
876
+ cerebro.run(maxcpus=4) # Use multiprocessing for optimization
877
+ ```
878
+
879
+ ---
880
+
881
+ ## 🤝 Contributing
882
+
883
+ We welcome contributions to improve code quality, fix bugs, and enhance performance.
884
+
885
+ ### 🐛 Reporting Indicator Discrepancies
886
+
887
+ If you find that the `dev` branch produces different results than `master`
888
+ for the same strategy, this likely indicates an indicator calculation bug.
889
+ Please help us fix it.
890
+
891
+ ### 📝 Pull Request Guidelines
892
+
893
+ #### 1. Create a Test Case
894
+
895
+ Add a new test case that:
896
+
897
+ - ✅ Passes on **both** `master` and `dev` branches
898
+ - ✅ Demonstrates the bug or validates the fix
899
+ - ✅ Includes clear assertions and expected values
900
+
901
+ ```python
902
+ # Example: tests/functional/strategies/<category>/test_NNNN_your_indicator.py
903
+ import backtrader as bt
904
+
905
+
906
+ class TestYourIndicator(bt.Strategy):
907
+ def __init__(self):
908
+ self.indicator = bt.indicators.YourIndicator(self.data)
909
+
910
+ def next(self):
911
+ # Add assertions to validate correctness
912
+ pass
913
+
914
+
915
+ def test_your_indicator():
916
+ cerebro = bt.Cerebro()
917
+ # ... setup and run
918
+ assert result == expected_value
919
+ ```
920
+
921
+ #### 2. Run Code Quality Checks
922
+
923
+ ```bash
924
+ # Option 1: Run the full optimization script (recommended)
925
+ bash scripts/optimize_code.sh
926
+
927
+ # Option 2: Run tests manually
928
+ pytest tests -n 4
929
+ ```
930
+
931
+ Both must pass without errors.
932
+
933
+ #### 3. Verify All Tests Pass
934
+
935
+ ```bash
936
+ pytest tests -n 4 -v
937
+ ```
938
+
939
+ Expected output: all 3,200+ tests pass.
940
+
941
+ #### 4. (Optional) Test Against the Installed Package
942
+
943
+ If you want to validate that the installed wheel still works (for example,
944
+ before publishing a release), see [Testing → Choosing Which backtrader to
945
+ Test Against](#choosing-which-backtrader-to-test-against).
946
+
947
+ #### 5. Submit Your PR
948
+
949
+ 1. Fork the repository
950
+ 2. Create a feature branch: `git checkout -b fix/indicator-name`
951
+ 3. Commit your changes: `git commit -m "fix: correct calculation in YourIndicator"`
952
+ 4. Push to your fork: `git push origin fix/indicator-name`
953
+ 5. Open a Pull Request with:
954
+ - Clear description of the issue
955
+ - Reference to the test case
956
+ - Explanation of the fix
957
+
958
+ ### 🎯 Contribution Areas
959
+
960
+ We especially welcome contributions in:
961
+
962
+ - 🐛 **Bug Fixes**: Indicator calculation errors, edge cases
963
+ - ✅ **Test Coverage**: Additional test cases for existing indicators
964
+ - 📊 **Performance**: Further optimization opportunities
965
+ - 📚 **Documentation**: Improved examples and tutorials
966
+ - 🔧 **Features**: New indicators, analyzers, or data feeds
967
+
968
+ ### 💡 Best Practices
969
+
970
+ - Write clear, self-documenting code
971
+ - Add docstrings to all public methods
972
+ - Follow existing code style (enforced by `ruff` and `black`)
973
+ - Keep changes focused and atomic
974
+ - Update documentation when adding features
975
+
976
+ ---
977
+
978
+ ## ⚠️ Important Disclaimer
979
+
980
+ ### Risk Warning
981
+
982
+ **THIS SOFTWARE IS PROVIDED FOR EDUCATIONAL AND RESEARCH PURPOSES ONLY.**
983
+
984
+ - ⚠️ **Trading Risk**: Algorithmic trading involves substantial risk of loss. Past performance does not guarantee future results.
985
+ - 🐛 **Software Status**: This project is under active development and may contain bugs or calculation errors.
986
+ - 💰 **Financial Liability**: **You are solely responsible for any financial losses** incurred from using this software.
987
+ - 🔍 **Verification Required**: Always verify backtest results against known benchmarks before live trading.
988
+ - 📊 **No Warranty**: This software is provided "AS IS" without warranty of any kind, express or implied.
989
+
990
+ **By using this software, you acknowledge and accept all risks associated with algorithmic trading.**
991
+
992
+ ---
993
+
994
+ ## 📄 License
995
+
996
+ This project is licensed under [GPLv3](LICENSE).
997
+
998
+ ---
999
+
1000
+ ## 📞 Contact
1001
+
1002
+ - **GitHub**: <https://github.com/cloudQuant/backtrader>
1003
+ - **Gitee**: <https://gitee.com/yunjinqi/backtrader>
1004
+ - **Author Blog**: <https://yunjinqi.blog.csdn.net/>
1005
+ - **ReadTheDocs (EN)**: <https://backtrader.readthedocs.io/en/latest/>
1006
+ - **ReadTheDocs (ZH)**: <https://backtrader-zh.readthedocs.io/zh-cn/latest/>
1007
+ - **GitHub Pages**: <https://cloudquant.github.io/backtrader/>
1008
+
1009
+ ---
1010
+
1011
+ <div align="center">
1012
+
1013
+ **If this project helps you, please give us a ⭐ Star!**
1014
+
1015
+ </div>
1016
+
1017
+ ---
1018
+
1019
+ # 📖 中文文档
1020
+
1021
+ [**English**](#-backtrader) | **中文**
1022
+
1023
+ ---
1024
+
1025
+ ## ⚡ 性能概览
1026
+
1027
+ 当前活跃的 `dev` 分支承接了原 `development` 分支上的优化工作。在**完整的 1,271 个策略
1028
+ 回归套件**(`tests/functional/strategies`,`-n 8`)上,`dev` 分支的总执行时间相比
1029
+ `master` 分支**几乎缩短一半**。
1030
+
1031
+ ### 📊 基准测试结果(完整策略套件)
1032
+
1033
+ | 指标 | Master 分支 | Dev 分支 | 提升幅度 |
1034
+ | --- | --- | --- | --- |
1035
+ | **总执行时间** | 438.96 秒(7分18秒) | 236.36 秒(3分56秒) | **-46.2%** |
1036
+ | **加速比** | 1.00x | **1.86x** | ✓ |
1037
+ | **测试策略数** | 1,271 | 1,271 | ✓ |
1038
+ | **测试通过率** | 100%(1271 passed) | 100%(1271 passed) | ✓ |
1039
+
1040
+ > *基准测试:在相同硬件上运行 `pytest tests/functional/strategies -n 8`(macOS,
1041
+ > Python 3.11,8 个并行 xdist 进程)。Master 通过 `--use-installed-backtrader`
1042
+ > 指向 master 构建版本测得。*
1043
+
1044
+ 更早期在 119 个策略小样本上的内部基准也得到了相近的约 45% 降幅(553.12 秒 → 305.36 秒)。
1045
+
1046
+ ### 🔧 核心优化项
1047
+
1048
+ 1. **移除元编程开销**
1049
+ - 消除动态元类属性拦截机制
1050
+ - 采用显式描述符参数系统
1051
+ - 结果:属性访问开销降低约 40%
1052
+ 2. **经纪商性能增强**
1053
+ - 移除 `BackBroker` 和 `CommInfoBase` 的全局 `__getattribute__` 重载
1054
+ - 在热路径(`BackBroker.next()`、`_get_value()`)实现本地参数缓存
1055
+ - 缓存高频访问参数(`mult`、`cash`、`stocklike`)
1056
+ - 结果:经纪商操作速度提升 42.5%
1057
+ 3. **指标计算优化**
1058
+ - 优化布林带 `once()` 方法,使用更快的 NaN 检查
1059
+ - 减少冗余数组边界检查
1060
+ - 缓存数学函数和常量
1061
+ - 结果:指标计算速度提升 15-20%
1062
+ 4. **减少内置函数调用**
1063
+ - 最小化热路径中的 `isinstance()`、`hasattr()`、`len()` 调用
1064
+ - 在适当场景使用类型恒等检查
1065
+ - 结果:Python 层面开销降低约 10%
1066
+
1067
+ ### 📈 不同策略类型的性能提升
1068
+
1069
+ | 策略类别 | 平均加速 | 示例 |
1070
+ | --- | --- | --- |
1071
+ | 简单均线交叉 | 40-45% | `test_03_two_ma`: 2.6 秒 → 1.5 秒 |
1072
+ | 多指标策略 | 45-50% | `test_09_dual_thrust`: 59.2 秒 → 26.9 秒 |
1073
+ | 多数据源 | 42-48% | `test_02_multi_extend_data`: 23.5 秒 → 12.6 秒 |
1074
+ | 复杂策略 | 38-42% | `test_08_kelter_strategy`: 36.9 秒 → 11.3 秒 |
1075
+
1076
+ ---
1077
+
1078
+ ## 🎯 项目简介
1079
+
1080
+ Backtrader 是一个功能强大、灵活易用的 Python 量化交易回测框架。本项目基于
1081
+ [backtrader](https://www.backtrader.com/) 进行了大量优化和功能扩展,支持
1082
+ **低频、中频、高频** 全频段交易策略的研发、回测与实盘交易。
1083
+
1084
+ ### 为什么选择 Backtrader?
1085
+
1086
+ | 对比项 | Backtrader | 其他框架 |
1087
+ | --- | --- | --- |
1088
+ | 学习曲线 | ⭐⭐ 平缓 | ⭐⭐⭐⭐ 陡峭 |
1089
+ | 策略开发效率 | ⭐⭐⭐⭐⭐ 极高 | ⭐⭐⭐ 一般 |
1090
+ | 内置指标数量 | 50+ | 10-30 |
1091
+ | 数据源支持 | 20+ | 5-10 |
1092
+
1093
+ ### 项目分支
1094
+
1095
+ - **`master`**:原始 Backtrader 基线;仅接收可在原始基线复现的 bug、兼容性与安全热修复
1096
+ - **`dev`**:日常开发入口,承载常规功能、修复、测试、文档与重构
1097
+ - **`development`**:改进与优化版本的发布分支;受控的 `dev` 提升和 CI/CD 在此执行
1098
+
1099
+ ---
1100
+
1101
+ ## 🌐 项目生态
1102
+
1103
+ CloudQuant Backtrader 生态由核心引擎与五个配套项目组成——AI 辅助策略开发
1104
+ (Skills / MCP / Agent)、Web 化研究交易平台与量化分析库:
1105
+
1106
+ | 项目 | 简介 |
1107
+ | --- | --- |
1108
+ | [`cloudQuant/backtrader`](https://github.com/cloudQuant/backtrader) | **核心引擎(本仓库)** — 高性能 Python 回测与实盘交易框架,覆盖低频、中频、高频全频段。 |
1109
+ | [`cloudQuant/backtrader-skills`](https://github.com/cloudQuant/backtrader-skills) | 面向 AI Agent 的离线编写/审查/测试 Skills — 把已登记的本地数据集与 typed `StrategySpec v1` 规格转为 pytest 策略或三文件策略包,不导入即可静态审查,并在隔离子进程中运行已批准候选。 |
1110
+ | [`cloudQuant/backtrader-mcp`](https://github.com/cloudQuant/backtrader-mcp) | 本地优先的 MCP Server — 用 typed tools、resources、prompts 构建和运行可复现策略:不可变数据集、私有草稿、有界子进程运行及持久化状态与报告。 |
1111
+ | [`cloudQuant/backtrader-agent`](https://github.com/cloudQuant/backtrader-agent) | 离线优先的策略编写 Agent 运行时 — 规范策略规格、静态审查、哈希绑定审批、固定子进程执行与可恢复会话溯源。 |
1112
+ | [`cloudQuant/backtrader_web`](https://github.com/cloudQuant/backtrader_web) | **"AI for Investor"** — Vue 3 + FastAPI 的全周期策略管理 Web 平台:研究、策略生成、回测分析、模拟盘、实盘执行与行情数据管理。 |
1113
+ | [`cloudQuant/fincore`](https://github.com/cloudQuant/fincore) | 量化绩效与风险分析库 — 150+ 金融指标、组合优化、蒙特卡洛模拟与绩效归因。 |
1114
+
1115
+ 三个 AI 产品(Skills / MCP / Agent)只是宿主接入形态不同,任意一个都不依赖另外两个
1116
+ 才能完成闭环;其 README 均说明面向 Claude Code、Codex、OpenCode 和 OpenClaw 的接入
1117
+ 路径。请在各自仓库中安装、测试、发布和贡献;本 Backtrader 核心仓库既不内嵌也不
1118
+ 初始化这些产品。
1119
+
1120
+ ---
1121
+
1122
+ ## ✨ 核心特性
1123
+
1124
+ - 🚀 **高性能多频段回测引擎**:支持向量化、事件驱动和 Tick 级别三种模式
1125
+ - 🔄 **Tick 级别回测与混合交易**:支持 Tick 数据回测、Tick + Bar 混合模式,打通低频、中频、高频全频段交易
1126
+ - 📊 **丰富的可视化**:Plotly 交互图表、Bokeh 实时图表
1127
+ - 📈 **专业回测报告**:一键生成 HTML/PDF/JSON 格式报告
1128
+ - 🔧 **50+ 内置技术指标**:均线、动量、波动率、趋势等
1129
+ - 📝 **TradeLogger 实时日志**:回测过程中实时记录订单、交易、持仓、行情数据,支持 MySQL 持久化
1130
+ - 📦 **模块化架构**:策略、指标、分析器可独立扩展
1131
+ - 🌍 **20+ 数据源支持**:CSV、Pandas、Yahoo、IB、CCXT、CTP 期货等
1132
+ - 🔗 **回测与实盘无缝衔接**:同一套策略代码可直接用于回测和实盘交易
1133
+
1134
+ ---
1135
+
1136
+ ## 📥 快速安装
1137
+
1138
+ > **注意**:纯 Python 版 `cloudQuant/backtrader` 从源码安装。pybind11 wheel 可使用
1139
+ > `pip install back-trader-cpp` 直接安装。
1140
+
1141
+ ```bash
1142
+ # 从 GitHub 克隆
1143
+ git clone https://github.com/cloudQuant/backtrader.git
1144
+ cd backtrader
1145
+ pip install -r requirements.txt
1146
+ pip install -U .
1147
+
1148
+ # 或从 Gitee 镜像克隆
1149
+ git clone https://gitee.com/yunjinqi/backtrader.git
1150
+ cd backtrader
1151
+ pip install -r requirements.txt
1152
+ pip install -U .
1153
+
1154
+ # 验证安装
1155
+ python -c "import backtrader as bt; print(bt.__version__)"
1156
+ ```
1157
+
1158
+ ---
1159
+
1160
+ ## 🎓 5 分钟入门
1161
+
1162
+ ```python
1163
+ import backtrader as bt
1164
+
1165
+
1166
+ # 定义策略
1167
+ class SmaCrossStrategy(bt.Strategy):
1168
+ params = (('fast', 10), ('slow', 30))
1169
+
1170
+ def __init__(self):
1171
+ fast_sma = bt.indicators.SMA(period=self.params.fast)
1172
+ slow_sma = bt.indicators.SMA(period=self.params.slow)
1173
+ self.crossover = bt.indicators.CrossOver(fast_sma, slow_sma)
1174
+
1175
+ def next(self):
1176
+ if not self.position and self.crossover > 0:
1177
+ self.buy()
1178
+ elif self.position and self.crossover < 0:
1179
+ self.close()
1180
+
1181
+
1182
+ # 创建引擎
1183
+ cerebro = bt.Cerebro()
1184
+ cerebro.adddata(data)
1185
+ cerebro.addstrategy(SmaCrossStrategy)
1186
+ cerebro.broker.setcash(100000)
1187
+
1188
+ # 运行回测
1189
+ results = cerebro.run()
1190
+ cerebro.plot(backend='plotly')
1191
+ ```
1192
+
1193
+ ---
1194
+
1195
+ ## 📝 日志
1196
+
1197
+ Backtrader 提供**统一的日志入口**,且**默认完全静默**——不主动调用就没有任何
1198
+ 输出,也不会修改 root logger 或干扰宿主程序的日志配置。
1199
+
1200
+ ```python
1201
+ import backtrader as bt
1202
+
1203
+ # 开启日志:控制台 + 可选滚动文件,幂等
1204
+ bt.configure_logging(level="INFO", log_file="run.log")
1205
+
1206
+ logger = bt.get_logger(__name__) # -> "backtrader.<模块名>"
1207
+ logger.info("strategy started")
1208
+
1209
+ bt.set_level("DEBUG") # 运行时调高日志级别
1210
+ bt.reset_logging() # 还原到默认静默状态(测试用)
1211
+ ```
1212
+
1213
+ | 级别 | 使用场景 |
1214
+ | --- | --- |
1215
+ | `CRITICAL` | 引擎无法继续 |
1216
+ | `ERROR` | 可恢复的失败(订单被拒、数据加载失败) |
1217
+ | `WARNING` | 降级 / 自动修正行为 |
1218
+ | `INFO` | 里程碑事件(启动/结束、成交) |
1219
+ | `DEBUG` | 每根 bar 的诊断信息 |
1220
+
1221
+ 框架内部统一通过 `backtrader.utils.log_message.get_logger` 获取 logger,而非
1222
+ 直接 `import logging`。完整规范(热路径守护、异常日志写法、print 取舍)见
1223
+ `docs/LOGGING_GUIDELINES.md`。
1224
+
1225
+ ---
1226
+
1227
+ ## 🧪 测试
1228
+
1229
+ 仓库自带 **3,200+ 个测试**,覆盖单元、功能、集成和性能四个层级。仅
1230
+ `tests/functional/strategies/` 这一目录就有 **1,271 个内联回归测试**,分布在
1231
+ 22 个策略类别下(趋势跟踪、均值回归、资产配置、机器学习、期权、配对交易等)。
1232
+
1233
+ ### 分级测试(快速 / 慢速 / 全量)
1234
+
1235
+ 策略回归套件很大(全量约 10 分钟),因此按单测文件的实测耗时做了分级:最快的
1236
+ ~35% 策略测试留在快速档,其余最慢的 ~65% 自动标记为 `slow`(**不改任何测试文件**
1237
+ ——拆分由 `conftest.py` 读取已提交的耗时数据动态完成)。
1238
+
1239
+ ```bash
1240
+ # 快速开发回路(约 3.5 分钟):全部非策略测试 + 最快 ~35% 的策略测试。
1241
+ # 最适合「改完代码看有没有引入 bug」的日常迭代。
1242
+ make test-fast # 等价于 pytest tests -m "not slow" -n 8 -q
1243
+
1244
+ # 慢速档(约 7 分钟):test-fast 跳过的那最慢 ~65% 策略测试
1245
+ make test-slow # 等价于 pytest tests -m slow -n 8 -q
1246
+
1247
+ # 只跑策略回归(全部 1,271 个策略测试,`dev` 约 4 分钟)
1248
+ make test-strategies # 等价于 pytest tests/functional/strategies -n 8 -q
1249
+
1250
+ # 全量 —— 所有测试并行(约 10 分钟)
1251
+ make test-all # 等价于 pytest tests -n 8 -q
1252
+ ```
1253
+
1254
+ 用环境变量 `BT_SLOW_PERCENTILE` 调节快速档里保留多少策略测试(默认 `35`,即保留
1255
+ 最快 35%):
1256
+
1257
+ ```bash
1258
+ # 更严格、压进 3 分钟内 —— 只保留最快 ~25% 的策略测试
1259
+ BT_SLOW_PERCENTILE=25 make test-fast
1260
+
1261
+ # 覆盖更全 —— 保留最快 ~50%
1262
+ BT_SLOW_PERCENTILE=50 make test-fast
1263
+ ```
1264
+
1265
+ 增删策略测试后刷新耗时数据:
1266
+
1267
+ ```bash
1268
+ python scripts/refresh_strategy_durations.py
1269
+ ```
1270
+
1271
+ ### 直接运行全部测试
1272
+
1273
+ ```bash
1274
+ pytest tests -n 8
1275
+
1276
+ # 封装脚本统一放在 scripts/ 下
1277
+ bash scripts/run_tests.sh -n 8
1278
+ scripts\run_tests.bat -n 8
1279
+ ```
1280
+
1281
+ ### 辅助脚本
1282
+
1283
+ 根目录安装和测试封装脚本已统一整理到 `scripts/`。从仓库根目录使用:
1284
+
1285
+ ```bash
1286
+ bash scripts/install_unix.sh
1287
+ scripts\install_win.bat
1288
+ bash scripts/run_tests.sh
1289
+ scripts\run_tests.bat
1290
+ ```
1291
+
1292
+ `mypy-report.txt` 是 CI 在 mypy 门禁中临时生成的报告文件,不需要提交到仓库;
1293
+ GitHub Actions 每次 lint job 都会重新生成它。
1294
+
1295
+ ### 只运行某一类
1296
+
1297
+ ```bash
1298
+ # 只跑策略套件(1,271 个测试,`dev` 约 4 分钟,`master` 约 7 分钟)
1299
+ pytest tests/functional/strategies -n 8
1300
+
1301
+ # 跑单个策略文件
1302
+ pytest tests/functional/strategies/others/test_0019_pattern_detection.py
1303
+
1304
+ # 显式只跑慢速 / 快速档
1305
+ pytest tests -m slow -n 8
1306
+ pytest tests -m "not slow" -n 8
1307
+ ```
1308
+
1309
+ ### 选择测试目标:本地代码 vs 已安装包
1310
+
1311
+ 从仓库根目录运行 pytest 时,`import backtrader` 默认解析到本地仓库副本(与
1312
+ `conftest.py` 同级的 `backtrader/` 目录)。开发期间这是你想要的行为。
1313
+
1314
+ 如果你额外用 `pip install backtrader` 装过其他版本(比如稳定版或旧版本),可以
1315
+ 临时把测试切到已安装的那一份:
1316
+
1317
+ ```bash
1318
+ # 默认 —— 使用本地仓库代码(开发常用)
1319
+ pytest tests/functional/strategies -n 8
1320
+
1321
+ # 通过环境变量切到 site-packages 安装的副本
1322
+ BACKTRADER_USE_INSTALLED=1 pytest tests/functional/strategies -n 8
1323
+
1324
+ # 或通过命令行参数
1325
+ pytest tests/functional/strategies -n 8 --use-installed-backtrader
1326
+ ```
1327
+
1328
+ 每次启动 pytest 都会在 session header 中打印当前生效的 `backtrader.__file__`,
1329
+ 方便确认本次跑的到底是哪一份。该开关在 `pytest-xdist` 并行模式下同样生效。
1330
+
1331
+ ### 测试数据
1332
+
1333
+ 测试夹具放在 `tests/datas/` 下。MT5 格式的日线 CSV 在
1334
+ `tests/datas/mt5_1d_data/`,覆盖了内联回归套件引用的所有标的(XAUUSD、
1335
+ XAGUSD、IVV、IEF、GLD、IWM 等)。
1336
+
1337
+ ---
1338
+
1339
+ ## 仓库维护说明
1340
+
1341
+ - 唯一的变更日志文件是 [`CHANGELOG.md`](CHANGELOG.md)。历史上的
1342
+ `ChangeLog.md` 和版本专用根目录 changelog 已合并。
1343
+ - `mypy-report.txt` 等生成报告已加入忽略规则,不应提交。
1344
+ - `.windsurf/workflows` 和过期的 `.kiro/steering` 不再作为跟踪的项目指导文件。
1345
+ - 安装、测试等辅助入口统一放在 `scripts/`,不要重新引入根目录重复脚本。
1346
+
1347
+ ---
1348
+
1349
+ ## 🤝 贡献指南
1350
+
1351
+ 我们欢迎所有有助于提升代码质量、修复 bug 和增强性能的贡献。
1352
+
1353
+ ### 🐛 报告指标差异
1354
+
1355
+ 如果您发现 `dev` 分支与 `master` 分支在相同策略下产生不同结果,这很可能表明
1356
+ 存在指标计算 bug。请帮助我们修复。
1357
+
1358
+ ### 📝 Pull Request 提交规范
1359
+
1360
+ #### 1. 创建测试用例
1361
+
1362
+ 添加一个新的测试用例,要求:
1363
+
1364
+ - ✅ 在 **master** 和 **dev** 分支上都能通过
1365
+ - ✅ 能够演示 bug 或验证修复
1366
+ - ✅ 包含清晰的断言和预期值
1367
+
1368
+ #### 2. 运行代码质量检查
1369
+
1370
+ ```bash
1371
+ # 方式 1:运行完整优化脚本(推荐)
1372
+ bash scripts/optimize_code.sh
1373
+
1374
+ # 方式 2:手动运行测试
1375
+ pytest tests -n 4
1376
+ ```
1377
+
1378
+ 两个命令都必须无错误通过。
1379
+
1380
+ #### 3. 验证所有测试通过
1381
+
1382
+ ```bash
1383
+ pytest tests -n 4 -v
1384
+ ```
1385
+
1386
+ 预期输出:3,200+ 个测试全部通过。
1387
+
1388
+ #### 4. 提交 PR
1389
+
1390
+ 1. Fork 本仓库
1391
+ 2. 创建功能分支:`git checkout -b fix/indicator-name`
1392
+ 3. 提交更改:`git commit -m "fix: 修正 YourIndicator 的计算"`
1393
+ 4. 推送到您的 fork:`git push origin fix/indicator-name`
1394
+ 5. 创建 Pull Request,包含:
1395
+ - 问题的清晰描述
1396
+ - 测试用例的引用
1397
+ - 修复方案的说明
1398
+
1399
+ ### 🎯 贡献方向
1400
+
1401
+ 我们特别欢迎以下方面的贡献:
1402
+
1403
+ - 🐛 **Bug 修复**:指标计算错误、边界情况处理
1404
+ - ✅ **测试覆盖**:为现有指标添加更多测试用例
1405
+ - 📊 **性能优化**:进一步的优化机会
1406
+ - 📚 **文档完善**:改进示例和教程
1407
+ - 🔧 **功能扩展**:新指标、分析器或数据源
1408
+
1409
+ ### 💡 最佳实践
1410
+
1411
+ - 编写清晰、自文档化的代码
1412
+ - 为所有公共方法添加文档字符串
1413
+ - 遵循现有代码风格(由 `ruff` 和 `black` 强制执行)
1414
+ - 保持更改集中和原子化
1415
+ - 添加功能时更新文档
1416
+
1417
+ ---
1418
+
1419
+ ## ❓ 常见问题
1420
+
1421
+ ### Q1:如何设置滑点?
1422
+
1423
+ ```python
1424
+ cerebro.broker.set_slippage_fixed(0.01) # 固定滑点
1425
+ cerebro.broker.set_slippage_perc(0.001) # 百分比滑点
1426
+ ```
1427
+
1428
+ ### Q2:如何限制单笔交易数量?
1429
+
1430
+ ```python
1431
+ class FixedSizer(bt.Sizer):
1432
+ params = (('stake', 100),)
1433
+
1434
+ def _getsizing(self, comminfo, cash, data, isbuy):
1435
+ return self.params.stake
1436
+
1437
+
1438
+ cerebro.addsizer(FixedSizer, stake=100)
1439
+ ```
1440
+
1441
+ ### Q3:如何获取所有交易记录?
1442
+
1443
+ ```python
1444
+ cerebro.addanalyzer(bt.analyzers.Transactions, _name='txn')
1445
+ results = cerebro.run()
1446
+ transactions = results[0].analyzers.txn.get_analysis()
1447
+ ```
1448
+
1449
+ ### Q4:回测速度慢怎么办?
1450
+
1451
+ ```python
1452
+ cerebro.run(runonce=True) # 使用向量化模式(默认)
1453
+ cerebro.run(maxcpus=4) # 参数优化时使用多进程
1454
+ ```
1455
+
1456
+ ---
1457
+
1458
+ ## ⚠️ 重要声明
1459
+
1460
+ ### 风险警示
1461
+
1462
+ **本软件仅供教育和研究目的使用。**
1463
+
1464
+ - ⚠️ **交易风险**:算法交易存在重大亏损风险。历史业绩不代表未来表现。
1465
+ - 🐛 **软件状态**:本项目正在积极开发中,可能包含 bug 或计算错误。
1466
+ - 💰 **财务责任**:**使用本软件产生的任何财务损失由您自行承担**。
1467
+ - 🔍 **验证要求**:实盘交易前,务必对照已知基准验证回测结果。
1468
+ - 📊 **无担保**:本软件按"原样"提供,不提供任何明示或暗示的担保。
1469
+
1470
+ **使用本软件即表示您承认并接受算法交易相关的所有风险。**
1471
+
1472
+ ---
1473
+
1474
+ ## 📞 联系方式
1475
+
1476
+ - **GitHub**: <https://github.com/cloudQuant/backtrader>
1477
+ - **Gitee**: <https://gitee.com/yunjinqi/backtrader>
1478
+ - **作者博客**: <https://yunjinqi.blog.csdn.net/>
1479
+ - **在线文档 (EN)**: <https://backtrader.readthedocs.io/en/latest/>
1480
+ - **在线文档 (ZH)**: <https://backtrader-zh.readthedocs.io/zh-cn/latest/>
1481
+ - **GitHub Pages**: <https://cloudquant.github.io/backtrader/>
1482
+
1483
+ ---
1484
+
1485
+ <div align="center">
1486
+
1487
+ **如果本项目对您有帮助,请点个 ⭐ Star 支持我们!**
1488
+
1489
+ Made with ❤️ by CloudQuant
1490
+
1491
+ </div>