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

Scheduling a Script to Run once a Day
http://www.smartquant.com/forums/viewtopic.php?f=44&t=10598
Page 1 of 1

Author:  umer.master [ Tue Oct 01, 2013 3:08 pm ]
Post subject:  Scheduling a Script to Run once a Day

Hello Support,

We are looking to achieve the following functionality:

Our QuantBase installation is collecting 1 minute data. What we need to do is Compress the bars to another (odd) time-frame at the end of each day so that we can use the compressed bars for testing etc. We need to automate this process and it should run at lets suppose 06:30 PM each day.

What we have tried:

We have a small script (also available on the forum) that converts/compresses the bars into our required time-frame. Now we need to schedule it to run at a specific time each day. What we have not been able to do is find a way to automate it inside OpenQuant. We also tried developing an external C# application that can then be used as a scheduled application in windows to run at our specified time. But, when we replicated the script in the external application with all the necessary references to OpenQuant assemblies provided, we get the popup at the start of the application:

Image

We have tried other ways to make this work as well (putting the executables in the OpenQuant base directory etc) but they all lead us no where.

We need to understand how to run a script at a specific time each day (if possible)? Or if that is not possible, how can we replicate it in an external application so that we can put it in the windows scheduling to run at a specific time of the day each day.

Hoping to hear from you soon.

Thanks
Umer

Author:  Alexei Kurov [ Tue Oct 01, 2013 4:14 pm ]
Post subject:  Re: Scheduling a Script to Run once a Day

Hi Umer,

You can run the script and leave it running.
It will check specified time and execute the task.
for example
Code:
   DateTime nextRun = DateTime.Today.AddHours(18).AddMinutes(30);

   while (true)
   {
      if (DateTime.Now >= nextRun)
      {
           nextRun = nextRun.AddDays(1);

           //  do some tasks
      }
      else
         System.Threading.Thread.Sleep(1000);
    }

Author:  umer.master [ Wed Oct 02, 2013 2:57 pm ]
Post subject:  Re: Scheduling a Script to Run once a Day

Hello Alexei,

Thank you for your response. We had tried this but wanted to know if there was another more elegant solution for this.

We will go with this for now and let you know if we need anything else.

Regards
Umer

Author:  Alexei Kurov [ Wed Oct 02, 2013 3:10 pm ]
Post subject:  Re: Scheduling a Script to Run once a Day

umer.master wrote:
We had tried this but wanted to know if there was another more elegant solution for this.

No.
OpenQuant has no built-in scheduler.

Author:  umer.master [ Fri Oct 04, 2013 9:48 am ]
Post subject:  Re: Scheduling a Script to Run once a Day

Thank you Alexei. Much appreciated.

We are going with the forever loop way for now with a bigger sleep time and it isnt taking much resources. So its fine.

Regards
Umer

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