SmartQuant Discussion
http://www.smartquant.com/forums/

Fill price is last bar close when send order at OnBarOpen
http://www.smartquant.com/forums/viewtopic.php?f=86&t=14988
Page 1 of 1

Author:  wukan [ Sat Nov 30, 2019 3:25 pm ]
Post subject:  Fill price is last bar close when send order at OnBarOpen

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.

Author:  skuvv [ Mon Dec 02, 2019 12:26 pm ]
Post subject:  Re: Fill price is last bar close when send order at OnBarOpe

Hi, problem will be fixed in next release.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/