Signals + QuantConnect

QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. The QuantConnect Cloud Platform enables more than 50,000 quants on a monthly basis to backtest, research, and trade various asset classes, including Equities, Options, Futures, Crypto, Forex, and CFDs.

Numerai Signals lets you use any dataset to generate your trading signals. By using QuantConnect, you can leverage their rich library of alternative data or your own custom datasets to generate unique trading signals. The QuantConnect team ensures the data is processed correctly and delivered on time. Their API provides simple and helpful methods to select universes of assets, define trading logic, and schedule submissions to Numerai Signals. When you deploy a live algorithm on QuantConnect, their team of engineers monitors the live trading infrastructure so that you can simply automate your Numerai Signals submissions and focus on other research.

Requirements

To run live algorithms on QuantConnect's co-located servers, you must be in an organization with an idle live trading node. The minimum cost to start live trading is $8/month for a seat in a Quant Researcher organization and $24/month for a live trading node.

Connecting to Numerai Signals

To export signals to Numerai from your algorithm on QuantConnect, add a Numerai signal export provider during initialization.

self.SignalExport.AddSignalExportProviders(NumeraiSignalExport(publicId, secretId, modelId, fileName))

The NumeraiSignalExport constructor accepts the following arguments:

ArgumentData TypeDescriptionDefault Value

publicId

string

Your Numerai API key.

secretId

string

Your Numerai API secret.

modelId

string

The Id of the Numerai model.

fileName

string

The name for the signal file. If you use a file name that already exists, the new file overwrites the old one.

"predictions.csv"

Universe Selection

The Numerai Signals stock market universe covers roughly the top 5,000 largest stocks in the world, but the QuantConnect Cloud Platform currently only supports live trading of US Equities. The universe available on QuantConnect that's the closest match to the Numerai Signals universe is the CRSP US Total Market Index, which represents approximately 100% of the investable US Equity market regularly traded on the New York Stock Exchange and Nasdaq. This Index doesn't contain all of the stocks in the Numerai Signals universe, but you don't need to submit signals for all the stocks in the Numerai Signals universe.

To get the constituents of the CRSP US Total Market Index, add an ETF constituents universe for the Vanguard Total Stock Market ETF, VTI.

self.etf_symbol = self.AddEquity("VTI").Symbol 
self.AddUniverse(self.Universe.ETF(self.etf_symbol))

When the universe constituents change, we notify your algorithm through the OnSecuritiesChanged event handler. If you add a securities list to your class, you can define the OnSecuritiesChanged event handler to maintain the list so you can use it later in your algorithm.

def OnSecuritiesChanged(self, changes: SecurityChanges) -> None:
    for security in changes.RemovedSecurities:
        if security in self.securities:
            self.securities.remove(security)
            
    self.securities.extend([security for security in changes.AddedSecurities if security.Symbol != self.etf_symbol])

Portfolio Construction

When you submit signals to Numerai Signals, abide by the following rules:

  • All signals must be between 0 and 1 (exclusive)

  • You must submit at least 10 different signals per submission

  • At least 1 signal value must be unique from the rest of the securities in the universe

To create signals, create PortfolioTarget objects.

targets = [PortfolioTarget(symbol, weight) for symbol, weight in weight_by_symbol.items()]

If you use the Algorithm Framework design, we have many pre-built Portfolio Construction models you can use to create your signals. The Equal Weighting model won’t work since it gives each security the same signal. In most cases, we recommend you use the Insight Weighting model, which weighs the assets according to the strength of the signal you create.

You don’t need to actually place any trades in your algorithm, but it may be helpful to visualize your algorithm activity. You just need to send signals to Numerai. To send the signals to Numerai, call the SetTargetPortfolio method. The method returns a boolean that represents whether the targets were successfully sent to Numerai.

success = self.SignalExport.SetTargetPortfolio(targets)

Scheduling Signals

Every Tuesday, Wednesday, Thursday, Friday, and Saturday of the week, a new round is open for you to submit signals. Saturday rounds open at 18:00 UTC, and the submission window is open until Monday 14:30 UTC. Weekday rounds open at 13:00 UTC, and the submission window is open for 1 hour. For more information about the competition rounds, see Rounds.

To schedule your submissions, you can use a Scheduled Event.

self.Schedule.On(
    self.DateRules.EveryDay(self.etf_symbol),
    self.TimeRules.At(13, 0, TimeZones.Utc), 
    self.submit_signals)

In the preceding example, the submit_signals method will automatically run at 13:00 UTC every trading day.

Deploying Live Algorithms

Follow these steps to deploy a live algorithm on QuantConnect that submits signals to Numerai Signals:

  1. In the Initialize method, add a US Equity universe.

self.etf_symbol = self.AddEquity("VTI").Symbol
self.AddUniverse(self.Universe.ETF(self.etf_symbol))
  1. In the Initialize method, add the Numerai Signal export provider.

self.SignalExport.AddSignalExportProviders(NumeraiSignalExport(publicId, secretId, modelId, fileName))
  1. In the Initialize method, add a Scheduled Event to submit signals for each round.

self.Schedule.On(
    self.DateRules.EveryDay(self.etf_symbol),
    self.TimeRules.At(13, 0, TimeZones.Utc), 
    self.submit_signals)
  1. Add a class member to track the securities in the universe.

securities = []
  1. Define the OnSecuritiesChanged event handler to update the securities list as the universe changes.

def OnSecuritiesChanged(self, changes: SecurityChanges) -> None:
    for security in changes.RemovedSecurities:
        if security in self.securities:
            self.securities.remove(security)
            
    self.securities.extend([security for security in changes.AddedSecurities if security.Symbol != self.etf_symbol])
  1. Define the Scheduled Event to create and send targets.

def submit_signals(self):
    # Select the subset of ETF constituents we can trade
    symbols = [security.Symbol for security in self.securities if security.HasData]
    if len(symbols) == 0:
        return

    # Get historical data
    # close_prices = self.History(symbols, 22, Resolution.Daily).close.unstack(0)
    
    # Create portfolio targets
    # weight_by_symbol = {} # Add your logic here
    targets = [PortfolioTarget(symbol, weight) for symbol, weight in weight_by_symbol.items()]

    # (Optional) Place trades
    self.SetHoldings(targets)

    # Send signals to Numerai
    success = self.SignalExport.SetTargetPortfolio(targets)
    if not success:
        self.Debug(f"Couldn't send targets at {self.Time}")

For more information about requesting historical stock prices and alternative data, see History Requests.

  1. At the top of the web IDE, click the Backtest icon.

QuantConnect doesn’t send targets to Numerai during backtests, but running a backtest is a quick way to test if the algorithm has coding errors before deploying live.

  1. Deploy the algorithm to live trading.

If you don’t want to place real-money trades in your algorithm, deploy with the paper trading brokerage. If you want to trade and submit signals to Numerai in the same algorithm, see the Deploy Live Algorithms documentation for one of QuantConnect’s supported brokerages.

Next Steps

To start using QuantConnect to automate your Numerai Signals submissions, review the Numerai Signals Overview documentation and create a QuantConnect account.

Demonstration Algorithm

For a full example algorithm that submits signals to Numerai Signals, see the NumeraiSignalExportDemonstrationAlgorithm in the LEAN GitHub repository.

Last updated