SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Fri Oct 23, 2020 1:35 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jan 09, 2012 9:36 pm 
Offline

Joined: Mon Mar 05, 2007 7:02 am
Posts: 58
I use Git for all source code management for everything developed in OQ. Currently its used in a very basic fashion with manual commits and this process works fine, but is messy and prone to errors.

I'd like to make it easier to track strategy code, inputs, outputs, results. To do this I'd like to programatically commit the OQ solution, project, input files (symbol lists, parameters, etc), output files (results) to the Git repository.

Has anyone done something similar to this? I'm not sure about how to best approach the problem other than committing files after running the solution.

Code:
using System;
using System.Diagnostics;
using OpenQuant.API;
using OpenQuant.API.Engine;
using LibGit2Sharp;

public class MyScenario : Scenario
{
   public override void Run()
   {   
      Start();
      GitCommit();
   }
}


A couple ideas I have are:
1) LibGit2Sharp Integration: http://stackoverflow.com/questions/4034962/which-language-has-the-best-git-api-bindings & https://github.com/libgit2/libgit2sharp
2) Call the standard Git commands from OQ scenario file

Any thoughts on how to best do this?

Thanks,
Eric


Top
 Profile  
 
PostPosted: Mon Jan 16, 2012 11:09 am 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi,

We are now working on new Task engine for OQ. Tasks will be a kind of combination of scripts and scenarios. It will be possible to develop a task that commits all you need into git when any solution is started. We haven't tried to play with git from c# code, but if you find some lib that allows to do it then this lib + tasks should do the job.

Regards,
Sergey.


Top
 Profile  
 
PostPosted: Fri Mar 09, 2012 2:15 am 
Offline

Joined: Mon Mar 05, 2007 7:02 am
Posts: 58
I got tired of manually committing all source, results etc. into a repo after each test run and/or changes.

I figured out a way to do this using the Windows Git Command Line. Note: This method requires Git to be added to the Windows Path.

Here it is:

Code:
   
public override void OnStrategyStart()
{
   if (GitCommit)
   {
      string command = "call C://Users//Eric//Documents//GitAutoCommit.bat";
      ExecuteCommand(command);
   }
}

static void ExecuteCommand(string command)
{
   int ExitCode;
   ProcessStartInfo ProcessInfo;
   Process process;

   ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
   ProcessInfo.CreateNoWindow = true;
   ProcessInfo.UseShellExecute = false;
   // *** Redirect the output ***
   ProcessInfo.RedirectStandardError = true;
   ProcessInfo.RedirectStandardOutput = true;

   process = Process.Start(ProcessInfo);
   process.WaitForExit();

   // *** Read the streams ***
   string output = process.StandardOutput.ReadToEnd();
   string error = process.StandardError.ReadToEnd();

   ExitCode = process.ExitCode;

   Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
   Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
   Console.WriteLine("ExitCode: " + ExitCode.ToString(), "ExecuteCommand");
   process.Close();
}



Here is the Batch file being called:
Code:
@ECHO OFF

REM get date and time
for /f "delims=" %%a in ('date/t') do @set mydate=%%a
for /f "delims=" %%a in ('time/t') do @set mytime=%%a
set fvar=%mydate%%mytime%

REM add all new files
cd C:\Users\Eric\Documents\OpenQuant
call git add .
call git commit -a -m "Automated commit on %fvar%"


Eric


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group