Logging and Plotting


In QuantConnect, the self.Debug() method is the equivalent of the function in Quantopian. Debug output is viewable via the QuantConnect Terminal Console.

Output to the console via self.Debug() is rate-limited. If you need long-term storage of your logs and don't want to overflow the console, consider using self.Log() instead. An example comparing logging between Quantopian and QuantConnect is shown below.


def initialize(context):"Hello, console!")


class MyLoggingAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.debug("Hello, console!")
        self.log("Hello, backtesting logs!")

Logging via self.Log() has daily limits in QuantConnect. On the free tier, users are limited to 10KB of logs per day for your account/organization. To increase this limit, you can upgrade your account to a different tier. Calls to self.Debug() will also count towards the 10KB log limit, but are always outputted to the Terminal Console regardless of your daily log limit.

To view pricing and upgrade your account, visit the Organization Pricing page.

You can view the logs generated via self.Log() for a backtest by first accessing a backtest, and clicking the "Logs" tab near the bottom of the page. To download the logs, you can click the "Download Logs" link to download a text file containing your backtest's logs.


In Quantopian, plotting/charting is done with the record(series1_name=scalar_value, series2_name=scalar_value, ...) function. In QuantConnect, plotting is accessible via the self.plot("chart name", "series name", scalar_value) method.

Plotting multiple series in one function call is possible in Quantopian. However, in QuantConnect, a separate call is needed for each series requiring an update. All series with the same chart name will appear on the same window/pane. New charts can be created by calling self.plot() method with a unique chart name.

An example of plotting in Quantopian vs. QuantConnect is shown below. The QuantConnect code will create two charts, one named "Chart1" with two series of data, and another named "Chart2" with one series of data. Note that you can also use self.plot("series name", value) to place the custom series on the same chart as the equity curve.


import numpy as np
from quantopian.algorithm import record

    def initialize(context):
        context.i = 0

    def handle_data(context, data):
        context.i += 0.25



import numpy as np
class Algorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.i = 0

    def on_data(self, slice: Slice) -> None:
        self.i += 0.25

        self.plot('Chart1', 'Series1', np.sin(self.i))
        self.plot('Chart1', 'Series2', np.cos(self.i))
        self.plot('Chart2', 'Chart2 Series1', np.tan(self.i))

For more information on plotting in QuantConnect, visit the Charting documentation page.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: