Exemple #1
0
        private void iq5009_ConnectedEventHandler(object sender, EventArgs e)
        {
            htSymbols         = new Hashtable();
            htSymbolsNotFound = new Hashtable();

            db1 = new TradeDB();
            db1.Open();

            db2 = new TradeDB();
            db2.Open();

            InitFundamentalRecordHandling();

            cmdSelect = new SqlCommand(sSelect, db2.Connection);
            drSelect  = cmdSelect.ExecuteReader();

            iq5009.HandleFundamentalMessage += new FundamentalMessageHandler(iq5009_HandleFundamentalMessage);
            //iq5009.HandleSummaryMessage += new SummaryMessageHandler(iq5009_HandleSummaryMessage);
            //iq5009.HandleUpdateMessage += new UpdateMessageHandler(iq5009_HandleUpdateMessage);
            iq5009.HandleWatchSymbolNotFound += new WatchSymbolNotFoundHandler(iq5009_HandleWatchSymbolNotFound);

            //iq5009.HandleFAdd = new Buffer.LineHandler(processF);
            //iq5009.HandleQAdd = new Buffer.LineHandler(processQ);

            cnt   = 0;
            cntQ  = 0;
            bMore = true;
            while (cnt <= 200)
            {
                requestNextWatch();
            }
        }
Exemple #2
0
 void InitializeListBox() // добавление категорий
 {
     using (var db = new TradeDB())
     {
         var query = from b in db.Categories
                     select b;
         foreach (var item in query)
         {
             listBox1.Items.Add(item.CategoryName);
         }
     }
 }
Exemple #3
0
    public override void Init()
    {
        sb = base.StrategyBase;
        //mm = strat.MarketManager;
        //ms = sb.MetaStrategy;

        Console.WriteLine("Mode {0}", sb.MetaStrategyBase.MetaStrategyMode);

        TradeDB db = new TradeDB();

        db.Open();

        SqlCommand    cmd;
        SqlDataReader dr;
        //DateTime inc;
        Instrument instrument;
        string     sSymbol;

        string s = "select symbol from ToTrade"
                   + " where tradesystem = @tradesystem"
                   + " and sixmonpossd <  0.97 * sixmonposmean"
                   + " and sixmonnegsd < -0.97 * sixmonnegmean"
                   + " and daycl > 10"
                   + " and daycl < 125"
                   + " and sixmonposmean >  0.12"
                   + " and sixmonnegmean < -0.12"
                   + " order by symbol";

        cmd = new SqlCommand(s, db.Connection);
        cmd.Parameters.Add("@tradesystem", SqlDbType.VarChar);
        cmd.Parameters["@tradesystem"].Value = sTradeSystem;

        int cnt = 0;

        dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            cnt++;
            sSymbol    = dr.GetString(0);
            instrument = InstrumentManager.Instruments[sSymbol];
            AddInstrument(instrument);
            //Console.WriteLine( "{0}.MarketManager", sSymbol );
        }

        db.Close();
        //Console.WriteLine( "{0} symbols added.", cnt );
        //dtCurrentDay = new DateTime( 0 );
        //bRecordDayStartEquity = false;

        //Portfolio.CompositionChanged += new EventHandler(Portfolio_CompositionChanged);
        //Portfolio.ValueChanged += new PositionEventHandler(Portfolio_ValueChanged);
        //Portfolio.TransactionAdded += new TransactionEventHandler(Portfolio_TransactionAdded);
    }
Exemple #4
0
 void InitializeListBox()          // выводим все категории товаров
 {
     using (var db = new TradeDB())
     {
         var query = from b in db.Categories
                     select b;
         foreach (var item in query)
         {
             listBox1.Items.Add(item.CategoryName);
         }
     }
 }
Exemple #5
0
 internal static void updateforSupply(string prodName, int units, decimal price)
 {
     using (var db = new TradeDB())
     {
         var cust = db.Products.Where(x => x.ProductName == prodName).FirstOrDefault();
         cust.ProductName  = prodName;
         cust.UnitsInStock = cust.UnitsInStock + units;
         cust.PriceForSale = price * 1.2m;
         cust.UnitPrice    = price;
         // 4. Вызов метода SaveChanges
         db.SaveChanges();
     }
 }
Exemple #6
0
        private void button1_Click(object sender, EventArgs e)     // количество товара на складе
        {
            string s = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

            using (var db = new TradeDB())
            {
                var query = from b in db.Products
                            where b.ProductName == s
                            select b;
                foreach (var item in query)
                {
                    label4.Text = item.UnitsInStock.ToString();
                }
            }
        }
Exemple #7
0
        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)  //Цена за единицу товара
        {
            textBox1.Clear();
            string s = listBox2.SelectedItem.ToString();

            using (var db = new TradeDB())
            {
                var query = from b in db.Products
                            where b.ProductName == s
                            select b;
                foreach (var item in query)
                {
                    textBox2.Text = item.UnitPrice.ToString();
                }
            }
        }
Exemple #8
0
 internal static void addSupply(string name, DateTime supplydate, decimal price)
 {
     using (var db = new TradeDB())
     {
         Supply supply = new Supply
         {
             CompanyName = name,
             SupplyDate  = supplydate,
             TotalPrice  = price
         };
         // 3. Добавление сущностного объекта в таблицу Customers
         db.Supply.Add(supply);
         // 4. Вызов метода SaveChanges
         db.SaveChanges();
     }
 }
Exemple #9
0
        private void listBox2_SelectedIndexChanged(object sender, EventArgs e) // при выборе другой категории товара, обновляется список товаров в listBox2
        {
            textBox1.Clear();
            string s = listBox2.SelectedItem.ToString();

            using (var db = new TradeDB())
            {
                var query = from b in db.Products
                            where b.ProductName == s
                            select b;
                foreach (var item in query)
                {
                    textBox2.Text = item.PriceForSale.ToString();
                    label11.Text  = (item.UnitsInStock - item.UnitsOnOrder).ToString();
                }
            }
        }
Exemple #10
0
 internal static void addOrderDetails(string prodName, int units, decimal price, int id)
 {
     using (var db = new TradeDB())
     {
         OrderDetails ord = new OrderDetails
         {
             OrderID     = id,
             ProductName = prodName,
             Quantity    = (short)units,
             UnitPrice   = price
         };
         // 3. Добавление сущностного объекта в таблицу Customers
         db.OrderDetails.Add(ord);
         // 4. Вызов метода SaveChanges
         db.SaveChanges();
     }
 }
Exemple #11
0
 internal static void addOrder(string name, DateTime ordate, DateTime req, decimal price)
 {
     using (var db = new TradeDB())
     {
         Orders ord = new Orders
         {
             ShipName     = name,
             OrderDate    = ordate,
             RequiredDate = req,
             TotalPrice   = price
         };
         // 3. Добавление сущностного объекта в таблицу Customers
         db.Orders.Add(ord);
         // 4. Вызов метода SaveChanges
         db.SaveChanges();
     }
 }
Exemple #12
0
 private void button2_Click(object sender, EventArgs e)
 {
     dataGridView1.Rows.Clear();
     using (var db = new TradeDB())
     {
         var query = from b in db.Suppliers
                     select b;
         foreach (var item in query)
         {
             int n = dataGridView1.Rows.Add();
             dataGridView1.Rows[n].Cells[0].Value = item.SupplierID;
             dataGridView1.Rows[n].Cells[1].Value = item.CompanyName;
             dataGridView1.Rows[n].Cells[2].Value = item.ContactName;
             dataGridView1.Rows[n].Cells[3].Value = item.ContactTitle;
             dataGridView1.Rows[n].Cells[4].Value = item.Country;
         }
     }
 }
Exemple #13
0
 public async Task ElicitBuyOrSell()
 {
     if (build.TradeType == "market")
     {
         await PurchaseAtMarket();
     }
     else if (build.TradeType == "limit")
     {
         await PurchaseAtLimit();
     }
     else if (build.TradeType == "sell")
     {
         trade.Status = true;
         TradeDB tradeDB = new TradeDB();
         await tradeDB.UpdateAsync(trade);
         await ElicitConditions();
     }
 }
Exemple #14
0
        private void button4_Click(object sender, EventArgs e)  // принятие заказа
        {
            string   companyname = dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
            DateTime orderdate   = Convert.ToDateTime(dataGridView2.SelectedRows[0].Cells[1].Value);
            DateTime reqdate     = Convert.ToDateTime(dataGridView2.SelectedRows[0].Cells[2].Value);
            decimal  totalprice  = Convert.ToDecimal(dataGridView2.SelectedRows[0].Cells[3].Value);

            Orderr.addOrder(companyname, orderdate, reqdate, totalprice);
            Company.deposit(totalprice);
            label2.Text = Company.Capital.ToString();
            string f2 = Company.Capital.ToString();

            File.WriteAllText("E:\\company.txt", f2);
            int n = dataGridView1.Rows.Count;

            for (int i = 0; i < n; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value != null) // проверка условия ненулевой строки
                {
                    string  prodName = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    int     units    = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value);
                    decimal price    = Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value);

                    string   name   = dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
                    DateTime ordate = Convert.ToDateTime(dataGridView2.SelectedRows[0].Cells[1].Value);
                    Products.updProduct(prodName, units, price);
                    using (var db = new TradeDB())
                    {
                        var query = from b in db.Orders
                                    where b.OrderDate == ordate && b.ShipName == name
                                    select b;
                        foreach (var item in query)
                        {
                            int id = item.OrderID;
                            Orderr.addOrderDetails(prodName, units, price, id);
                        }
                    }
                }
            }
            dataGridView1.Rows.Clear();
            dataGridView2.Rows.Clear();
            File.Delete(path);
        }
Exemple #15
0
 public async Task InitializeTrade()
 {
     trade.CustomerId       = customer.Id;
     trade.BuyPrice         = build.Price;
     trade.TakeProfitPrice  = build.TakeProfitPrice;
     trade.StopLossPrice    = build.StopLossPrice;
     trade.Market           = build.Market;
     trade.Amount           = build.Amount;
     trade.Type             = build.TradeType;
     trade.AmountDecimal    = build.AmountDecimal;
     trade.BasePriceDecimal = build.BasePriceDecimal;
     trade.PriceDecimal     = build.AssetPriceDecimal;
     trade.IsStopLoss       = build.StopLoss;
     trade.IsTakeProfit     = build.TakeProfit;
     trade.IsTrailingStop   = build.TrailingStopLoss;
     trade.IsTrailingTake   = build.TrailingTakeProfit;
     TradeDB tradeDB = new TradeDB();
     await tradeDB.Add(trade);
 }
Exemple #16
0
 private async Task PurchaseAtLimit()
 {
     var limitBuy = Task.Run(async() => {
         Buy buy = new Buy(build, api);
         trade   = await buy.LimitAsync(trade, build.Price);
         if (trade.Success)
         {
             trade.LimitPending = true;
             trade.Status       = true;
             TradeDB tradeDB    = new TradeDB();
             await tradeDB.UpdateAsync(trade);
             bool filled = false;
             while (!filled)
             {
                 using (var client = new BinanceClient())
                 {
                     var orderStatus = await client.QueryOrderAsync(build.Market, trade.OrderId);
                     if (orderStatus.Success)
                     {
                         if (orderStatus.Data.Status == OrderStatus.Filled)
                         {
                             filled             = true;
                             trade.LimitPending = false;
                             await tradeDB.UpdateAsync(trade);
                             await ElicitConditions();
                         }
                         else if (orderStatus.Data.Status == OrderStatus.Canceled)
                         {
                             trade.Success = false;
                             trade.Status  = false;
                             await tradeDB.UpdateAsync(trade);
                             return;
                         }
                     }
                 }
                 System.Threading.Thread.Sleep(5000);
             }
             return;
         }
         // Add Error Notification
         return;
     });
 }
Exemple #17
0
        private void accept_button_Click(object sender, EventArgs e)   // одобрить поставку
        {
            string   companyname = dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
            DateTime supplydate  = Convert.ToDateTime(dataGridView2.SelectedRows[0].Cells[1].Value);
            decimal  totalprice  = Convert.ToDecimal(dataGridView2.SelectedRows[0].Cells[2].Value);

            Suppliess.addSupply(companyname, supplydate, totalprice);
            Company.withdrawal(totalprice);
            label2.Text = Company.Capital.ToString();
            string f2 = Company.Capital.ToString();

            File.WriteAllText("E:\\company.txt", f2);
            int n = dataGridView1.Rows.Count;

            for (int i = 0; i < n; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value != null)
                {
                    string  prodName = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    int     units    = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value);
                    decimal price    = Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value);

                    string   name      = dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
                    DateTime suppldate = Convert.ToDateTime(dataGridView2.SelectedRows[0].Cells[1].Value);
                    Products.updateforSupply(prodName, units, price);
                    using (var db = new TradeDB())
                    {
                        var query = from b in db.Supply
                                    where b.SupplyDate == suppldate && b.CompanyName == name
                                    select b;
                        foreach (var item in query)
                        {
                            int id = item.SupplyID;
                            Suppliess.addSupplyDetails(prodName, units, price, id);
                        }
                    }
                }
            }
            dataGridView1.Rows.Clear();
            dataGridView2.Rows.Clear();
            File.Delete(path);
        }
Exemple #18
0
        private async Task PurchaseAtMarket()
        {
            Buy buy = new Buy(build, api);

            trade = await buy.MarketAsync(trade);

            if (trade.Success)
            {
                trade.Status = true;
                TradeDB tradeDB = new TradeDB();
                await tradeDB.UpdateAsync(trade);
                await ElicitConditions();

                return;
            }
            else
            {
            }
            // Add Error Notification
            return;
        }
Exemple #19
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var db = new TradeDB())
            {
                Customers cust = new Customers
                {
                    //CompanyName = textBox1.Text.ToString(),
                    ContactName  = "Александр Ерохин",
                    ContactTitle = "Owner",
                    Address      = "1017 Maple Leaf",
                    City         = "Moscow",
                    Region       = "MC",
                    PostalCode   = "555555",
                    Country      = "Russia",
                    Phone        = "+7(800)123-4567",
                    Fax          = "None"
                };
                // 3. Добавление сущностного объекта в таблицу Customers
                db.Customers.Add(cust);

                // 4. Вызов метода SaveChanges
                db.SaveChanges();
            }
        }
Exemple #20
0
 internal static void AddSupplier(string comName, string CN, string T, string adr, string city, string reg, string post,
                                  string country, string phone, string fax)
 {
     using (var db = new TradeDB())
     {
         Suppliers supplier = new Suppliers
         {
             CompanyName  = comName,
             ContactName  = CN,
             ContactTitle = T,
             Address      = adr,
             City         = city,
             Region       = reg,
             PostalCode   = post,
             Country      = country,
             Phone        = phone,
             Fax          = fax
         };
         // 3. Добавление сущностного объекта в таблицу Customers
         db.Suppliers.Add(supplier);
         // 4. Вызов метода SaveChanges
         db.SaveChanges();
     }
 }
Exemple #21
0
        private void getstat_button_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();

            if (radioButton3.Checked)                           // статистика за период который мы указали
            {
                if (textBox1.Text != "" && textBox2.Text != "") // проверка введены ли данные временного интервала
                {
                    using (var db = new TradeDB())
                    {
                        DateTime _fromDate = StringToDate(textBox1.Text);
                        DateTime _toDate   = StringToDate(textBox2.Text);

                        if (_fromDate < _toDate)      // проверка того, чтобы начальная дата не превышала конечную
                        {
                            if (comboBox1.SelectedItem.ToString() == "Продажи")
                            {
                                Sale(_fromDate, _toDate);
                            }

                            if (comboBox1.SelectedItem.ToString() == "Поставки")
                            {
                                Delivery(_fromDate, _toDate);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Начальная дата не может быть больше конечной!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Введите временные данные!");
                }
            }
            if (radioButton1.Checked)    //статистика за последний месяц
            {
                DateTime _fromDate = DateTime.Now.AddMonths(-1);;
                DateTime _toDate   = DateTime.Now;

                if (_fromDate < _toDate)  // проверка того, чтобы начальная дата не превышала конечную
                {
                    if (comboBox1.SelectedItem.ToString() == "Продажи")
                    {
                        Sale(_fromDate, _toDate);
                    }

                    if (comboBox1.SelectedItem.ToString() == "Поставки")
                    {
                        Delivery(_fromDate, _toDate);
                    }
                }
            }
            if (radioButton2.Checked)     // статистика за последний год
            {
                DateTime _fromDate = DateTime.Now.AddYears(-1);
                DateTime _toDate   = DateTime.Now;

                if (_fromDate < _toDate)   // проверка того, чтобы начальная дата не превышала конечную
                {
                    if (comboBox1.SelectedItem.ToString() == "Продажи")
                    {
                        Sale(_fromDate, _toDate);
                    }

                    if (comboBox1.SelectedItem.ToString() == "Поставки")
                    {
                        Delivery(_fromDate, _toDate);
                    }
                }
            }
        }
Exemple #22
0
 private async Task ElicitConditions()
 {
     var implementConditions = Task.Run(async() => {
         if (!build.StopLoss && !build.TakeProfit)
         {
             // Buy Only --------------------------------------------------------------------- Done
             trade.DisplayType = "BOVC";
             TradeDB tradeDB   = new TradeDB();
             await tradeDB.UpdateAsync(trade);
         }
         else if (!build.StopLoss && build.TakeProfit && !build.TrailingTakeProfit)
         {
             // Take Profit
             // --------------------------------------------------------------------- Done
             Sell sell = new Sell(build, api);
             trade     = await sell.LimitAsync(trade, build.TakeProfitPrice);
             if (trade.Success)
             {
                 trade.DisplayType = "TPVC";
                 TradeDB tradeDB   = new TradeDB();
                 await tradeDB.UpdateAsync(trade);
                 Scan scan          = new Scan(build);
                 TradeResult result = await scan.ConclusionTakeProfitAsync(trade);
                 trade.Status       = false;
                 await tradeDB.UpdateAsync(trade);
                 if (result.Success)
                 {
                     TradeResultDB resultDB = new TradeResultDB();
                     resultDB.Add(result);
                 }
             }
         }
         else if (!build.StopLoss && build.TakeProfit && build.TrailingTakeProfit)
         {
             // Take Profit
             // Trailing Take Profit
             // --------------------------------------------------------------------- Done
             int priceDecimal            = BitConverter.GetBytes(decimal.GetBits(trade.TakeProfitPrice)[3])[2];
             decimal tempTakeProfitPrice = decimal.Round(build.TakeProfitPrice * 2, priceDecimal);
             Sell sell = new Sell(build, api);
             trade     = await sell.LimitAsync(trade, tempTakeProfitPrice);
             if (trade.Success)
             {
                 trade.TakeProfitPrice = build.TakeProfitPrice;
                 trade.DisplayType     = "TPVC";
                 TradeDB tradeDB       = new TradeDB();
                 await tradeDB.UpdateAsync(trade);
                 Scan scan          = new Scan(build, api);
                 TradeResult result = scan.TrailingTakeProfit(trade);
                 trade.Status       = false;
                 await tradeDB.UpdateAsync(trade);
                 if (result.Success)
                 {
                     TradeResultDB resultDB = new TradeResultDB();
                     resultDB.Add(result);
                 }
             }
         }
         else if (build.StopLoss && !build.TrailingStopLoss && !build.TakeProfit)
         {
             // Stop Loss
             // --------------------------------------------------------------------- Done
             Sell sell = new Sell(build, api);
             trade     = await sell.LimitStopAsync(trade, build.StopLossPrice);
             if (trade.Success)
             {
                 trade.DisplayType = "SLVC";
                 TradeDB tradeDB   = new TradeDB();
                 await tradeDB.UpdateAsync(trade);
                 Scan scan          = new Scan(build, api);
                 TradeResult result = await scan.ConclusionStopLossAsync(trade);
                 trade.Status       = false;
                 await tradeDB.UpdateAsync(trade);
                 if (result.Success)
                 {
                     TradeResultDB resultDB = new TradeResultDB();
                     resultDB.Add(result);
                 }
             }
         }
         else if (build.StopLoss && build.TrailingStopLoss && !build.TakeProfit)
         {
             // Stop Loss
             // Trailing Stop Loss
             // --------------------------------------------------------------------------------------- Done
             Sell sell = new Sell(build, api);
             trade     = await sell.LimitStopAsync(trade, trade.StopLossPrice);
             if (trade.Success)
             {
                 trade.DisplayType = "TSLVC";
                 TradeDB tradeDB   = new TradeDB();
                 await tradeDB.UpdateAsync(trade);
                 var trailingStop = Task.Run(async() =>
                 {
                     Scan scan          = new Scan(build, api);
                     TradeResult result = scan.TrailingStopLoss(trade);
                     trade.Status       = false;
                     await tradeDB.UpdateAsync(trade);
                     if (result.Success)
                     {
                         TradeResultDB resultDB = new TradeResultDB();
                         resultDB.Add(result);
                     }
                 });
             }
         }
         else if (build.StopLoss && build.TakeProfit && !build.TrailingStopLoss && !build.TrailingTakeProfit)
         {
             // Stop Loss
             // Take Profit
             // --------------------------------------------------------------------------------------- Done
             Sell sell = new Sell(build, api);
             trade     = await sell.LimitAsync(trade, build.TakeProfitPrice);
             if (trade.Success)
             {
                 trade.DisplayType = "TPSLVC";
                 TradeDB tradeDB   = new TradeDB();
                 await tradeDB.UpdateAsync(trade);
                 var scanStop = Task.Run(async() => {
                     Scan scan          = new Scan(build, api);
                     TradeResult result = scan.MiddleOrderFlip(trade);
                     trade.Status       = false;
                     await tradeDB.UpdateAsync(trade);
                     if (result.Success)
                     {
                         TradeResultDB resultDB = new TradeResultDB();
                         resultDB.Add(result);
                     }
                 });
             }
         }
         else if (build.StopLoss && build.TakeProfit && build.TrailingStopLoss && !build.TrailingTakeProfit)
         {
             // Stop Loss
             // Take Profit
             // Trailing Stop Loss
             //
             Sell sell = new Sell(build, api);
             trade     = await sell.LimitAsync(trade, build.TakeProfitPrice);
             if (trade.Success)
             {
                 trade.DisplayType = "TPSLVC";
                 TradeDB tradeDB   = new TradeDB();
                 await tradeDB.UpdateAsync(trade);
                 var scanStop = Task.Run(async() => {
                     Scan scan          = new Scan(build, api);
                     TradeResult result = scan.MiddleOrderFlip(trade);
                     trade.Status       = false;
                     await tradeDB.UpdateAsync(trade);
                     if (result.Success)
                     {
                         TradeResultDB resultDB = new TradeResultDB();
                         resultDB.Add(result);
                     }
                 });
             }
         }
         else if (build.StopLoss && build.TakeProfit && !build.TrailingStopLoss && build.TrailingTakeProfit)
         {
             // Stop Loss
             // Take Profit
             // Trailing Take Profit
             Sell sell = new Sell(build, api);
             trade     = await sell.LimitAsync(trade, build.TakeProfitPrice);
             if (trade.Success)
             {
                 trade.DisplayType = "TPSLVC";
                 TradeDB tradeDB   = new TradeDB();
                 await tradeDB.UpdateAsync(trade);
                 var scanStop = Task.Run(async() => {
                     Scan scan          = new Scan(build, api);
                     TradeResult result = scan.MiddleOrderFlip(trade);
                     trade.Status       = false;
                     await tradeDB.UpdateAsync(trade);
                     if (result.Success)
                     {
                         TradeResultDB resultDB = new TradeResultDB();
                         resultDB.Add(result);
                     }
                 });
             }
         }
         else if (build.StopLoss && build.TakeProfit && build.TrailingStopLoss && build.TrailingTakeProfit)
         {
             // Stop Loss
             // Take Profit
             // Trailing Stop Loss
             // Trailing Take Profit
             Sell sell = new Sell(build, api);
             trade     = await sell.LimitAsync(trade, build.TakeProfitPrice);
             if (trade.Success)
             {
                 trade.DisplayType = "TPSLVC";
                 TradeDB tradeDB   = new TradeDB();
                 await tradeDB.UpdateAsync(trade);
                 var scanStop = Task.Run(async() => {
                     Scan scan          = new Scan(build, api);
                     TradeResult result = scan.MiddleOrderFlip(trade);
                     trade.Status       = false;
                     await tradeDB.UpdateAsync(trade);
                     if (result.Success)
                     {
                         TradeResultDB resultDB = new TradeResultDB();
                         resultDB.Add(result);
                     }
                 });
             }
         }
     });
 }
Exemple #23
0
        public Pivots(string Symbol, string TradeSystem)
        {
            TradeDB db1 = new TradeDB();

            db1.Open();

            string sql = "select dayhi, daylo, daycl, day3hi, day3lo, weekhi, weeklo, weekcl, monhi, monlo, moncl, "
                         + " sma20day, sma200day, sixmonposmean, sixmonpossd, sixmonnegmean, sixmonnegsd"
                         + " from totrade where tradesystem='" + TradeSystem + "' and symbol = '" + Symbol + "'";
            SqlCommand cmd = new SqlCommand(sql, db1.Connection);

            SqlDataReader dr;

            dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    dayhi         = dr.GetDouble(0);
                    daylo         = dr.GetDouble(1);
                    daycl         = dr.GetDouble(2);
                    day3hi        = dr.GetDouble(3);
                    day3lo        = dr.GetDouble(4);
                    weekhi        = dr.GetDouble(5);
                    weeklo        = dr.GetDouble(6);
                    weekcl        = dr.GetDouble(7);
                    monhi         = dr.GetDouble(8);
                    monlo         = dr.GetDouble(9);
                    moncl         = dr.GetDouble(10);
                    sma20day      = dr.GetDouble(11);
                    sma200day     = dr.GetDouble(12);
                    sixmonposmean = dr.GetDouble(13);
                    sixmonpossd   = dr.GetDouble(14);
                    sixmonnegmean = dr.GetDouble(15);
                    sixmonnegsd   = dr.GetDouble(16);
                }
            }

            dr.Close();
            db1.Close();

            dayPv = (dayhi + daylo + daycl) / 3;
            dayR1 = 2 * dayPv - daylo;
            dayR2 = dayPv + (dayhi - daylo);
            dayR3 = dayR1 + (dayhi - daylo);
            dayS1 = 2 * dayPv - dayhi;
            dayS2 = dayPv - (dayhi - daylo);
            dayS3 = dayS1 - (dayhi - daylo);
            psDay = new PivotSet("day", dayS3, dayS2, dayS1, dayPv, dayR1, dayR2, dayR3);

            day3Pv = (day3hi + day3lo + daycl) / 3;
            day3R1 = 2 * day3Pv - day3lo;
            day3R2 = day3Pv + (day3hi - day3lo);
            day3R3 = day3R1 + (day3hi - day3lo);
            day3S1 = 2 * day3Pv - day3hi;
            day3S2 = day3Pv - (day3hi - day3lo);
            day3S3 = day3S1 - (day3hi - day3lo);
            psDay3 = new PivotSet("day3", day3S3, day3S2, day3S1, day3Pv, day3R1, day3R2, day3R3);

            weekPv = (weekhi + weeklo + weekcl) / 3;
            weekR1 = 2 * weekPv - weeklo;
            weekR2 = weekPv + (weekhi - weeklo);
            weekR3 = weekR1 + (weekhi - weeklo);
            weekS1 = 2 * weekPv - weekhi;
            weekS2 = weekPv - (weekhi - weeklo);
            weekS3 = weekS1 - (weekhi - weeklo);
            psWeek = new PivotSet("week", weekS3, weekS2, weekS1, weekPv, weekR1, weekR2, weekR3);

            monPv   = (monhi + monlo + moncl) / 3;
            monR1   = 2 * monPv - monlo;
            monR2   = monPv + (monhi - monlo);
            monR3   = monR1 + (monhi - monlo);
            monS1   = 2 * monPv - monhi;
            monS2   = monPv - (monhi - monlo);
            monS3   = monS1 - (monhi - monlo);
            psMonth = new PivotSet("mon", monS3, monS2, monS1, monPv, monR1, monR2, monR3);

            // Pivot Information
            if (pivotDraw)
            {
                pivot = (pivotHigh + pivotLow + pivotClose) / 3.0;
                //dsPivot = new DoubleSeries( "Pivot" );
                pivotR1 = 2.0 * pivot - pivotLow;
                pivotS1 = 2.0 * pivot - pivotHigh;
                pivotR2 = pivotR1 + pivot - pivotS1;
                pivotS2 = pivot - pivotR1 - pivotS1;
                Console.WriteLine("pivot {0} r1 {1} r2 {2} s1 {3} s2 {4}",
                                  pivot, pivotR1, pivotR2, pivotS1, pivotS2);
            }
        }
Exemple #24
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)  // выводи все товары выбранной категории
        {
            int Selected = listBox1.SelectedIndex;

            if (Selected == 0)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName + "-" + item.UnitsInStock);
                    }
                }
            }
            if (Selected == 1)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 2
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName + "-" + item.UnitsInStock);
                    }
                }
            }
            if (Selected == 2)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1002
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName + "-" + item.UnitsInStock);
                    }
                }
            }
            if (Selected == 3)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1003
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName + "-" + item.UnitsInStock);
                    }
                }
            }
            if (Selected == 4)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1009
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName + "-" + item.UnitsInStock);
                    }
                }
            }
            if (Selected == 5)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1010
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName + "-" + item.UnitsInStock);
                    }
                }
            }
            if (Selected == 6)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1012
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName + "-" + item.UnitsInStock);
                    }
                }
            }
        }
Exemple #25
0
        public void Run(DateTime dtEnd, bool bDebug)
        {
            TradeDB db1;
            TradeDB db2;

            string sDel = "delete from SymbolStats";
            //string sSelect = "select distinct top 5 symbol from iqRootOptionSymbols";
            string sSelect = "select distinct symbol from iqRootOptionSymbols";
            string sInsert = "insert into SymbolStats "
                             + "( symbol, hi52wk, hi52wkdate, lo52wk, lo52wkdate, "
                             + " hi26wk, hi26wkdate, lo26wk, lo26wkdate, "
                             + " volatility, volume, calcdate ) values ( "
                             + " @symbol, @hi52wk, @hi52wkdate, @lo52wk, @lo52wkdate, "
                             + " @hi26wk, @hi26wkdate, @lo26wk, @lo26wkdate, "
                             + " @volatility, @volume, @calcdate )";

            SqlCommand    cmdDel, cmdSelect, cmdInsert;
            SqlDataReader dr;

            //DateTime dtEnd = new DateTime( 2005, 08, 4 );
            ///DateTime dtEnd = DateTime.Today;
            //string s= dtEnd.ToShortDateString(
            TimeSpan ts52wk       = new TimeSpan(52 * 7, 0, 0, 0);
            DateTime dtStart52wk  = dtEnd.Subtract(ts52wk);
            TimeSpan ts26wk       = new TimeSpan(26 * 7, 0, 0, 0);
            DateTime dtStart26wk  = dtEnd.Subtract(ts26wk);
            TimeSpan ts20day      = new TimeSpan(20, 0, 0, 0);
            DateTime dtStart20day = dtEnd.Subtract(ts20day);

            //DataManager.Init();

            db1 = new TradeDB();
            db1.Open();

            db2 = new TradeDB();
            db2.Open();

            cmdDel    = new SqlCommand(sDel, db1.Connection);
            cmdSelect = new SqlCommand(sSelect, db1.Connection);
            cmdInsert = new SqlCommand(sInsert, db2.Connection);

            cmdInsert.Parameters.Add("@symbol", SqlDbType.VarChar, 12);
            cmdInsert.Parameters.Add("@hi52wk", SqlDbType.Float);
            cmdInsert.Parameters.Add("@hi52wkdate", SqlDbType.DateTime);
            cmdInsert.Parameters.Add("@lo52wk", SqlDbType.Float);
            cmdInsert.Parameters.Add("@lo52wkdate", SqlDbType.DateTime);
            cmdInsert.Parameters.Add("@hi26wk", SqlDbType.Float);
            cmdInsert.Parameters.Add("@hi26wkdate", SqlDbType.DateTime);
            cmdInsert.Parameters.Add("@lo26wk", SqlDbType.Float);
            cmdInsert.Parameters.Add("@lo26wkdate", SqlDbType.DateTime);
            cmdInsert.Parameters.Add("@volatility", SqlDbType.Float);
            cmdInsert.Parameters.Add("@volume", SqlDbType.Float);
            cmdInsert.Parameters.Add("@calcdate", SqlDbType.DateTime);

            cmdDel.ExecuteNonQuery();

            dr = cmdSelect.ExecuteReader();

            string      sSymbol;
            Instrument  instrument;
            DailySeries ds52;
            DailySeries ds26;

            DateTime dtNewHigh52;
            DateTime dtNewHigh26;
            //DateTime dtNewLow52;
            //DateTime dtNewLow26;

            int cntNewHigh52 = 0;
            int cntNewHigh26 = 0;
            int cntNewLow52  = 0;
            int cntNewLow26  = 0;

            while (dr.Read())
            {
                sSymbol = dr.GetString(0);
                if (bDebug)
                {
                    Console.Write("Starting {0}", sSymbol);
                }

                instrument = InstrumentManager.Instruments[sSymbol];
                if (null != instrument)
                {
                    try {
                        ds52 = DataManager.GetDailySeries(instrument, dtStart52wk, dtEnd);
                        ds26 = DataManager.GetDailySeries(instrument, dtStart26wk, dtEnd);
                        if (null != ds26)
                        {
                            dtNewHigh52 = ds52.HighestHighBar(dtStart52wk, dtEnd).DateTime;
                            dtNewHigh26 = ds26.HighestHighBar(dtStart26wk, dtEnd).DateTime;
                            //dtNewLow52  = ds52.LowestLowBar( dtStart52wk, dtEnd ).DateTime;
                            //dtNewLow26  = ds52.LowestLowBar( dtStart26wk, dtEnd ).DateTime;

                            if (dtNewHigh52 == dtEnd)
                            {
                                cntNewHigh52++;
                            }
                            if (dtNewHigh26 == dtEnd)
                            {
                                cntNewHigh26++;
                            }
                            //if ( dtNewLow52  == dtEnd ) cntNewLow52++;
                            //if ( dtNewLow26  == dtEnd ) cntNewLow26++;

                            cmdInsert.Parameters["@symbol"].Value = sSymbol;
                            cmdInsert.Parameters["@hi52wk"].Value = ds52.HighestHigh(dtStart52wk, dtEnd);
                            //cmdInsert.Parameters[ "@hi52wk" ].Value = 0.0;
                            cmdInsert.Parameters["@hi52wkdate"].Value = dtNewHigh52;
                            //cmdInsert.Parameters[ "@hi52wkdate" ].Value = dtEnd;
                            //cmdInsert.Parameters[ "@lo52wk" ].Value = ds52.LowestLow( dtStart52, dtEnd );
                            cmdInsert.Parameters["@lo52wk"].Value = 0.0;
                            //cmdInsert.Parameters[ "@lo52wkdate" ].Value = dtNewLow52;
                            cmdInsert.Parameters["@lo52wkdate"].Value = dtEnd;
                            cmdInsert.Parameters["@hi26wk"].Value     = ds26.HighestHigh(dtStart26wk, dtEnd);
                            cmdInsert.Parameters["@hi26wkdate"].Value = dtNewHigh26;
                            //cmdInsert.Parameters[ "@lo26wk" ].Value = ds52.LowestLow( dtStart26, dtEnd );
                            cmdInsert.Parameters["@lo26wk"].Value = 0.0;
                            //cmdInsert.Parameters[ "@lo26wkdate" ].Value = dtNewLow26;
                            cmdInsert.Parameters["@lo26wkdate"].Value = dtEnd;
                            //try {
                            //	cmdInsert.Parameters[ "@volatility" ].Value = ds52.GetVariance( dtStart20, dtEnd );
                            //}
                            //catch {
                            cmdInsert.Parameters["@volatility"].Value = 0.0;
                            //cmdInsert.Parameters[ "@volatility" ].Value = instrument.Volatility();
                            //}
                            cmdInsert.Parameters["@volume"].Value   = ds26.GetVolumeSeries(dtStart20day, dtEnd).GetMean();
                            cmdInsert.Parameters["@calcdate"].Value = dtEnd;

                            cmdInsert.ExecuteNonQuery();
                        }
                    }
                    catch (Exception e) {
                        if (bDebug)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Error:  {0} {1}", e.Message, e.StackTrace);
                        }
                    }
                }
                if (bDebug)
                {
                    Console.WriteLine();
                }
            }

            db1.Close();
            db2.Close();
            //DataManager.Close();
            Console.WriteLine("{0} 52 High={1}, 52 Low={2}, 26 High={3}, 26 Low={4}",
                              dtEnd, cntNewHigh52, cntNewLow52, cntNewHigh26, cntNewLow26);
            dr.Close();
        }
Exemple #26
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e) //Добавление товаров в выбранной категории
        {
            int Selected = listBox1.SelectedIndex;                             // переменная для выбранного товара в listBox1

            if (Selected == 0)                                                 // выводит в listBox2 все товары из категории[0] выбранный в listBox1
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 1)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 2
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 2)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1002
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 3)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1003
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 4)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1009
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 5)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1010
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 6)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1012
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
        }
Exemple #27
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e) // добавление всех товаров в listBox2, которые включены в выбранную категорию из listBox1
        {
            int Selected = listBox1.SelectedIndex;

            if (Selected == 0)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 1)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 2
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 2)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1002
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 3)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1003
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 4)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1009
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 5)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1010
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
            if (Selected == 6)
            {
                listBox2.Items.Clear();
                using (var db = new TradeDB())
                {
                    var query = from b in db.Products
                                where b.CategoryID == 1012
                                select b;
                    foreach (var item in query)
                    {
                        listBox2.Items.Add(item.ProductName);
                    }
                }
            }
        }
        public void Run()
        {
            //
            // TODO: Add constructor logic here
            //
            // http://www.dtniq.com/product/mktsymbols.zip

            //			string sConn0 = "Integrated Security=SSPI;" +
            //				"Persist Security Info=False;Initial Catalog=Trade;" +
            //				"Data Source=localhost;" +
            //				"Packet Size=4096;" +
            //				"";
            //			string sConn = "Integrated Security=SSPI;" +
            //				"Persist Security Info=False;Initial Catalog=Trade;" +
            //				"Data Source=localhost;" +
            //				"Packet Size=4096;Workstation ID=I9100;" +
            //				"";

            TradeDB db1;

            db1 = new TradeDB();
            db1.Open();

            //string sConn = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Trade;Data Source=ARMOR01;Packet Size=4096;";
            //SqlConnection connTrade = new SqlConnection();
            //connTrade.ConnectionString = sConn;
            //connTrade.ConnectionTimeout= 14400;
            //connTrade.Open();

            string     sDelete;
            SqlCommand cmdDelete;

            sDelete                  = "delete from iqSymbols";
            cmdDelete                = new SqlCommand(sDelete, db1.Connection);
            cmdDelete.CommandType    = System.Data.CommandType.Text;
            cmdDelete.CommandTimeout = 14400;
            cmdDelete.ExecuteNonQuery();

            sDelete                  = "delete from iqRootOptionSymbols";
            cmdDelete                = new SqlCommand(sDelete, db1.Connection);
            cmdDelete.CommandType    = System.Data.CommandType.Text;
            cmdDelete.CommandTimeout = 14400;
            cmdDelete.ExecuteNonQuery();

            string sInsert = "insert into iqSymbols ( symbol, descr, exchange, isindex, iscboeindex, isindicator, "
                             + "ismutualfund, ismoneymarketfund ) "
                             + "values ( @symbol, @descr, @exchange, @isindex, @iscboeindex, @isindicator, "
                             + "@ismutualfund, @ismoneymarketfund )";
            SqlCommand cmdInsert = new SqlCommand(sInsert, db1.Connection);

            cmdInsert.CommandType = System.Data.CommandType.Text;

            cmdInsert.Parameters.Add("@symbol", SqlDbType.VarChar);
            cmdInsert.Parameters.Add("@descr", SqlDbType.VarChar);
            cmdInsert.Parameters.Add("@exchange", SqlDbType.VarChar);
            cmdInsert.Parameters.Add("@isindex", SqlDbType.Bit);
            cmdInsert.Parameters.Add("@iscboeindex", SqlDbType.Bit);
            cmdInsert.Parameters.Add("@isindicator", SqlDbType.Bit);
            cmdInsert.Parameters.Add("@ismutualfund", SqlDbType.Bit);
            cmdInsert.Parameters.Add("@ismoneymarketfund", SqlDbType.Bit);

            Stream       fsSymbols = new FileStream(dir, FileMode.Open);
            StreamReader srSymbols = new StreamReader(fsSymbols, Encoding.ASCII);

            string l;
            int    i = 0;

            string [] items  = null;
            string    sDelim = "\t";

            char [] chDelim = sDelim.ToCharArray();
            //string t;
            string sSymbol;
            string sExchange;

            bool bMutual;
            bool bMoneyMkt;
            bool bIndex;
            bool bCboe;
            bool bIndicator;

            Hashtable htExchange = new Hashtable();

            //int cntLines = 0;

            srSymbols.ReadLine();
            //&& cntLines++ < 34
            while (srSymbols.Peek() >= 0)
            {
                l = srSymbols.ReadLine();
                //Console.WriteLine( l );
                items = l.Split(chDelim);
                //foreach ( string t in items ) {
                //Console.Write( "'" + t + "'," );
                //}
                if (3 != items.GetLength(0))
                {
                    Console.WriteLine("Missing an element: {0}", l);
                    continue;
                }
                sSymbol    = items[0];
                sExchange  = items[2];
                bMutual    = Regex.IsMatch(sSymbol, ".{3}[^\\.]X$", RegexOptions.None) && 5 == sSymbol.Length;
                bMoneyMkt  = Regex.IsMatch(sSymbol, ".{3}XX$", RegexOptions.None) && 5 == sSymbol.Length;
                bIndex     = Regex.IsMatch(sSymbol, ".+\\.X$", RegexOptions.None);
                bCboe      = Regex.IsMatch(sSymbol, ".+\\.XO$", RegexOptions.None);
                bIndicator = Regex.IsMatch(sSymbol, ".+\\.Z$", RegexOptions.None);

                cmdInsert.Parameters[0].Value = sSymbol;
                cmdInsert.Parameters[1].Value = items[1];
                cmdInsert.Parameters[2].Value = items[2];
                cmdInsert.Parameters[3].Value = bIndex;
                cmdInsert.Parameters[4].Value = bCboe;
                cmdInsert.Parameters[5].Value = bIndicator;
                cmdInsert.Parameters[6].Value = bMutual;
                cmdInsert.Parameters[7].Value = bMoneyMkt;

                cmdInsert.ExecuteNonQuery();

                //Console.WriteLine( htExchange[ sExchange ].GetType() );
                if (htExchange.ContainsKey(sExchange))
                {
                }
                else
                {
                    htExchange[sExchange] = 0;
                }
                //htExchange[ sExchange ]++;
                i = (int)htExchange[sExchange];
                i++;
                htExchange[sExchange] = i;
                //i = (int) htExchange[ sExchange ];
                //i++;
                //htExchange[ sExchange ] = i;


                //Console.WriteLine();
            }

            Console.WriteLine("{0}", DateTime.Now);
            ArrayList aKeys = new ArrayList(htExchange.Keys);

            aKeys.Sort();
            foreach (string s in aKeys)
            {
                Console.WriteLine("{0} {1}", s, htExchange[s]);
            }

            //foreach ( string s in args ) {
            //Console.WriteLine( s );
            //}


            srSymbols.Close();
            fsSymbols.Close();

            db1.Close();
        }