I have a client who has a Pine Script (TradingView) strategy that they would like to convert to a Python QuantConnect strategy. The strategy relies on technical patterns derived from OHLC (open, high, low, close) and volume data. It appears that the indicators displayed on QuantConnect are quite different from what I'm seeing on TradingView.
After further investigation, I've noticed a significant difference between the OHLC and volume data on the two platforms. Here is a comparison for minute bars on TSLA, for example.
Quant Connect
open high low close volume
2024-02-26T04:42:00-05:00 195.91 196.18 195.74 195.76 893406
2024-02-26T04:43:00-05:00 195.77 196.4 195.47 196.46 45974
Trading View
open high low close volume
2024-02-26T04:42:00-05:00 190.17 190.2 190.13 190.13. 507
2024-02-26T04:43:00-05:00 190.13 190.13 190.13 190.13. 604
I read somewhere that QuantConnect calculates its own ohlc data based on tick data. Questions:1. Is there anyway to align the QuantConnect data anywhere close to what I'm seeing to TradingView? Has anyone tried or been succcessful at this? 2. I assume QuantConnect data is also not adjusted for any corporate actions etc.. Is there a way to get US Equity ohlc volume data adjusted?
3. A health check re: my code below. Am I receiving all data including after hours?
4. Do Research Notebooks use the same data as backtests? Here is the code I've used to pull data from the Research Notebook. I assume the data used in Research Notebooks is identical to the data used in backtests.
qb = QuantBook()
symbol = qb.AddEquity("TSLA")
history = qb.History(qb.Securities.Keys, 360, Resolution.Minute)
from QuantConnect import Resolution
from QuantConnect.Data.Market import TradeBar
from IPython.display import display
# Initialize the QuantBook
qb = QuantBook()
# Add the TSLA equity
symbol = qb.AddEquity("TSLA")
# Define the start and end times for February 27, 2024
start_time = datetime(2024, 2, 26)
end_time = datetime(2024, 2, 27) # The end time is exclusive
# Fetch the historical TradeBar data for TSLA
history_trade_bar_df = qb.History(TradeBar, symbol.Symbol, start_time, end_time, Resolution.Minute)
# Check if history is empty (e.g., on weekends or holidays)
if history_trade_bar_df.empty:
print("No historical TradeBar data found for the specified date range. Please check the dates and try again.")
else:
# Format the DataFrame
history_trade_bar_df.reset_index(inplace=True)
history_trade_bar_df['time'] = history_trade_bar_df['time'].dt.strftime('%Y-%m-%dT%H:%M:%SZ')
# Print the entire DataFrame without truncation
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
# print(history_trade_bar_df[['time', 'open', 'high', 'low', 'close', 'volume']].to_string(index=False))
# Print the entire DataFrame without truncation
with pd.option_context('display.max_rows', None, 'display.max_columns', None, 'display.width', 1000):
display(history_trade_bar_df[['time', 'open', 'high', 'low', 'close', 'volume']])
Some visual comparison on simple RSI 14 close. (with 70 and 30 horizontal lines)QuantConnect:

TradingView:

Yuri Lopukhov
First thing is that in TradingView, unless you pay extra, intraday data is not complete:
By default QuantConnect data IS adjusted by splits and dividends. You can choose to adjust by dividends or splits or both when you request data, as described in the documentation here:
https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/us-equity/requesting-data#11-Data-Normalization
Yuri Lopukhov
There are more differences between platforms than data, indicators may calculate a bit differently, hourly consolidators have different boundaries (9:30-10:00, or rather 9:00-10:00 on QuantConnect, 9:30-10:30 on TradingView). So in general 100% matching results are usually impossible and this shouldn't be a purpose on its own.
Jared Broad
Thanks Yuri, I didn't know Trading View was 930-1030 👍
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Dom
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!