Adding extra day before dtcmp calc, as otherwise the extradays
have no effect (#388)
Fixing the issue with TWS API Bust events (err code 10225) (#396)
Add support for ASK quotes for CASH assets (#395) plus fixes
Remove duplicated note (#386)
Fixing time.clock for python>=3.8 (#394)
Changed file initiation for WriterFile to make it work under
multi-process optimization (#397) plus fixes
Fixed backend loading if a backend is loaded (Google Collab) and
backend to use on MacOSX
Fix: crumb in feeds.YahooFinanceData (#400)
Fix color assignments, ticks line widths and some pep-8 improvements
Fix timeframe/compression detection when plotting
Fix default value for ticks display format on X-axis
Sample with ta-lib SAR test
Generic support of multiple "text/*" content types for Yahoo
@benjomeyer said in Timers:
Given how you pass it ... you could probably try this better
def notify_timer(self, timer, when, timername):
given that you have no additional *args or **kwargs. But a more general approach I would suggest this
def notify_timer(self, timer, when, **kwargs):
timername = kwargs.get('timername', None)
where you can also decide if a default logic for None is needed.
Note: notice the usage of elif
A few days ago I'm started to play with leverage in backtrader in order to use it in Interactive Brokers (IB). In particular to trade stocks.
In my understanding, leverage in IB, it is a little different from other platforms (based on some blogs reading). What I mean by this, in simple words, is that you can consider that you are using leverage if you buy more than the cash you have (I know that some conditions need to be met, like initial margin, maintenance margin among others). When you do that, you cash will be negative, because you have "debt".
In other platforms, and it seems the case of backtrader, when you buy with leverage, you will never have negative cash.
Until now, that behavior of backtrader was not a problem, the returns of the strategy seem to be ok. It was until I processed the results with Pyfolio that I realized that it leads to confusion in the Pyfolio analysis.
Here is a screenshot of the first position a strategy took with leverage of 4x:
In some operations with pyfolio, it considers the sum of each row as the portfolio value. And that it is incorrect here.
Although it could be a desition design, another output from backtrader is also incorrect. The gross leverage is erroneous:
It never reports a value greater than 1.
It could be a bug or a decision design or that pyfolio has changed since the last commit about pyfolio analyzer of backtrader. But I ask this community to provide any help on how to fix it. Any insight is welcome :)