Exemplo n.º 1
0
        public async static void ShowBacktestLocal()
        {
            var dlg = new OpenFileDialog
            {
                Filter = "JSON file|*.json|All files|*.*",
                Title  = "Open Backtest results from file"
            };

            if (DialogResult.OK == dlg.ShowDialog())
            {
                var control = QCPluginUtilities.GetPaneWindow();

                await QCStudioPluginActions.Authenticate();

                control.Logger = (msg) => {
                    QCPluginUtilities.OutputCommandString(msg, QCPluginUtilities.Severity.Error);
                };

                control.Initialize(Path.GetFileNameWithoutExtension(dlg.FileName), QCStudioPluginActions.UserID, QCStudioPluginActions.AuthToken);
                var _results = await QCStudioPluginActions.LoadLocalBacktest(dlg.FileName);

                QCPluginUtilities.OutputCommandString("GetBacktestResults succeded: " + _results.Success, QCPluginUtilities.Severity.Info);
                foreach (var err in _results.Errors)
                {
                    QCPluginUtilities.OutputCommandString(err, QCPluginUtilities.Severity.Error);
                }

                control.Run(_results.rawData);
            }
        }
Exemplo n.º 2
0
        public async static void ShowBacktestRemote(string backtestId)
        {
            var control = QCPluginUtilities.GetPaneWindow();

            await QCStudioPluginActions.Authenticate();

            control.Logger = (msg) => {
                QCPluginUtilities.OutputCommandString(msg, QCPluginUtilities.Severity.Error);
            };

            control.Initialize(backtestId, QCStudioPluginActions.UserID, QCStudioPluginActions.AuthToken);
            var _results = await QCStudioPluginActions.GetBacktestResults(backtestId);

            if (_results.Errors == null)
            {
                _results.Errors = new List <string>();
            }

            QCPluginUtilities.OutputCommandString("GetBacktestResults succeded: " + _results.Success, QCPluginUtilities.Severity.Info);
            foreach (var err in _results.Errors)
            {
                QCPluginUtilities.OutputCommandString(err, QCPluginUtilities.Severity.Error);
            }

            control.Run(_results.rawData);
        }
        private IVsWindowFrame GetToolWindowFrame <T>()
        {
            ToolWindowPane window = this.FindToolWindow(typeof(T), 0, true);

            if ((null == window) || (null == window.Frame))
            {
                QCPluginUtilities.OutputCommandString("Failed to initialize " + Resources.ToolWindowTitle, QCPluginUtilities.Severity.Error);
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }

            return((IVsWindowFrame)window.Frame);
        }
Exemplo n.º 4
0
        public static void GetSelectedItem(out string classDll, out string className)
        {
            classDll  = "";
            className = "";
            if (dte.SelectedItems.Count != 1)
            {
                return;
            }
            var selitem = dte.SelectedItems.Cast <SelectedItem>().FirstOrDefault();

            var startupProjDir = GetProjectOutputBuildFolder(selitem.ProjectItem.ContainingProject);

            classDll = Path.Combine(startupProjDir, selitem.ProjectItem.ContainingProject.Name) + ".dll";

            className = GetAlgorithmsList(selitem.ProjectItem.Document.FullName, classDll).FirstOrDefault();

            if (!File.Exists(classDll))
            {
                QCPluginUtilities.OutputCommandString("The algorithm binary not found: " + classDll, QCPluginUtilities.Severity.Error);
                classDll = null;
            }
            else
            {
                QCPluginUtilities.OutputCommandString("Using algorithm binary: " + classDll, QCPluginUtilities.Severity.Info);
            }

            if (className == null)
            {
                QCPluginUtilities.OutputCommandString("The algorithm class not found. Check that all relevant classes implement QuantConnect.Algorithm.QCAlgorithm.", QCPluginUtilities.Severity.Error);
                //TODO: show dialog with 2 dropdowns to choose correct algorithm class
            }
            else
            {
                QCPluginUtilities.OutputCommandString("Using algorithm class: " + className, QCPluginUtilities.Severity.Info);
            }
        }
Exemplo n.º 5
0
        public static string GetProjectOutputBuildFolder(EnvDTE.Project proj)
        {
            string absoluteOutputPath = null;
            string projectFolder      = Path.GetDirectoryName(proj.FullName);

            try
            {
                //Get the configuration manager of the project
                EnvDTE.ConfigurationManager configManager = proj.ConfigurationManager;

                if (configManager == null)
                {
                    QCPluginUtilities.OutputCommandString("The project " + proj.Name + " doesn't have a configuration manager", QCPluginUtilities.Severity.Error);
                }
                else
                {
                    //Get the active project configuration
                    EnvDTE.Configuration activeConfiguration = configManager.ActiveConfiguration;

                    //Get the output folder
                    string outputPath = activeConfiguration.Properties.Item("OutputPath").Value.ToString();

                    //The output folder can have these patterns:
                    //1) "\\server\folder"
                    //2) "drive:\folder"
                    //3) "..\..\folder"
                    //4) "folder"
                    if (outputPath.StartsWith(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString()))
                    {
                        //This is the case 1: "\\server\folder"
                        absoluteOutputPath = outputPath;
                    }
                    else if (outputPath.Length >= 2 && outputPath[1] == Path.VolumeSeparatorChar)
                    {
                        //This is the case 2: "drive:\folder"
                        absoluteOutputPath = outputPath;
                    }
                    else if (outputPath.IndexOf("..\\") > -1)
                    {
                        //This is the case 3: "..\..\folder"
                        while (outputPath.StartsWith("..\\"))
                        {
                            outputPath    = outputPath.Substring(3);
                            projectFolder = Path.GetDirectoryName(projectFolder);
                        }

                        absoluteOutputPath = Path.Combine(projectFolder, outputPath);
                    }
                    else
                    {
                        //This is the case 4: "folder"
                        projectFolder      = Path.GetDirectoryName(proj.FullName);
                        absoluteOutputPath = Path.Combine(projectFolder, outputPath);
                    }
                }
            }
            catch (Exception ex)
            {
                QCPluginUtilities.OutputCommandString("Get project output build folder error: " + ex.ToString(), QCPluginUtilities.Severity.Error);
            }

            return(absoluteOutputPath);
        }