Example #1
0
        internal static SelectableCollection <ISelectable> GetAssetTypes()
        {
            var list = new SelectableCollection <ISelectable>();

            var assetClasses = (AssetClass[])Enum.GetValues(typeof(AssetClass));

            foreach (var assetClass in assetClasses)
            {
                list.AddSelectable(new AssetType(assetClass)
                {
                    IsSelected = true
                });
            }

            return(list);
        }
Example #2
0
        internal static SelectableCollection <ISelectable> GetDays()
        {
            var list = new SelectableCollection <ISelectable>();

            var days = (DayOfWeek[])Enum.GetValues(typeof(DayOfWeek));

            foreach (var day in days)
            {
                list.AddSelectable(new Day(day)
                {
                    IsSelected = true
                });
            }

            return(list);
        }
Example #3
0
        internal static SelectableCollection <IMarket> GetDefaultMarkets()
        {
            var collection = new SelectableCollection <IMarket>();

            try
            {
                var connection = new SqlConnection(DataConnection.Builder.ConnectionString);
                connection.Open();

                const string sql = "SELECT * From Market;";

                using (var cmd = new SqlCommand(sql, connection))
                {
                    var reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            var assetClass = (AssetClass)Enum.Parse(typeof(AssetClass), reader.GetFieldValue <string>(2));
                            var pipDivisor = (PipDivisor)Enum.Parse(typeof(PipDivisor), reader.GetFieldValue <string>(3));
                            collection.AddSelectable(new Market(reader.GetFieldValue <string>(1), assetClass, pipDivisor)
                            {
                                Id = reader.GetFieldValue <int>(0), IsSelected = true
                            });
                        }
                    }
                }

                connection.Close();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.ToString());
            }

            return(collection);
        }
Example #4
0
        internal static SelectableCollection <ISelectableTradeField> GetDefaultStrategies()
        {
            var collection = new SelectableCollection <ISelectableTradeField>();

            try
            {
                var connection = new SqlConnection(DataConnection.Builder.ConnectionString);
                connection.Open();

                const string sql = "SELECT * From Strategy;";

                using (var cmd = new SqlCommand(sql, connection))
                {
                    var reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            collection.AddSelectable(new Strategy(reader.GetFieldValue <string>(1))
                            {
                                Id = reader.GetFieldValue <int>(0), IsSelected = true
                            });
                        }
                    }
                }

                connection.Close();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.ToString());
            }

            return(collection);
        }