Back

GDAX Backtest Results Tabs - Trades versus Logs Discrepancy

Can someone please provide some insights to why the trades tab in my backtest results are showing one set of prices for my long and shorts, yet the logs are showing a completely different long and short prices.  The logs are recording the current price at the time of the order event.  I would think this should match current prices listed in the trades tab because the trade and the event log are happening in the same function.  Where is the trade tab prices coming from?  Why is there such a discrepancy between the trade tab prices and the log prices?

On a side note, I've never been able to resolve the 5 hour timestamp difference I'm seeing with any of my GDAX backtests or even in live trading.  Help with this would also be appreciated.  

using System;
using System.Globalization;
using System.Linq;
using QuantConnect.Indicators;
using QuantConnect.Models;


namespace QuantConnect.DemaSlope.GDAX
{

public class MovingAverageCross : QCAlgorithm
{
private const string Symbol = "BTCUSD";
private DoubleExponentialMovingAverage slow;
private decimal previousDEMA = 1m;
private decimal limitQuantity = 0m;
private decimal limitOrderPrice = 0m;

public override void Initialize()
{

//Add the coin and resolution
AddCrypto(Symbol, Resolution.Minute);

//Live constants
SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash);
DefaultOrderProperties = new GDAXOrderProperties {PostOnly = true};

//Backtesting variables
SetStartDate(2018, 02, 01);
SetEndDate(2018, 02, 2);
//SetEndDate(DateTime.Now.Date.AddDays(-1));
SetCash(1000);

//Indicator variables
slow = DEMA(Symbol, 150, Resolution.Minute);

}

private DateTime previous;

public void OnData(TradeBars data)
{
if (!slow.IsReady) return;

if (previous.Minute == Time.Minute) return;

const decimal tolerance = 0.00025m;
var holdings = Portfolio[Symbol].Quantity;
var actualAmountHolding = Portfolio.CashBook["BTC"].Amount;

//Cancel all outstanding orders.
Transactions.CancelOpenOrders(Symbol);

if (holdings <= 0)
{
// if the slow is greater than the previousDEMA, go long
if (slow > previousDEMA * (1 + tolerance))
{
//Set order quantity to 97% of total cash
limitQuantity = Portfolio.Cash * 0.97m / Securities[Symbol].Price;

//Set the limit price
limitOrderPrice = Securities[Symbol].Price; // * 1.001m;

//Log market price versus limit price
Log("MARKET PRICE = " + Securities[Symbol].Price + ". BUY COINS @ MAX LIMIT PRICE >> " + limitOrderPrice);
LimitOrder(Symbol, limitQuantity, limitOrderPrice);
}
}

// Liquidate if currently holding a position
// if the slow is less than the previousDEMA then sell
if (holdings > 0 && slow < previousDEMA * (1-tolerance))
{
Log("SELL >> " + Securities[Symbol].Price);
Sell(Symbol, actualAmountHolding);
//Liquidte doesn't work with GDAX
//Liquidate(Symbol);
}

Plot(Symbol, "Price", data[Symbol].Price);
Plot(Symbol, slow);

previous = Time;
previousDEMA = slow;
}
}
}

 

   

Update Backtest








Update Backtest





0

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.


Loading...

This discussion is closed