Hi,
I have only daily bars no trades,
I send market order at begin of the day, but filled at yesterday close.
If i send order after stock dividend, the error is too big.
My Data:
Quote:
DateTime,Open,High,Low,Close,Volume,OpenInt
2019-01-04 00:00:00.000,100,110,90,105,100,1
2019-01-05 00:00:00.000,200,210,190,205,100,1
2019-01-06 00:00:00.000,300,310,290,305,100,1
2019-01-07 00:00:00.000,400,410,390,405,100,1
2019-01-08 00:00:00.000,500,510,390,505,100,1
My Code:
Code:
using System;
using SmartQuant;
namespace OpenQuant
{
public class Backtest : Scenario
{
public Backtest(Framework framework)
: base(framework)
{
}
public override void Run()
{
Instrument instrument1 = InstrumentManager.Instruments["TEST"];
// Create SMA Crossover strategy
strategy = new MyStrategy(framework, "SMACrossover");
// Add instruments
strategy.AddInstrument(instrument1);
// Set simulation interval
this.DataSimulator.SubscribeAll = true;
// Run the strategy
StartStrategy();
}
}
}
using System;
using System.Drawing;
using SmartQuant;
using SmartQuant.Indicators;
using SmartQuant.Optimization;
namespace OpenQuant
{
public class MyStrategy : InstrumentStrategy
{
public MyStrategy(Framework framework, string name)
: base(framework, name)
{
}
protected override void OnBarOpen(Instrument instrument, Bar bar)
{
Buy(instrument, 1);
}
}
}
the ExecutionSimulator:
Quote:
FillMarketOnNext=false
FillOnBarOpen=true
OrderManager export to csv:
Quote:
DateTime,Provider,Symbol,Side,SubSide,Type,Qty,Avg. Price,Price,Stop Price,Status,Text
01/08/2019 00:00:00.000,2,TEST,Buy,Undefined,Market,1,405.00,0.00,0.00,Filled,
01/07/2019 00:00:00.000,2,TEST,Buy,Undefined,Market,1,305.00,0.00,0.00,Filled,
01/06/2019 00:00:00.000,2,TEST,Buy,Undefined,Market,1,205.00,0.00,0.00,Filled,
01/05/2019 00:00:00.000,2,TEST,Buy,Undefined,Market,1,105.00,0.00,0.00,Filled,
01/04/2019 00:00:00.000,2,TEST,Buy,Undefined,Market,1,105.00,0.00,0.00,Filled,
Or, Could you provide an interface for user to control the fill price and fill qty.