Realised P&L by year
All plugins

Plugin libraryReports

Plugin

Realised P&L by year

Sums a run's closed trades per calendar year and instrument: gross gains, losses, commission, swap and net, as CSV and Markdown, in EUR when ECB rates are cached.

ExporterNo networkDesktop onlyv1.0.0

About

Not tax advice: a backtest is hypothetical, and this exporter only adds up its trades. Ask a tax adviser how real trading results are to be declared.

A trade counts in the year it was closed, on the clock of the time zone you set, so a trade closed at 23:30 UTC on 31 December counts in the next year in Berlin. Per year and instrument the report lists the number of trades (won and lost), the gross gains (trades that made money before costs), the gross losses, the commission paid, the swap (a credit is positive) and the net result: net = gross gains + gross losses - commission + swap, which is the sum of the trades' own net figures.

The amounts are in the result's currency, which is the instrument's quote currency (USD for EURUSD); the engine converts nothing. With the ECB reference rates plugin (ecb_fx_reference) switched on and its data fetched, the report adds every amount in EUR: each trade at the euro reference rate known on the day it closed, read from the feed ecb_eur plus the currency (ecb_eurusd holds USD per 1 EUR). Without that feed, or when it does not cover every closing day, the report stays in the result's currency and says why in its first lines.

Configuration

FieldTypeDefaultDescription
convertToEurAdd EUR with ECB ratesbooleantrueAdd every amount in EUR with the ECB reference rates, when their feed is on this machine. Off keeps the report in the result's currency.
fileNameFile namestring"realised_pnl"The start of both file names; the instrument and the run's seed are added, the files end in .csv and .md.
timeZoneTime zone for the year boundarystring"Europe/Berlin"The time zone whose midnight separates the years, as an IANA name like Europe/Berlin or UTC.

Use it in a strategy

Not called from a strategy: after a run, choose it in the result's export menu. Exports are part of the plans that include CSV export. For EUR, switch on ecb_fx_reference and run once with "Fetch external data (news and plugin feeds)" ticked, so its feed is on this machine.

What it provides

realised_pnl_<instrument>_<seed>.csvFileOne row per year and instrument. Two lines starting with # come first (the disclaimer and the currency basis); pandas reads it with comment="#". The _eur columns are empty when nothing was converted.
realised_pnl_<instrument>_<seed>.mdFileThe same as a Markdown report: the disclaimer, the currency basis, a table per year and a table per year and instrument.

Limits

  • Not tax advice and not a tax report. It does not know your country's rules, loss offsetting, allowances or the tax categories of CFDs, futures or forex.
  • The trades are those of a hypothetical backtest. A trade the engine closed at the end of the data counts in the year the data ended.
  • EUR only through the ECB reference rates, one a day: a trade uses the last rate published before the day it closed, which on a Monday is Friday's.
OrionQuant