Ejemplo n.º 1
0
        private void ReportTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            List <StrategyAbst> strats = Server.GetInstance().GetStrategies();
            string heading             = "Robot Started - Report";
            string text = "";

            for (int i = 0; i < strats.Count; i++)
            {
                if (strats[i].GO <= 0)
                {
                    text += "Strategy " + strats[i].Name + " is not connected! User check is strongly advised.\r\n";
                }
                else if (strats[i].GO > 0)
                {
                    text += "Strategy " + strats[i].Name + " is connected.\r\n";
                }
            }
            text = "Report\r\n" + text;
            DateTime thisTime = ServerTime.GetRealTime();

            if (thisTime.Hour < 11)
            {
                EmailSender.SendEmail(heading, text);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Отправляет на почту отчет об успешности завершения торгового дня
        /// </summary>
        private void SendReport()
        {
            string title   = "End of Trading Day - " + ServerTime.GetRealTime().ToShortDateString();
            string message = "Day successfully closed.\r\n";

            foreach (StrategyAbst strat in GetInstance().GetStrategies())
            {
                message += strat.ToString() + "***********************\r\n\r\n";
            }
            EmailSender.SendEmail(title, message);
        }
Ejemplo n.º 3
0
 public void WriteToStatus(string message)
 {
     if (infoTextBox.InvokeRequired)
     {
         WriteToStatusDelegate d = new WriteToStatusDelegate(WriteToStatus);
         Invoke(d, new object[] { message });
     }
     else
     {
         infoTextBox.AppendText(ServerTime.GetRealTime() + ": " + message + "\n");
     }
 }
Ejemplo n.º 4
0
 private Server(string login, string password, MainForm form)
 {
     //Login = login;
     //Password = password;
     Form         = form;
     Logger       = new LogWriter(LogPath, LogName);
     dbWriter     = new DBInputOutput.DBWriter();
     dbReader     = new DBInputOutput.DBReader();
     Strategies   = new List <StrategyAbst>();
     Collector    = new DataCollector();
     WasConnected = false;
     dbWriter.InsertSts(ServerTime.GetRealTime(), "Stocks", "Working");
 }
Ejemplo n.º 5
0
 public double SelectGOById(int tickerId)
 {
     try
     {
         MySqlCommand selectCommand = DatabaseConnection.CreateCommand();
         selectCommand.CommandText = SelectGOBuyByTickerId;
         selectCommand.Parameters.AddWithValue("?assetid", tickerId);
         selectCommand.Parameters.AddWithValue("?dtime", ServerTime.GetRealTime().ToString("yyyy-MM-dd"));
         double goBuy = -1;
         using (MySqlDataReader reader = selectCommand.ExecuteReader())
         {
             while (reader.Read())
             {
                 goBuy = reader.GetDouble("val");
             }
             reader.Close();
         }
         double goSell = -1;
         if (goBuy > 0)
         {
             selectCommand             = DatabaseConnection.CreateCommand();
             selectCommand.CommandText = SelectGOSellByTickerId;
             selectCommand.Parameters.AddWithValue("?assetid", tickerId);
             selectCommand.Parameters.AddWithValue("?dtime", ServerTime.GetRealTime().ToString("yyyy-MM-dd"));
             goSell = -1;
             using (MySqlDataReader reader = selectCommand.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     goSell = reader.GetDouble("val");
                 }
                 reader.Close();
             }
         }
         return((goBuy + goSell) / 2);
     }
     catch (Exception e)
     {
         throw new SmartException(e);
     }
 }
Ejemplo n.º 6
0
 public bool IsInfoNeedsToBeInsertedToday(int tickerId)
 {
     try
     {
         MySqlCommand selectCommand = DatabaseConnection.CreateCommand();
         selectCommand.CommandText = SelectInfoDate;
         selectCommand.Parameters.AddWithValue("?assetid", tickerId);
         DateTime res = DateTime.MinValue;
         using (MySqlDataReader reader = selectCommand.ExecuteReader())
         {
             while (reader.Read())
             {
                 res = reader.GetDateTime("date");
             }
             reader.Close();
         }
         DateTime today = ServerTime.GetRealTime();
         return(!((res.Day == today.Day) && (res.Month == today.Month) && (res.Year == today.Year)));
     }
     catch (Exception e)
     {
         throw new SmartException(e);
     }
 }
Ejemplo n.º 7
0
 public void InsertGeneral(string comment, string ticker)
 {
     InsertGeneral(ServerTime.GetRealTime(), comment, ticker);
 }
Ejemplo n.º 8
0
 public Bar()
 {
     StartTime = ServerTime.GetRealTime();
     Ticks     = new List <Contract>();
 }
Ejemplo n.º 9
0
        public bool IsEveningPause()
        {
            DateTime dTime = ServerTime.GetRealTime();

            return(dTime.Hour == 18 && dTime.Minute >= 45 || (dTime.Hour == 19 && dTime.Minute == 0));
        }
Ejemplo n.º 10
0
 private void PingTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     dbWriter.InsertSts(ServerTime.GetRealTime(), "Stocks", "Working");
 }
Ejemplo n.º 11
0
        public bool IsNowEveningTradeTime()
        {
            DateTime dTime = ServerTime.GetRealTime();

            return((dTime.Hour >= 19 && dTime.Hour < 23) || (dTime.Hour == 23 && dTime.Minute < 50));
        }
Ejemplo n.º 12
0
        public bool IsNowDayTradeTime()
        {
            DateTime dTime = ServerTime.GetRealTime();

            return((dTime.Hour >= 10 && dTime.Hour < 18) || (dTime.Hour == 18 && dTime.Minute < 45));
        }
Ejemplo n.º 13
0
        public bool IsNowNightTime()
        {
            DateTime dTime = ServerTime.GetRealTime();

            return(dTime.Hour <= 8 && dTime.Hour >= 0);
        }
Ejemplo n.º 14
0
        public bool IsNowTradeTime()
        {
            DateTime dTime = ServerTime.GetRealTime();

            return(IsNowDayTradeTime() || IsNowEveningTradeTime());
        }
Ejemplo n.º 15
0
 private void WriteToLog(string message, params object[] args)
 {
     Logger.WriteLine(LogPath, LogName, ServerTime.GetRealTime().ToString(LogDateTimeFormat) + " | " + message, args);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Проверяет, является ли текущий момент времени концом торгового дня
        /// </summary>
        /// <returns>Возвращает true, если торговый день завершен</returns>
        private bool IsEndOfWork()
        {
            DateTime dTime = ServerTime.GetRealTime();

            return(dTime.Hour < 10 || (dTime.Hour == 23 && dTime.Minute >= 50));
        }