예제 #1
0
        public static StrategyInfo GetStrategyInfoFromAlias(string alias, MySqlConnection conn)
        {
            StrategyInfo StrategyInfoOut = new StrategyInfo();

            string query = "SELECT * FROM strategy WHERE alias=\"" + alias + "\"";

            MySqlDataReader reader = null;
            MySqlCommand    cmd    = null;

            try
            {
                cmd    = new MySqlCommand(query, conn);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    StrategyInfoOut.Id        = reader.GetInt32("id");
                    StrategyInfoOut.OpenDate  = reader.GetDateTime("open_date");
                    StrategyInfoOut.CloseDate = reader.GetDateTime("close_date");

                    int PnlIndex = reader.GetOrdinal("pnl");

                    StrategyInfoOut.Pnl = reader.IsDBNull(PnlIndex) ? Double.NaN : reader.GetDouble("pnl");

                    StrategyInfoOut.CreatedDate       = reader.GetDateTime("created_date");
                    StrategyInfoOut.LastUpdatedDate   = reader.GetDateTime("last_updated_date");
                    StrategyInfoOut.DescriptionString = reader.GetString("description_string");
                }
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(StrategyInfoOut);
        }
예제 #2
0
        public static StrategyInfo GetStrategyInfoFromAlias(string alias, MySqlConnection conn)
        {
            StrategyInfo StrategyInfoOut = new StrategyInfo();

            string query = "SELECT * FROM strategy WHERE alias=\"" + alias + "\"";

            MySqlDataReader reader = null;
            MySqlCommand cmd = null;

            try
            {
                cmd = new MySqlCommand(query, conn);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    StrategyInfoOut.Id = reader.GetInt32("id");
                    StrategyInfoOut.OpenDate = reader.GetDateTime("open_date");
                    StrategyInfoOut.CloseDate = reader.GetDateTime("close_date");

                    int PnlIndex = reader.GetOrdinal("pnl");

                    StrategyInfoOut.Pnl = reader.IsDBNull(PnlIndex) ? Double.NaN : reader.GetDouble("pnl");

                    StrategyInfoOut.CreatedDate = reader.GetDateTime("created_date");
                    StrategyInfoOut.LastUpdatedDate = reader.GetDateTime("last_updated_date");
                    StrategyInfoOut.DescriptionString = reader.GetString("description_string");
                }
            }

            finally
            {
                if (reader != null) reader.Close();
            }
            return StrategyInfoOut;
        }
예제 #3
0
        public static bool CheckIfStrategyExist(string alias, MySqlConnection conn)
        {
            StrategyInfo Si = GetStrategyInfoFromAlias(alias: alias, conn: conn);

            return(!(Si.OpenDate == DateTime.MinValue));
        }