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); } }
/// <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); }
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"); } }
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"); }
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); } }
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); } }
public void InsertGeneral(string comment, string ticker) { InsertGeneral(ServerTime.GetRealTime(), comment, ticker); }
public Bar() { StartTime = ServerTime.GetRealTime(); Ticks = new List <Contract>(); }
public bool IsEveningPause() { DateTime dTime = ServerTime.GetRealTime(); return(dTime.Hour == 18 && dTime.Minute >= 45 || (dTime.Hour == 19 && dTime.Minute == 0)); }
private void PingTimer_Elapsed(object sender, ElapsedEventArgs e) { dbWriter.InsertSts(ServerTime.GetRealTime(), "Stocks", "Working"); }
public bool IsNowEveningTradeTime() { DateTime dTime = ServerTime.GetRealTime(); return((dTime.Hour >= 19 && dTime.Hour < 23) || (dTime.Hour == 23 && dTime.Minute < 50)); }
public bool IsNowDayTradeTime() { DateTime dTime = ServerTime.GetRealTime(); return((dTime.Hour >= 10 && dTime.Hour < 18) || (dTime.Hour == 18 && dTime.Minute < 45)); }
public bool IsNowNightTime() { DateTime dTime = ServerTime.GetRealTime(); return(dTime.Hour <= 8 && dTime.Hour >= 0); }
public bool IsNowTradeTime() { DateTime dTime = ServerTime.GetRealTime(); return(IsNowDayTradeTime() || IsNowEveningTradeTime()); }
private void WriteToLog(string message, params object[] args) { Logger.WriteLine(LogPath, LogName, ServerTime.GetRealTime().ToString(LogDateTimeFormat) + " | " + message, args); }
/// <summary> /// Проверяет, является ли текущий момент времени концом торгового дня /// </summary> /// <returns>Возвращает true, если торговый день завершен</returns> private bool IsEndOfWork() { DateTime dTime = ServerTime.GetRealTime(); return(dTime.Hour < 10 || (dTime.Hour == 23 && dTime.Minute >= 50)); }