Esempio n. 1
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);
        }
Esempio n. 2
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);
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // Create the command for the tool window
                var toolwndCommandID = new CommandID(GuidList.guidQCStudioPluginCmdSet, (int)PkgCmdIDList.cmdidQCLocal);
                var menuToolWin      = new OleMenuCommand((sender, e) => { QCPluginUtilities.ShowBacktestLocal(); }, toolwndCommandID);
                mcs.AddCommand(menuToolWin);

                toolwndCommandID = new CommandID(GuidList.guidQCStudioPluginCmdSet, (int)PkgCmdIDList.cmdidQCSaveLocal);
                menuToolWin      = new OleMenuCommand(async(sender, e) =>
                {
                    OptionPageGrid page = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));
                    await QCStudioPluginActions.SaveLocalBacktest(page.PathBinaries2, page.PathData2);
                }, toolwndCommandID);
                mcs.AddCommand(menuToolWin);

                toolwndCommandID = new CommandID(GuidList.guidQCStudioPluginCmdSet, (int)PkgCmdIDList.cmdidQCRemote);
                menuToolWin      = new OleMenuCommand((sender, e) =>
                {
                    var windowFrame = GetToolWindowFrame <AdminPane>();
                    ErrorHandler.ThrowOnFailure(windowFrame.Show());
                }, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }

            CustomInitialize();
        }
        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);
        }
        private void CustomInitialize()
        {
            string AppTitle      = Resources.ToolWindowTitle;
            var    dte           = (DTE2)GetService(typeof(EnvDTE.DTE));
            var    dialogFactory = GetService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;
            var    outputWindow  = GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            var page = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));

            page.PropertyChanged += page_PropertyChanged;

            QCPluginUtilities.Initialize(AppTitle, dte, dialogFactory, outputWindow, this.GetPaneWindow);
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
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);
        }