示例#1
0
        /// <summary>
        /// Gets the mood of a post using the viralheat API
        /// </summary>
        /// <param name="text">The post to be analyzed</param>
        /// <returns>"negative" or "positive"</returns>
        public static Sentiment GetSentimentMood(string text)
        {
            Sentiment result = new Sentiment();

            string viralHeatApiKey = "&api_key=" + ChartManager.GetViralHeatAPIKey();
            //if(firstAPIUsed)
            //viralHeatApiKey = "&api_key=olGbEN1IUhKjrvgQvZOt";
            string url = "http://www.viralheat.com/api/sentiment/review.json?text=" + text + viralHeatApiKey;

            string jsonString;

            try
            {
                jsonString = new System.Net.WebClient().DownloadString(url);
            }
            catch (Exception e)
            {
                //Error with the webservice
                System.Diagnostics.Debug.WriteLine("========================");
                System.Diagnostics.Debug.WriteLine("Error with webservice");
                System.Diagnostics.Debug.WriteLine(e.ToString());
                System.Diagnostics.Debug.WriteLine("========================");
                //done = true;
                return(null);
            }
            if (jsonString.Contains("Error"))
            {
                //Post was probably not in english, skip it

                if (jsonString.Contains("Over quota limit"))
                {
                    //firstAPIUsed = true;
                    //ChartManager.toggleLanguageAnalysis();
                    System.Diagnostics.Debug.WriteLine("=================================");
                    System.Diagnostics.Debug.WriteLine("Out of ViralHeat Queries");
                    System.Diagnostics.Debug.WriteLine("=================================");
                    result      = new Sentiment();
                    result.mood = "unknown";
                    result.prob = -1;
                    result.text = text;
                    result      = null;
                }
                else
                {
                    //ChartManager.setLanguageAnalysis(false);
                    System.Diagnostics.Debug.WriteLine("========================");
                    System.Diagnostics.Debug.WriteLine("Error with webservice");
                    System.Diagnostics.Debug.WriteLine(url);
                    System.Diagnostics.Debug.WriteLine(jsonString);
                    System.Diagnostics.Debug.WriteLine("========================");
                    result = null;
                }
            }
            else
            {
                result = JsonConvert.DeserializeObject <Sentiment>(jsonString);
            }

            return(result);
        }
示例#2
0
 protected override void OnTrackingLost()
 {
     _rm.ChangeFatiaTag("AxisVisOption_Item");
     visCard         = null;
     _axisID         = 0;
     _instrutorSteps = new[] { "Select Vis", "Select Axis", "Select Attribute" };
 }
示例#3
0
 // Start is called before the first frame update
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
 private void LoadChart()
 {
     ChartManager.LoadChart(chartName, matchesType, new[] { seria1, seria2, seria3 }, currentRole);
     chartNameLabel.Content = $"{chartName} ({matchesType})";
     lbMatchesCount.Content = $"{Properties.Resources.MatchesCount} {ChartManager.MatchesCount}";
     lbWinRate.Content      = $"{Properties.Resources.WinRate} {ChartManager.WinRate}%";
 }
示例#5
0
    public void SelectedVis(string optionName)
    {
        visCard = GameObject.Find("Chart_Target_0" + optionName[0]).GetComponent <ChartManager>();
        int           maxDimensions = visCard.GetMaxDim();
        List <string> AxisOptions   = new List <string>();

        _instrutorSteps[0] = optionName;
        instrutor.text     = _instrutorSteps[0] + "\n" + _instrutorSteps[1] + "\n" + _instrutorSteps[2];

        for (int i = 0; i < maxDimensions; i++)
        {
            switch (i)
            {
            case 0:
                AxisOptions.Add(visCard.GetChartType() == "parallel_coordinates" ? "Vertical Axis" : "X Axis");
                break;

            case 1:
                AxisOptions.Add(visCard.GetChartType() == "parallel_coordinates" ? "Color" : "Y Axis");
                break;

            case 2:
                AxisOptions.Add("Color");
                break;
            }
        }


        _rm.SetRadialOptions(AxisOptions);
        _rm.ChangeFatiaTag("AxisOption_Item");
    }
        //private BarometerDbContext db = BarometerDbContext.Create();
        public DashboardController()
        {
            UnitOfWorkManager unitOfWorkManager = new UnitOfWorkManager();

            this.userManager = new ApplicationUserManager(unitOfWorkManager);
            ChartManager     = new ChartManager(unitOfWorkManager);
            itemManager      = new ItemManager(unitOfWorkManager);
        }
    // Use this for initialization
    void Start()
    {
        _cm = transform.parent.GetComponent<ChartManager>();

          _switchFloorplate = GetComponentInChildren<SwitchFloorplate>();
          _switchFloorplate.OnSwitchSteppedOn += OnSwitchSteppedOn;
          _switchFloorplate.OnSwitchSteppedOff += OnSwitchSteppedOff;
    }
示例#8
0
        public Form1()
        {
            InitializeComponent();
            // MyWSIM = new WaterSimManager_DB(".", ".");
            SQLServer ServerType         = SQLServer.stText;
            string    TheDefaultDatabase = Path.GetDirectoryName(Application.ExecutablePath);

            MyWSIM = new WaterSimManager_DB(ServerType, ".", ".", TheDefaultDatabase, "", "", "", "");
            //            MyWSIM = new WaterSimManager_SIO(".", ".");
            //UnitData TheData = null;
            //TheData = MyWSIM.TheCRFNetwork.CRFUnitData;

            // This add some groups for the west data
            WaterSimDCDC.WestTools.AddWestParameterGroups(MyWSIM);

            SetupPhrasesAndColors();

            foreach (string name in MyWSIM.WaterSimWestModel.UnitModelNames)
            {
                DisplaySankeyMenuItem.DropDownItems.Add(name);
                SanKeyGraphcomboBox.Items.Add(name);
            }

            parameterTreeView1.ParameterManager = MyWSIM.ParamManager;

            // Set al;l Industry to purple, default is red
            foreach (WaterSimCRFModel WSM in MyWSIM.WaterSimWestModel.WaterSimCRFModels)
            {
                WSM.TheCRFNetwork.Industrial.Color = Color.Purple;
            }
            // Reset Size of Sankey Graph
            sankeyGraphUnit.Width = SankeyGraphPanel.Width - 2;
            sankeyGraphUnit.Invalidate();
            Application.DoEvents();
            // Ok, reset the graph
            ResetSanKeyGraphUnit(ModelUnitName);
            // Create the chart manager
            MyCM = new ChartManager(chart1, "MyCHart");
            // Setup Input Tree
            treeViewInput.CheckBoxes = true;
            foreach (int emp in MyWSIM.ParamManager.eModelParameters())
            {
                ModelParameterClass MP = MyWSIM.ParamManager.Model_Parameter(emp);
                if (MP.isInputParam)
                {
                    treeViewInput.Nodes.Add(new ParameterTreeNode(MP));
                }
            }
            // Setup MultiSankey Window
            MyMultiSankey = new ShowMultipleSankeyV1(MyWSIM);
            MyMultiSankey.Hide();
            //regionTreeViewClass1.WaterSim = MyWSIM;
            regionTreeViewClass1.WaterSim        = MyWSIM;
            regionTreeViewClass1.CallBackHandler = RegionTreeViewCallback;


            // LoadParameterDropDown();
        }
        public PageController()
        {
            UnitOfWorkManager unitOfWorkManager = new UnitOfWorkManager();

            this.im                 = new ItemManager(unitOfWorkManager);
            this.userManager        = new ApplicationUserManager(unitOfWorkManager);
            this.am                 = new AlertManager(unitOfWorkManager);
            this.socialMediaManager = new SocialMediaManager(unitOfWorkManager);
            this.chartManager       = new ChartManager(unitOfWorkManager);
        }
示例#10
0
        protected BasicController()
        {
            UnitOfWorkManager unitOfWorkManager = new UnitOfWorkManager();

            SocialMediaManager = new SocialMediaManager(unitOfWorkManager);
            AlertManager       = new AlertManager(unitOfWorkManager);
            UserManager        = new ApplicationUserManager(unitOfWorkManager);
            UserManager.SetSocialMediaManager(SocialMediaManager);
            ChartManager = new ChartManager(unitOfWorkManager);
        }
示例#11
0
 private void Awake()
 {
     if (null == instance)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
示例#12
0
        public static List <ChartData> GetChart(ChartsDetails chartsDetails)
        {
            switch (chartsDetails.type)
            {
            case 1: return(ChartManager.GetJobsOpenedChart(chartsDetails.start, chartsDetails.end, chartsDetails.userid, chartsDetails.curUserid));

            case 2: return(ChartManager.GetGraduatesVSJobs(chartsDetails.branches, chartsDetails.areas, chartsDetails.userid, chartsDetails.curUserid));

            case 3: return(ChartManager.GetPlacementsChart(chartsDetails.start, chartsDetails.end, chartsDetails.userid, chartsDetails.curUserid));

            default:
                return(null);
            }
        }
示例#13
0
        private async Task <ChartController> CreatChartControllerAsync(IEnumerable <Chart> testData)
        {
            await context.Charts.AddRangeAsync(testData);

            await context.SaveChangesAsync();

            var albumRepository  = new AlbumRepository(context);
            var chartRepository  = new ChartRepository(context);
            var artistRepository = new ArtistRepository(context);
            var pieceRepository  = new PieceRepository(context);
            var service          = new ChartManager(chartRepository, albumRepository, pieceRepository, artistRepository);

            return(new ChartController(service));
        }
示例#14
0
        public MainForm()
        {
            Global.MainForm = this;

            Global.DockManager      = new ExtDockManager();
            Global.DockManager.Dock = DockStyle.Fill;
            this.Controls.Add(Global.DockManager);

            InitializeComponent();

            _helpManager   = new HelpManager();
            _tablesManager = new TablesManager();
            _chartManager  = new ChartManager();
            _properties    = new PropertiesManager();
            _filesManager  = new FilesManager();
            _buildManager  = new BuildManager();
        }
示例#15
0
 public void RealInitailize()
 {
     try
     {
         var initDataNode = HtmlPage.Window.Invoke("GetInitData");
         SettingsProvider settingsProvider = new SettingsProvider(initDataNode.ToString()); //new SettingsProvider(data.Instruments,data.EnableTrendSheetChart,data.HighBid,data.LowBid);
         ChartManager chartManager = new ChartManager(this._QuotationProvider, settingsProvider, new ChartChildWindowManager());
         this._ChartManager = chartManager;
         iExchange4.Chart.SilverlightExtensionToolbar.Toolbar toolbar = new iExchange4.Chart.SilverlightExtensionToolbar.Toolbar(this._ChartManager);
         ChartPanel chartPanel = this._ChartManager.CreateChartPanel(null, Frequency.Minute);
         this.Chart.Content = chartPanel;
         toolbar.ChartPanel = chartPanel;
         chartPanel.RefreshChart(false);
         //this._ChartManager.RefreshBar(Guid.Parse("AF10D803-F811-45D1-A0E3-DDB5BAD79FF1"), DateTime.Now);
     }
     catch (Exception ex)
     {
         HtmlPage.Window.Invoke("WriteLog", ex.ToString());
     }
 }
示例#16
0
        public async Task Ema_MA_Success()
        {
            // Arrange
            var loggerMock = Mock.Of <ILogger <CsvLoader> >();
            var parser     = new CsvLoader(loggerMock);
            var fileH1     = Path.Combine(Directory.GetCurrentDirectory(), "RTS-12.20_H1.csv");
            var bars       = await parser.LoadBars(fileH1);

            var chartManager = new ChartManager(bars);

            chartManager.Finish();
            var ema = new MovingAverage(chartManager.Chart, 50);

            // Act
            var emaValues = ema.EmaValue();


            // Assert
            bars.Should().NotBeEmpty();
            bars.Should().HaveCount(863);
        }
示例#17
0
    void Awake()
    {
        instance = this;

        if (SongPlateManager.selectedSong != null)
        {
            fileName = SongPlateManager.selectedSong.getChartDataPath(SongPlateManager.selectedDifficulty);
        }
        print(fileName);


        for (int i = 1; i <= 5; i++)
        {
            nodeCreators.Add(GameObject.Find("NodeLine" + i + "/NodeCreator").GetComponent <NodeCreator>());
        }

        foreach (NodeCreator creator in nodeCreators)
        {
            creator.fileName = fileName;
        }
        print("Manager Done");
    }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="parentControl">父容器</param>
        /// <param name="seriesNames">示波器各序列名</param>
        /// <param name="sampleFrequency">绘制曲线颜色</param>
        /// <param name="titleColor">绘制曲线颜色</param>
        /// <param name="chartManager"> 内置图表的的chartManager(可空)</param>
        public WaveformMonitor(
            Panel parentControl,
            string[] seriesNames,
            double sampleFrequency,
            Color titleColor,
            ChartManager chartManager
            )
        {
            _samplingFrequency = sampleFrequency;
            _parentControl     = parentControl;

            _chart                     = new LightningChartUltimate();
            _chart.ChartName           = "Waveform chart";
            _chart.ViewXY.XAxes        = ViewXY.CreateDefaultXAxes();
            _chart.ViewXY.YAxes        = ViewXY.CreateDefaultYAxes();
            _chart.VerticalAlignment   = VerticalAlignment.Top;
            _chart.HorizontalAlignment = HorizontalAlignment.Left;

            _chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked;
            _chart.ViewXY.AxisLayout.SegmentsGap = 10;

            parentControl.Children.Add(_chart);

            _chart.BeginUpdate();
            _chart.ChartManager = chartManager;

            _chart.ViewXY.AxisLayout.AutoAdjustMargins = false;

            _chart.ViewXY.DropOldSeriesData          = true;
            _chart.ChartRenderOptions.AntiAliasLevel = 0; // Disable hw anti-aliasing.

            AxisX axisX = _chart.ViewXY.XAxes[0];

            axisX.Maximum                   = 10;
            axisX.SweepingGap               = 2;
            axisX.ScrollMode                = XAxisScrollMode.Scrolling;
            axisX.Title.Text                = "Range";
            axisX.Title.VerticalAlign       = XAxisTitleAlignmentVertical.Top;
            axisX.Title.HorizontalAlign     = XAxisTitleAlignmentHorizontal.Right;
            axisX.LabelsPosition            = Alignment.Near;
            axisX.LabelsFont                = new WpfFont("Segoe UI", 11, true, false);
            axisX.MajorDivTickStyle.Visible = false;
            axisX.MinorDivTickStyle.Visible = false;
            axisX.MajorGrid.Visible         = false;
            axisX.MinorGrid.Visible         = false;
            axisX.LabelsVisible             = false;
            axisX.SteppingInterval          = 1;
            axisX.MouseScaling              = false;
            axisX.MouseScrolling            = false;
            axisX.AxisThickness             = 1;

            //AxisY axisY = _chart.ViewXY.YAxes[0];
            //axisY.SetRange(-30000, 30000);
            //axisY.Title.Visible = false;
            //axisY.LabelsFont = new WpfFont("Segoe UI", 11, true, false);

            _chart.ViewXY.GraphBackground.GradientDirection = 270;
            _chart.ViewXY.GraphBackground.GradientFill      = GradientFill.Cylindrical;

            Color color = _chart.ViewXY.GraphBackground.Color;

            _chart.ViewXY.GraphBackground.Color = Color.FromArgb(150, color.R, color.G, color.B);

            _chart.Title.Font = new WpfFont("Segoe UI", 14, true, false);

            _chart.Title.Align = ChartTitleAlignment.TopCenter;
            _chart.Title.Offset.SetValues(0, 25);
            _chart.Title.Color = titleColor;

            _chart.ViewXY.Margins = new Thickness(70, 10, 15, 10);
            _chart.ViewXY.ZoomPanOptions.ZoomRectLine.Color = Colors.Lime;

            _chart.ChartBackground.Color             = ChartTools.CalcGradient(titleColor, Colors.Black, 65);
            _chart.ChartBackground.GradientDirection = 0;
            _chart.ChartBackground.GradientFill      = GradientFill.Cylindrical;

            //清除之前的y轴与数据序列
            DisposeAllAndClear(_chart.ViewXY.YAxes);
            DisposeAllAndClear(_chart.ViewXY.SampleDataSeries);
            //添加多序列的y轴属性
            for (int index = 0; index < seriesNames.Count(); index++)
            {
                AxisY axisY = new AxisY(_chart.ViewXY);
                axisY.SetRange(-30000, 30000);
                axisY.Title.Font    = new WpfFont("Segoe UI", 10, false, false);
                axisY.Title.Text    = string.Format(seriesNames[index]);
                axisY.Title.Angle   = 0;
                axisY.Units.Visible = false;
                //axisY.Title.Visible = false;
                axisY.LabelsFont = new WpfFont("Segoe UI", 11, true, false);
                _chart.ViewXY.YAxes.Add(axisY);

                //Add SampleDataSeries
                SampleDataSeries sds = new SampleDataSeries(_chart.ViewXY, axisX, axisY);
                _chart.ViewXY.SampleDataSeries.Add(sds);
                sds.SampleFormat              = SampleFormat.DoubleFloat;
                sds.LineStyle.Color           = DefaultColors.SeriesForBlackBackgroundWpf[index % DefaultColors.SeriesForBlackBackgroundWpf.Length];
                sds.SamplingFrequency         = _samplingFrequency;
                sds.FirstSampleTimeStamp      = 1.0 / _samplingFrequency;
                sds.LineStyle.Width           = 1f;
                sds.LineStyle.AntiAliasing    = LineAntialias.None;
                sds.ScrollModePointsKeepLevel = 1;
                sds.ScrollingStabilizing      = true;
                sds.MouseInteraction          = false;



                //Add the line as a zero level
                ConstantLine cls = new ConstantLine(_chart.ViewXY, axisX, axisY);
                cls.Title.Text       = "Constant line";
                cls.Title.Visible    = false;
                cls.LineStyle.Color  = Colors.BlueViolet;
                cls.Behind           = true;
                cls.LineStyle.Width  = 2;
                cls.MouseInteraction = false;
                cls.Value            = 0;
                _chart.ViewXY.ConstantLines.Add(cls);
            }

            //LineSeriesCursor cursor1 = new LineSeriesCursor(_chart.ViewXY, axisX);
            //cursor1.ValueAtXAxis = 1;
            //cursor1.LineStyle.Width = 6;

            //color = Colors.OrangeRed;
            //cursor1.LineStyle.Color = Color.FromArgb(180, color.R, color.G, color.B);

            //cursor1.FullHeight = true;
            //cursor1.SnapToPoints = true;
            //cursor1.Style = CursorStyle.PointTracking;
            //cursor1.TrackPoint.Color1 = Colors.Yellow;
            //cursor1.TrackPoint.Color2 = Colors.Transparent;
            //cursor1.TrackPoint.Shape = Shape.Circle;
            //_chart.ViewXY.LineSeriesCursors.Add(cursor1);

            _chart.EndUpdate();
        }
示例#19
0
 public ChartController(ChartManager manager)
 {
     this.manager = manager;
 }
        public HomeController()
        {
            UnitOfWorkManager unitOfWorkManager = new UnitOfWorkManager();

            chartManager = new ChartManager(unitOfWorkManager);
        }
示例#21
0
 void Start()
 {
     // local ref to chart manager
       _cm = GetComponent<ChartManager>();
 }
        public IActionResult Get()
        {
            var timerManager = new TimerManager(() => _hub.Clients.All.SendAsync("transferchartdata", ChartManager.GetData()));

            return(Ok(new { Message = "Request Completed" }));
        }
示例#23
0
        public APIDataModel Get(
            string request,
            string keyword = "",
            int runningAvg = 0,
            int interval   = 0,
            long sinceID   = 0,
            string id      = "",
            string unit    = "",
            string date    = "",
            string source  = ""
            )
        {
            int          keyID = -1;
            APIDataModel data  = new APIDataModel();

            if (request == "TOTAL")
            {
                if (runningAvg > 1)
                {
                    d = ChartManager.collectAverages(keyword, runningAvg);
                }
                else
                {
                    data          = ChartManager.CollectRawValues(keyword);
                    data.chartDiv = data.keyword.Replace(" ", String.Empty) + "ChartDiv";
                }
            }
            else if (request == "FIVE_MINUTES")
            {
                keyID = DatabaseAccessLayer.Instance.GetKeywordID(keyword);
                data  = DatabaseAccessLayer.Instance.Get5Min(keyID);
            }

            else if (request == "USER_INFO")
            {
                data.keywords    = AccountManager.GetUserKeywords(Guid.Parse(id));
                data.accounts    = new Account[1];
                data.accounts[0] = AccountManager.GetAccountInfo(Guid.Parse(id));
            }
            else if (request == "USER_LIST")
            {
                data.accounts = AccountManager.GetAccounts().ToArray();
            }
            else if (request == "CLASSIFY_SENTIMENT")
            {
                data.ourSentiment   = SentimentClassificationService.Instance.Classify(keyword);
                data.viralSentiment = "none";//json["mood"];
            }
            else if (request == "GET_ANNOTATIONS")
            {
                data = DatabaseAccessLayer.Instance.GetAnnotations(keyword);
            }
            else if (request == "TIME_RANGE")
            {
                keyID = DatabaseAccessLayer.Instance.GetKeywordID(keyword);
                if (unit == "5min")
                {
                    data = DatabaseAccessLayer.Instance.Get5Min(keyID);
                }
                else if (unit == "1min")
                {
                    d = DatabaseAccessLayer.Instance.GetLastMinute(keyID);
                }
                else if (unit == "10sec")
                {
                    data = DatabaseAccessLayer.Instance.GetTenSeconds(keyID, source);
                }
                else
                {
                    data = DatabaseAccessLayer.Instance.GetTimeRange(keyID, unit);
                    if (data.dates.Count() > 0)
                    {
                        data.sentimentList = DatabaseAccessLayer.Instance.GetHistoryPage(keyword, 0, DateTime.Parse(data.dates[0])).sentimentList;
                    }
                }
            }
            else if (request == "PAGE")
            {
                data = DatabaseAccessLayer.Instance.GetHistoryPage(keyword, interval - 1, DateTime.Parse(date));
            }
            else if (request == "DAY_VALUES")
            {
                data = DatabaseAccessLayer.Instance.GetDayValues(keyword, DateTime.Parse(date));
            }
            else if (request == "WIDGET")
            {
                data = DatabaseAccessLayer.Instance.GetWidgetData(keyword);
            }

            return(data);
        }
示例#24
0
        static void Main(string[] args)
        {
            if (GlobalVariables.ParseCommands(args) == false)
            {
                return;
            }

            if (GlobalVariables.BuildStarDatabase == true)
            {
                StarCatalog.BuildPPMCatalog(GlobalVariables.PPMCatalogSource);
                StarCatalog.BuildVSXCatalog(GlobalVariables.VSXCatalogSource);
                return;
            }

            using (var db = new StarCatalogContext())
            {
                if (GlobalVariables.LoadFrames == true)
                {
                    FrameManager.GetFrameInfo(GlobalVariables.InputDirectory, db);
                    return;
                }

                if (GlobalVariables.LoadResults == true)
                {
                    string chartname =
                        new ChartManager().LoadChart(GlobalVariables.InputDirectory, db);

                    new SampleManager().LoadStarField(GlobalVariables.InputDirectory, chartname, db);

                    return;
                }

                var field = StarField.LoadStarField(GlobalVariables.Chart, db);

                // Apply quality filter.
                field.Stars = field.Stars.OrderByDescending(x => x.AvgInstrumentalMag).Where(x => x.MinSNR > GlobalVariables.MinSNR && x.Flags < 16).ToList();

                field.DoPhotometricReduction();

                // Output results
                StringBuilder candidates = new StringBuilder();
                candidates.AppendLine(String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", "Star", "RMag", "C-VMag", "C-VMag-E", "VMag", "C-ColorIndex", "ColorIndex", "Label", "Known Variable", "Uncertainty", "Score", "Flags", "URL"));

                StringBuilder timeseries = new StringBuilder();
                timeseries.AppendLine(String.Format("{0},{1},{2},{3},{4},{5}", "Score", "Star", "ObsDate", "VMag", "TFAMag", "Uncertainty"));

                StringBuilder aavsolog = new StringBuilder();

                aavsolog.AppendLine("#TYPE=EXTENDED");
                aavsolog.AppendLine("#OBSCODE=" + GlobalVariables.ObsCode);
                aavsolog.AppendLine("#SOFTWARE=VSA V" + Assembly.GetEntryAssembly().GetName().Version);
                aavsolog.AppendLine("#DELIM=,");
                aavsolog.AppendLine("#DATE=JD");
                aavsolog.AppendLine("#OBSTYPE=DSLR");
                aavsolog.AppendLine("#NAME,DATE,MAG,MERR,FILT,TRANS,MTYPE,CNAME,CMAG,KNAME,KMAG,AMASS,GROUP,CHART,NOTES");

                Console.WriteLine("Outputing results.");
                foreach (Star star in field.Stars)
                {
                    D_VSXEntry entry = StarCatalog.GetVSXEntry((double)star.RA, (double)star.DEC);

                    string variabletype = "";
                    if (entry != null && entry.VFlag < 2)
                    {
                        Console.WriteLine("Found variable star: " + entry.Name);
                        variabletype = "http://www.aavso.org/vsx/index.php?view=detail.top&oid=" + entry.OID.Trim();

                        string ensemble = "Custom ensemble of " + (star.Comparables.Count() - 1).ToString() + " due to low chart count.";
                        if (field.ChartComparables.Count > 1)
                        {
                            ensemble = field.ChartComparables[1].Label;
                            for (int f = 2; f < field.ChartComparables.Count; f++)
                            {
                                ensemble += "/" + field.ChartComparables[f].Label;
                            }
                        }

                        // Query to get auid.
                        string auid = StarCatalog.GetAUID(entry);

                        if (auid != null)
                        {
                            aavsolog.AppendLine(String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}",
                                                              auid,
                                                              Math.Round(field.Frames[0].Time, 4),
                                                              Math.Round(star.VMag, 3).ToString().PadLeft(7, ' '),
                                                              Math.Round(star.e_VMag, 3),
                                                              "V",
                                                              "YES",
                                                              "STD",
                                                              "ENSEMBLE",
                                                              "na",
                                                              field.ChartComparables[0].Label.Replace("[CHECK]", "").Trim(),
                                                              Math.Round(field.ChartComparables[0].VMag, 3).ToString().PadLeft(7, ' '),
                                                              "na",
                                                              "na",
                                                              field.Frames[0].Chart,
                                                              String.Format("MAG=avg {0} img|MERR=StdDe|ENSEMBLE={1}", star.Samples.Count(), ensemble)));
                        }
                    }

                    string label = "";
                    if (field.ChartComparables.Contains(star))
                    {
                        label = star.Label;
                    }

                    candidates.Append(String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}",
                                                    star.Name,
                                                    star.CatalogEntry.Rmag,
                                                    star.VMag,
                                                    star.e_VMag,
                                                    star.CatalogEntry.Vmag,
                                                    star.CalculatedColorIndex,
                                                    star.ColorIndex,
                                                    label,
                                                    variabletype,
                                                    star.EnsembleError,
                                                    star.Score,
                                                    Convert.ToString(star.Flags, 2).PadLeft(5, '0')));

                    // Output the calculated differential magnitude with the comparable star.
                    int i = 0;
                    foreach (SampleData sample in star.Samples)
                    {
                        timeseries.AppendLine(String.Format("{0},{1},{2},{3},{4},{5}", star.Score, star.Name, field.Frames[i].Time, sample.ApparentVMag - star.VMag, sample.TFAVMag - star.VMag, sample.Uncertainty));
                        i++;
                    }
                    candidates.Append(String.Format(",http://simbad.u-strasbg.fr/simbad/sim-coo?Coord={0}%20{1}%20{2}%20{3}%20{4}%20{5}&Radius=2&Radius.unit=arcsec&",
                                                    star.Name.Substring(0, 2), star.Name.Substring(2, 2), star.Name.Substring(4, 4), star.Name.Substring(8, 3), star.Name.Substring(11, 2), star.Name.Substring(13, 2)));
                    candidates.AppendLine();
                }
                File.WriteAllText(GlobalVariables.GetOutput(".\\AAVSO\\" + field.Frames[0].Chart + ".txt"), aavsolog.ToString());
                File.WriteAllText(GlobalVariables.GetOutput(".\\candidates_out.csv"), candidates.ToString());
                File.WriteAllText(GlobalVariables.GetOutput(".\\timeseries_out.csv"), timeseries.ToString());
            }
        }
示例#25
0
        public void Post(
            string request,
            string userID      = "",
            string UserID      = "",
            string companyName = "",
            string phoneNumber = "",
            string email       = "",
            string address1    = "",
            string address2    = "",
            string address3    = "",
            string city        = "",
            string state       = "",
            string zip         = "",
            string keyword     = "",
            string title       = "",
            string caption     = "",
            string date        = ""
            )
        {
            if (request == "UPDATE_ADDRESS")
            {
                Account account = new Account(Guid.Parse(userID));
                account.companyName = companyName;
                account.phoneNumber = phoneNumber;
                account.email       = email;
                account.address1    = address1;
                account.address2    = address2;
                account.address3    = address3;
                account.city        = city;
                account.state       = state;
                account.zip         = zip;
                account.FixNullParams();
                //account.country = country;
                //account.apartmentNum = apartmentNum;
                AccountManager.UpdateAccountInfo(account);
            }
            if (request == "ADD_KEYWORD")
            {
                TextInfo txtInfo = new CultureInfo("en-US", false).TextInfo;
                keyword = txtInfo.ToTitleCase(keyword);
                AccountManager.AssignKeyword(Guid.Parse(UserID), keyword);
                DataCollector.Instance.AddKeyword(keyword);
            }
            else if (request == "REMOVE_KEYWORD")
            {
                AccountManager.UnAssignKeyword(Guid.Parse(UserID), keyword);
                DataCollector.Instance.RemoveKeyword(keyword);
            }
            else if (request == "DELETE_ANNOTATION")
            {
                DatabaseAccessLayer.Instance.DeleteAnnotation(int.Parse(UserID));
            }
            else if (request == "INSERT_ANNOTATION")
            {
                ChartManager.InsertAnnotation(keyword, title, caption, date);
            }

            else if (User.Identity.IsAuthenticated && User.Identity.Name == "Administrator")
            {
                if (request == "DISABLE_KEY")
                {
                    ChartManager.DisableKeyword(keyword);
                }
                else if (request == "ENABLE_KEY")
                {
                    ChartManager.EnableKeyword(keyword);
                }
                else if (request == "DISABLE_ACCOUNT")
                {
                    AccountManager.DisableAccount(Guid.Parse(keyword));
                }
                else if (request == "ENABLE_ACCOUNT")
                {
                    AccountManager.EnableAccount(Guid.Parse(keyword));
                }
            }
        }
示例#26
0
 public ReportController(ChartManager manager)
 {
     chartManager = manager;
 }
示例#27
0
        public ICollection <ModelForCharts> GetVelocity()
        {
            ChartManager manager = new ChartManager(_sprints, _stories);

            return(_chartManager.GetDataVelocity());
        }
 public CrossMovingAveragePattern(ChartManager chartManager, string vixPath, string outputPath, DateTime startDate, DateTime endDate
                                  ) : base(chartManager, startDate, endDate, vixPath, null, outputPath, null)
 {
 }
        public async Task Run()
        {
            Console.WriteLine("Updating VIX and SPX data");
            await ApplyUpdates(true, false);

            Console.WriteLine("Loading VIX file");
            vixPrices = CSVProcessor.ProcessVIXFile(VIXPath);

            Console.WriteLine("Connecting to alpaca trading API");
            alpacaTradingClient = Environments.Paper.GetAlpacaTradingClient(API_KEY, new SecretKey(API_SECRET));

            Console.WriteLine("Connecting to alpaca data API");
            alpacaDataClient = Environments.Paper.GetAlpacaDataClient(API_KEY, new SecretKey(API_SECRET));

            Console.WriteLine("Getting Market Calendars");
            var calendars = (await alpacaTradingClient.ListCalendarAsync(StartDate, EndDate)).ToList();

            Console.WriteLine("Writing header line in output file");
            using (StreamWriter w = File.CreateText(OutputPath))
            {
                w.WriteLine("Symbol, Date, StartTime, EndTime, PatternAlgFound, PatternVisFound, PosOpenTime, PosCloseTime, PosLong, PosReturn");
            }

            foreach (var calDate in calendars)
            {
                List <DateTime> startTimes     = new List <DateTime>();
                DateTime        loopTime       = calDate.TradingOpenTime.AddMinutes(15);
                TimeSpan        timeUntilClose = calDate.TradingCloseTime.Subtract(loopTime);
                while (timeUntilClose.TotalMinutes >= 30)
                {
                    startTimes.Add(loopTime);
                    loopTime       = loopTime.Add(new TimeSpan(0, 30, 0));
                    timeUntilClose = calDate.TradingCloseTime.Subtract(loopTime);
                }

                // High volatility only.
                if (!vixPrices.ContainsKey(calDate.TradingDate.ToString("yyyy-MM-dd")))
                {
                    continue;
                }
                if (vixPrices[calDate.TradingDate.ToString("yyyy-MM-dd")].Open < 28)
                {
                    continue;
                }

                foreach (DateTime dateTime in startTimes)
                {
                    var barSet = (await alpacaDataClient.GetBarSetAsync(symbols, TimeFrame.Minute, 60, true, dateTime.Subtract(TimeSpan.FromMinutes(14)), calDate.TradingCloseTime));


                    foreach (string sym in symbols)
                    {
                        if (!barSet.ContainsKey(sym))
                        {
                            continue;
                        }
                        var bars = barSet[sym].ToList();
                        // Pattern matching algorithm:
                        if (bars.Count < 44)
                        {
                            continue;
                        }

                        int  istr    = 14;
                        int  endtime = 14;
                        bool gr      = false;
                        bool found   = false;

                        for (int i = 14; i < 44; i++)
                        {
                            var price = bars[i];
                            if (price.Close - price.Open > 0)
                            {
                                if (gr)
                                {
                                    continue;
                                }

                                if (i - istr >= 4)
                                {
                                    found   = true;
                                    endtime = i;
                                    break;
                                }

                                istr = i;
                                gr   = true;
                            }
                            else
                            {
                                if (!gr)
                                {
                                    continue;
                                }

                                if (i - istr >= 6)
                                {
                                    found   = true;
                                    endtime = i;
                                    break;
                                }

                                istr = i;
                                gr   = false;
                            }
                        }

                        if (!found)
                        {
                            continue;
                        }

                        bool lng = !gr;

                        decimal entPrice = bars[endtime].Close;
                        decimal exPrice  = bars[43].Close;

                        decimal profit = lng ? exPrice - entPrice : entPrice - exPrice;
                        decimal pct    = profit / entPrice;

                        // End of Algorithm - Should be a pattern match now

                        List <PriceData> prices = new List <PriceData>();
                        for (int i = 0; i < 30; i++)
                        {
                            var price = bars[i + 14];
                            prices.Add(new PriceData(price.Time.ToString("HH:mm"), i, price.Open, price.Close, price.High, price.Low));
                        }

                        AlgoResult match = new AlgoResult(prices, sym, dateTime, dateTime.AddMinutes(30), true, res => {
                            //WriteToOutput(res);
                        }, dateTime.AddMinutes(14 + endtime), dateTime.AddMinutes(44), lng, pct);

                        ChartManager.SendToChartQueue(match);
                        match.PatternVisFound = true;
                        WriteToOutput(match);
                    }
                }
            }
            ChartManager.DoneProcessing();
        }