TLDR, the code is supposed to just short the same asset every day with 50% of my portfolio equity. Is it normal for such a big discrepancy between quantconnect and tradingview soley due to slightly different price data? TV says 1200% return, QC says 2500% return.

 

---

 

The first script below is on TradingView, the second one is supposed to be the same thing on QuantConnect. TradingView says it returns 2385% profit whereas QuantConnect says it returns 3120% profit. I have seen it have a 1200% vs 2500% discrepancy on other assets. Same algo.

 

Is it normal for there to be a big discrepancy between QuantConnect and TradingView? I have looked and seen that the price data is a bit different for both platforms. Is that all that's going on? Just wondering in the future how big of a discrepancy I can expect when porting TradingView algorithms to QuantConnect.

TradingView code
//@version=5
strategy(title="Simply Short",
         shorttitle="Simply Short",
         overlay=false,
         calc_on_order_fills=false,
         calc_on_every_tick=true,
         default_qty_type=strategy.cash,
         default_qty_value=5000000,
         initial_capital=10000000,
         currency=currency.USD,
         slippage=0,
         commission_type=strategy.commission.percent,
         commission_value=0,
         process_orders_on_close=false,
         margin_long=75,
         margin_short=90,
         use_bar_magnifier=false
         )

// startDate = input.time(title="Start Date", defval=timestamp("2012-01-01"), group="Trading")
startDate = input.time(title="Start Date", defval=timestamp("2010-06-01"), group="Trading")
afterStartDate = time >= startDate
endDate = input.time(title="End Date", defval=timestamp("2024-06-03"), group="Trading")
beforeEndDate = time < endDate

withinDateRange = afterStartDate and beforeEndDate


// Calculate quantity based on current equity
// float quantity = .5 * strategy.equity / close

// Enter a short position continuously
if (withinDateRange)
    strategy.close_all()
    float quantity = .5 * strategy.equity / close
    strategy.entry("Short", strategy.short, qty=quantity)

// Close short position on the last bar
if (barstate.islast)
    strategy.close_all()
QuantConnect code:
#region imports
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Globalization;
    using System.Drawing;
    using QuantConnect;
    using QuantConnect.Algorithm.Framework;
    using QuantConnect.Algorithm.Framework.Selection;
    using QuantConnect.Algorithm.Framework.Alphas;
    using QuantConnect.Algorithm.Framework.Portfolio;
    using QuantConnect.Algorithm.Framework.Execution;
    using QuantConnect.Algorithm.Framework.Risk;
    using QuantConnect.Parameters;
    using QuantConnect.Benchmarks;
    using QuantConnect.Brokerages;
    using QuantConnect.Util;
    using QuantConnect.Interfaces;
    using QuantConnect.Algorithm;
    using QuantConnect.Indicators;
    using QuantConnect.Data;
    using QuantConnect.Data.Consolidators;
    using QuantConnect.Data.Custom;
    using QuantConnect.DataSource;
    using QuantConnect.Data.Fundamental;
    using QuantConnect.Data.Market;
    using QuantConnect.Data.UniverseSelection;
    using QuantConnect.Notifications;
    using QuantConnect.Orders;
    using QuantConnect.Orders.Fees;
    using QuantConnect.Orders.Fills;
    using QuantConnect.Orders.Slippage;
    using QuantConnect.Scheduling;
    using QuantConnect.Securities;
    using QuantConnect.Securities.Equity;
    using QuantConnect.Securities.Future;
    using QuantConnect.Securities.Option;
    using QuantConnect.Securities.Forex;
    using QuantConnect.Securities.Crypto;
    using QuantConnect.Securities.Interfaces;
    using QuantConnect.Storage;
    using QuantConnect.Data.Custom.AlphaStreams;
    using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm;
    using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm;
#endregion

namespace QuantConnect.Algorithm.CSharp
{
    public class InteractiveBrokersBrokerageExampleAlgorithm : QCAlgorithm
    {
        private Equity _equity;
        private Symbol _symbol;
        private string _symbolString = "TECS";
        private decimal _targetMargin = -0.5m;

        public override void Initialize()
        {
            SetStartDate(2010, 06, 01);
            SetEndDate(2024, 6, 3);
            SetCash(10_000_000);
            
            SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin);
            _equity = AddEquity(_symbolString, Resolution.Daily, extendedMarketHours: false);
            _symbol = _equity.Symbol;
            
            _equity.SetBuyingPowerModel(new SecurityMarginModel(.75m, .9m, 0));
            _equity.SetFeeModel(new ConstantFeeModel(0));
            _equity.SetSlippageModel(new ConstantSlippageModel(0));
            _equity.MarginInterestRateModel = MarginInterestRateModel.Null;
            Settings.MinimumOrderMarginPortfolioPercentage = 0;

            // Set default order properties
            DefaultOrderProperties = new InteractiveBrokersOrderProperties
            {
                TimeInForce = TimeInForce.GoodTilCanceled,
                OutsideRegularTradingHours = false
            };
        }

        public override void OnData(Slice data)
        {
            if (!data.Bars.ContainsKey(_symbol))
                return;
            SetHoldings(_symbol, _targetMargin);
        }
    }
}