The built-in datasets cover fundamentals, positioning, rates and prices. But many strategies run on something of your own: a signal you compute elsewhere, sentiment scores, an alternative data feed you bought, prices from a venue the catalog doesn't have. On MarketsCoder you can upload it as a CSV and use it in backtests and notebooks like any other dataset.
Two kinds of dataset
- Price bars: open, high, low and close (volume optional), for an instrument you want to trade or chart.
- Custom: any columns, numbers or text, such as a signal, a score or an indicator from another tool.
Preparing the file
A header row, then one row per time:
time,score,mentions
2024-01-02 14:30:00,0.42,1830
2024-01-02 14:31:00,0.47,1912
2024-01-02 14:32:00,0.31,2104- The time column is the one named
time,timestamp,dateor similar, else the first column. - Times may be
YYYY-MM-DD HH:MM:SS(taken as UTC), ISO 8601 with an offset, or Unix seconds or milliseconds. - Price bars need
open,high,lowandclose(common short names likeo,h,l,cwork too). - Up to 500 MB, 5 million rows and 50 columns a file. Commas, semicolons and tabs are all fine.
Uploading
- Open Datasets in the app and choose Upload your own.
- Pick the file, give the dataset a short name such as
my-signals, and say whether it's price bars or custom. - Wait for the check. It finds the time column, sorts the rows, keeps the last of any duplicate times, and stops at the first problem with the line and what to fix.
- Copy the code it shows you.
Using it in a backtest
One line in initialize subscribes to it, and its rows arrive in on_data at their times:
from AlgorithmImports import *
from lean_platform_data import UserData
class SentimentAlgorithm(QCAlgorithm):
def initialize(self):
self.set_start_date(2024, 1, 1)
self.set_end_date(2024, 6, 30)
self.spy = self.add_equity("SPY", Resolution.MINUTE).symbol
self.signals = self.add_data(UserData, "my-signals", Resolution.MINUTE, TimeZones.UTC).symbol
def on_data(self, slice):
if self.signals in slice:
row = slice[self.signals]
if row["score"] > 0.4:
self.set_holdings(self.spy, 1)
elif row["score"] < 0:
self.liquidate(self.spy)Custom columns are read by name, as in row["score"]; price bars have row.open to row.close. The same line works in a research notebook, and the AI assistant knows your datasets and can write the code for you.
Privacy and cost
Your datasets are private to your account. A backtest only receives the datasets its code names, and only yours. The first 1 GB of storage is free; beyond it, storage is $0.10 per GB a month, charged daily. You can rename, replace or delete a dataset at any time.
Large files and long histories can need more memory than the standard machine has. If a backtest on a big dataset fails, pick a bigger machine.
Frequently asked questions
Can I backtest on my own data?
Yes. Upload a CSV on the My datasets page; it's checked and converted, then one add_data line loads it into a backtest or a notebook.
What format does the CSV need?
A header row, then one row per time. The time column is the one named time, timestamp, date or similar, else the first column, in YYYY-MM-DD HH:MM:SS (UTC), ISO 8601 with an offset, or Unix seconds or milliseconds. Price bars also need open, high, low and close columns.
How big can an uploaded dataset be?
Up to 500 MB a file, 5 million rows and 50 columns. The first 1 GB of storage is free; beyond it, storage is $0.10 per GB a month.
