예제 #1
0
        public void Update_Paths()
        {
            DataTable dttemp = Bitcoin_Notify_DB.SPs.ViewPathsAll().GetDataSet().Tables[0];

            foreach (DataRow dr in dttemp.Rows)
            {
                try
                {
                    Models.Path currentpath = new Models.Path();
                    currentpath.pathkey = Convert.ToInt32(dr["path_key"]);
                    currentpath.label   = dr["path_name"].ToString();
                    DataTable dttemproutes = Bitcoin_Notify_DB.SPs.ViewPathRouteSpecific(currentpath.pathkey).GetDataSet().Tables[0];
                    currentpath.path = new List <int>();
                    foreach (DataRow dr2 in dttemproutes.Rows)
                    {
                        currentpath.path.Add(Convert.ToInt32(dr2["market_key"]));
                    }

                    currentpath.marketdifference = GetArbitrageRate(currentpath.path);

                    if (currentpath.marketdifference.isvoid == false)
                    {
                        fb.UpdatePaths(currentpath);
                    }
                }
                catch
                {
                }
            }
        }
예제 #2
0
        void Execute_Update_Firebase()
        {
            APIs.Firebase fb = new APIs.Firebase();

            DataTable          dttemp   = Bitcoin_Notify_DB.SPs.ViewArbResults().GetDataSet().Tables[0];
            List <Models.Path> allpaths = new List <Models.Path>();

            foreach (DataRow dr in dttemp.Rows)
            {
                Models.Path currentpath = new Models.Path();
                currentpath.label                       = dr["label"].ToString();
                currentpath.marketdifference            = new Models.MarketDifference();
                currentpath.marketdifference.percentage = Convert.ToDecimal(dr["percentage"]);
                currentpath.pathkey                     = Convert.ToInt32(dr["arb_results_key"]);
                allpaths.Add(currentpath);
            }
            fb.UpdateAllPaths(allpaths);
        }
예제 #3
0
        public void Update_Paths_All()
        {
            DataTable dttemp = Bitcoin_Notify_DB.SPs.ViewExchangesAll().GetDataSet().Tables[0];

            DataTable dttemppathkey = Bitcoin_Notify_DB.SPs.ViewPathsAll().GetDataSet().Tables[0];
            int       pathkey       = Convert.ToInt32(dttemppathkey.Rows[dttemppathkey.Rows.Count - 1]["path_key"]);

            foreach (DataRow dr in dttemp.Rows)  //looping through exchanges 1
            {
                int exchange1 = Convert.ToInt32(dr["exchange_key"]);

                List <Tuple <int, int> > hsexchangecurrencypairs = new List <Tuple <int, int> >();

                DataTable dtexchangecurrencies = Bitcoin_Notify_DB.SPs.ViewExchangeCurrenciesSpecificExchange(exchange1).GetDataSet().Tables[0];
                foreach (DataRow drec in dtexchangecurrencies.Rows)
                {
                    int currency1 = Convert.ToInt32(drec["currency"]);
                    foreach (DataRow drec2 in dtexchangecurrencies.Rows)
                    {
                        int currency2 = Convert.ToInt32(drec2["currency"]);
                        if (currency1 < currency2)
                        {
                            hsexchangecurrencypairs.Add(new Tuple <int, int>(currency1, currency2));
                        }
                    }
                }

                foreach (DataRow dr2 in dttemp.Rows) //looping through exchanges 2
                {
                    int exchange2 = Convert.ToInt32(dr2["exchange_key"]);


                    if (exchange1 != exchange2)  //must be different exchanges
                    {
                        foreach (Tuple <int, int> currencypair in hsexchangecurrencypairs)
                        {
                            //go through all currency pairs exchange1 has

                            //check if exchange 2 has both currencies
                            DataTable dtexchangecurrency2 = Bitcoin_Notify_DB.SPs.ViewExchangeCurrenciesSpecificExchange(exchange2).GetDataSet().Tables[0];

                            DataColumn[] keyColumns1 = new DataColumn[1];
                            keyColumns1[0] = dtexchangecurrency2.Columns["currency"];
                            dtexchangecurrency2.PrimaryKey = keyColumns1;

                            bool candopairing = false;
                            if ((dtexchangecurrency2.Rows.Contains(currencypair.Item1)) && (dtexchangecurrency2.Rows.Contains(currencypair.Item2)))
                            {
                                candopairing = true;
                            }

                            if (candopairing) //can do currency pairing
                            {
                                DataTable dttemppath = Bitcoin_Notify_DB.SPs.ViewPathByExchangesAndCurrencies(exchange1, exchange2, currencypair.Item1, currencypair.Item2).GetDataSet().Tables[0];

                                Models.Path currentpath = new Models.Path();
                                currentpath.pathkey = 0;
                                currentpath.label   = "";
                                currentpath.path    = new List <int>();

                                foreach (DataRow drpath in dttemppath.Rows)
                                {
                                    currentpath.path.Add(Convert.ToInt32(drpath["market_key"]));
                                    currentpath.label += drpath["Source_Shortname"].ToString() + "_" + drpath["Source_Currency"].ToString() + "->";
                                }

                                if (currentpath.label.Length > 3)
                                {
                                    currentpath.label = currentpath.label.Substring(0, currentpath.label.Length - 2);
                                }

                                currentpath.marketdifference = GetArbitrageRate(currentpath.path);

                                if (currentpath.marketdifference.isvoid == false)
                                {
                                    pathkey            += 1;
                                    currentpath.pathkey = pathkey;
                                    fb.UpdatePaths(currentpath);
                                }
                            }
                        }
                    }
                }
            }
        }