Exemplo n.º 1
0
        private void UpdateOrdersNew()
        {
            Task t = new Task(() =>
            {
                APIBalance balance   = APIWrapper.GetBalance();
                tbBalance.Text       = balance.Confirmed.ToString();
                var values           = Enum.GetValues(typeof(AlgorithmEnum)).OfType <AlgorithmEnum>().Select(a => (int)a).ToList();
                List <OrderN> result = new List <OrderN>();
                values.ForEach(value =>
                {
                    result.AddRange(HttpHelper.GetOrderListByLocation(_apiId, _apiKey, 0, value).Result);
                    result.AddRange(HttpHelper.GetOrderListByLocation(_apiId, _apiKey, 1, value).Result);
                });
                orderList = new SortableBindingList <OrderN>(result);
                if (dgvOrders.InvokeRequired)
                {
                    dgvOrders.Invoke(new Action(() =>
                    {
                        orderNBindingSource.DataSource = orderList;
                    }));
                }
                else
                {
                    orderNBindingSource.DataSource = orderList;
                }
            });

            t.Start();
        }
Exemplo n.º 2
0
        private async Task RefreshBalance()
        {
            APIBalance Balance = APIWrapper.GetBalance();

            if (Balance == null)
            {
                BalanceLabel.Text = "";
            }
            else
            {
                BalanceLabel.Text = Balance.Confirmed.ToString("F8") + " BTC";
            }
        }
Exemplo n.º 3
0
        private async Task UpdateOrders()
        {
            //return;
            //var ttt = HttpHelper.Get($"https://api.nicehash.com/api?method=balance&id={_apiId}&key={_apiKey}");
            APIBalance balance = APIWrapper.GetBalance();

            tbBalance.Text = balance.Confirmed.ToString();
            var t1 = HttpHelper.GetAllOrders(_apiId, _apiKey);
            await t1.ContinueWith(async (tmpOrderList) =>
            {
                orderList = new SortableBindingList <OrderN>(await tmpOrderList);
                orderNBindingSource.DataSource = orderList;
            });

            //var tmpOrderList =
        }
Exemplo n.º 4
0
        private void BalanceRefresh_Tick(object sender, EventArgs e)
        {
            if (!APIWrapper.ValidAuthorization)
            {
                return;
            }

            APIBalance Balance = APIWrapper.GetBalance();

            if (Balance == null)
            {
                toolStripLabel2.Text = "";
            }
            else
            {
                toolStripLabel2.Text = Balance.Confirmed.ToString("F8") + " BTC";
            }
        }
Exemplo n.º 5
0
        private void BalanceRefresh_Tick(object sender, EventArgs e)
        {
            if (!APIWrapper.ValidAuthorization)
            {
                return;
            }

            APIBalance Balance = APIWrapper.GetBalance();

            if (Balance == null)
            {
                toolStripLabel2.Text = "";
            }
            else
            {
                toolStripLabel2.Text = Balance.Confirmed.ToString("F8") + " BTC";
            }

            string JSONData = GetHTTPResponseInJSON("http://antminer/json_margin.php");

            if (JSONData == null)
            {
                Console.WriteLine("[" + DateTime.Now.ToString() + "] Local margin down!");
            }
            LocalStatsResponse Response;
            double             m = 0.01;
            double             r = 0;
            double             g = 0;
            double             s = 25 / 50000;
            string             d = "00:00:00";
            int a = 0;

            try
            {
                Response = JsonConvert.DeserializeObject <LocalStatsResponse>(JSONData);
                m        = Response.margin;
                r        = Response.estimated_reward;
                g        = (Response.ghashes_ps / 1000);
                s        = 25 / g;
                g        = (g / 1000);
                d        = Response.round_duration;
                a        = Response.auto;
                string _m = "!";
                if (a == 0)
                {
                    _m = "";
                }

                OrderContainer[] Orders = OrderContainer.GetAll();
                if (Orders.Length > 0 && Orders[0].OrderStats != null)
                {
                    double p     = Orders[0].OrderStats.BTCPaid + Response.prepaid;
                    double diff  = r - p;
                    string _diff = "";
                    if (diff > 0)
                    {
                        _diff = "+";
                    }
                    double speed = (Orders[0].OrderStats.Speed / 1000);
                    toolStripStatusLabel1.Text = m.ToString("F3") + _m + " - Paid " + p.ToString("F8") + " Reward " + r.ToString("F8") + " " + Math.Round((diff * 100) / p, 2).ToString("F2") + "% Diff " + Math.Round(((r - p) * 100) / r, 2).ToString("F2") + "% " + _diff + diff.ToString("F8") + " Hash " + speed.ToString("F2") + "/" + Orders[0].OrderStats.SpeedLimit.ToString("F2") + " Slush " + d + "/" + g.ToString("F2");
                }
                else
                {
                    toolStripStatusLabel1.Text = m.ToString("F3") + _m + " Slush " + d + "/" + g.ToString("F2");
                }
                statusStrip1.Refresh();
                if (a > 0 && TimeSpan.Parse(d).TotalMinutes > a)
                {
                    if (Orders.Length == 0)
                    {
                        if (FormNewOrderInstance == null)
                        {
                            FormNewOrderInstance = new FormNewOrder();
                            FormNewOrderInstance.Show();
                            FormNewOrderInstance.AcceptButton.PerformClick();
                        }
                    }
                }
            }
            catch
            {
                Console.WriteLine("[" + DateTime.Now.ToString() + "] Local margin grabage!");
            }
        }