Beispiel #1
0
 public static void Add(int SL, int Algo, double Price, double SpeedLimit, Pool PoolInfo)
 {
     OrderContainer OC = new OrderContainer(SL, Algo, Price, SpeedLimit, PoolInfo);
     OC.Launch();
     OrderList.Add(OC);
     Commit();
 }
Beispiel #2
0
        public OrderPanel(int id, OrderContainer order, EventHandler TimerRefresh)
        {
            this.order        = order;
            this.id           = id;
            this.TimerRefresh = TimerRefresh;
            height            = 100;

            panel = new Panel
            {
                Width       = 200,
                Height      = height,
                BackColor   = System.Drawing.Color.White,
                BorderStyle = BorderStyle.FixedSingle,
            };

            FillPanel();

            if (order.OrderStats == null)
            {
                panel.BackColor = System.Drawing.Color.Yellow;
            }
            else if (!order.OrderStats.Alive)
            {
                panel.BackColor = System.Drawing.Color.IndianRed;
            }
            else
            {
                panel.BackColor = System.Drawing.Color.LightGreen;
            }
        }
Beispiel #3
0
        private void FindOrdersButton_Click(object sender, EventArgs e)
        {
            DesyncController.Delete();

            List <Order> orders = new List <Order>();

            foreach (Order order in APIWrapper.GetMyOrders(0, AlgorithmComboBox.SelectedIndex))
            {
                orders.Add(order);
            }
            foreach (Order order in APIWrapper.GetMyOrders(1, AlgorithmComboBox.SelectedIndex))
            {
                orders.Add(order);
            }

            OrderContainer[] localOrders = OrderContainer.GetAll();
            foreach (Order order in orders)
            {
                bool exists = false;
                foreach (OrderContainer orderContainer in localOrders)
                {
                    if (orderContainer.ID == order.ID)
                    {
                        exists = true;
                    }
                }
                if (!exists)
                {
                    OrderContainer.Add(order.ServiceLocation, order.Algorithm, order.Price, order.SpeedLimit, new Pool(), order.ID, 0.001, 0.005, "");
                }
            }

            Refresh();
        }
Beispiel #4
0
        private void EUConfirmButton_Click(object sender, EventArgs e)
        {
            if (PoolComboBox.SelectedIndex < 0)
            {
                MessageBox.Show("You have to select pool for this order!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                PoolComboBox.Focus();
                return;
            }

            LimitBuffer    = decimal.ToDouble(Convert.ToDecimal(EUSpeedTextBox.Text));
            MaxPriceBuffer = decimal.ToDouble(Convert.ToDecimal(EUPriceTextBox.Text));

            if (OrderContainer.Add(0, AlgorithmComboBox.SelectedIndex, MaxPriceBuffer, LimitBuffer, Pools[PoolComboBox.SelectedIndex], OrderID, StartPrice, StartAmount, ""))
            {
                OrderID++;
            }
            else
            {
                MessageBox.Show("Error creating order", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (linked)
            {
                if (OrderContainer.Add(1, AlgorithmComboBox.SelectedIndex, MaxPriceBuffer, LimitBuffer, Pools[PoolComboBox.SelectedIndex], OrderID, StartPrice, StartAmount, ""))
                {
                    OrderID++;
                }
                else
                {
                    MessageBox.Show("Error creating order", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Refresh();
        }
Beispiel #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBox3.SelectedIndex < 0)
            {
                MessageBox.Show("You have to select pool for this order!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboBox3.Focus();
                return;
            }

            double Limit       = decimal.ToDouble(numericUpDown1.Value);
            double MaxPrice    = decimal.ToDouble(numericUpDown2.Value);
            int    OrderID     = decimal.ToInt32(numericUpDown3.Value);
            double StartPrice  = decimal.ToDouble(numericUpDown4.Value);
            double StartAmount = decimal.ToDouble(numericUpDown5.Value);

            if (AdvancedOptionsShown)
            {
                if (!OrderContainer.Add(comboBox1.SelectedIndex, comboBox2.SelectedIndex, MaxPrice, Limit, Pools[comboBox3.SelectedIndex], OrderID, StartPrice, StartAmount, textBox1.Text))
                {
                    MessageBox.Show("Order already in list!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    numericUpDown3.Focus();
                    return;
                }
            }
            else
            {
                OrderContainer.Add(comboBox1.SelectedIndex, comboBox2.SelectedIndex, MaxPrice, Limit, Pools[comboBox3.SelectedIndex]);
            }

            Close();
        }
Beispiel #6
0
        private async Task SetOvSpeedAsync()
        {
            FormPleaseWait pleaseWait = new FormPleaseWait();

            try
            {
                pleaseWait.StartPosition = FormStartPosition.CenterScreen;
                pleaseWait.Show();
            }
            catch (Exception ex) { Console.WriteLine(ex); }

            bool needDelay = false;

            OrderContainer[] Orders = OrderContainer.GetAll();
            for (int i = Orders.Length - 1; i >= 0; i--)
            {
                if (Orders[i].Algorithm == AlgorithmComboBox.SelectedIndex)
                {
                    if (Orders[i].OrderStats != null)
                    {
                        if (needDelay)
                        {
                            await Task.Delay(2000);
                        }
                        OrderContainer.SetLimit(i, Convert.ToDouble(OvSpeedTextBox.Text));
                        APIWrapper.OrderSetLimit(Orders[i].ServiceLocation, Orders[i].Algorithm, Orders[i].ID, Convert.ToDouble(OvSpeedTextBox.Text));
                        needDelay = true;
                    }
                }
            }
            try { pleaseWait.Close(); }
            catch (Exception ex) { Console.WriteLine(ex); }

            Refresh();
        }
Beispiel #7
0
 public static void Add(int SL, int Algo, double Price, double SpeedLimit, Pool PoolInfo, int OrderID, double StartPrice, double StartAmount, string HandlerFile)
 {
     OrderContainer OC = new OrderContainer(SL, Algo, Price, SpeedLimit, PoolInfo, OrderID, StartPrice, StartAmount, HandlerFile);
     OC.Launch();
     OrderList.Add(OC);
     Commit();
 }
Beispiel #8
0
        public static void Add(int SL, int Algo, double Price, double SpeedLimit, Pool PoolInfo)
        {
            OrderContainer OC = new OrderContainer(SL, Algo, Price, SpeedLimit, PoolInfo);

            OC.Launch();
            OrderList.Add(OC);
            Commit();
        }
        public static void Add(int SL, int Algo, double Price, double SpeedLimit, Pool PoolInfo, int OrderID, double StartPrice, double StartAmount, string HandlerFile)
        {
            OrderContainer OC = new OrderContainer(SL, Algo, Price, SpeedLimit, PoolInfo, OrderID, StartPrice, StartAmount, HandlerFile);

            OC.Launch();
            OrderList.Add(OC);
            Commit();
        }
Beispiel #10
0
        private void setToUnlimitedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }

            OrderContainer.SetLimit(listView1.SelectedIndices[0], 0);
        }
Beispiel #11
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }

            OrderContainer.Remove(listView1.SelectedIndices[0]);
            TimerRefresh_Tick(sender, e);
        }
 public OrderContainer(OrderContainer orderContainer)
 {
     ServiceLocation = orderContainer.ServiceLocation;
     Algorithm       = orderContainer.Algorithm;
     MaxPrice        = orderContainer.MaxPrice;
     Limit           = orderContainer.Limit;
     PoolData        = orderContainer.PoolData;
     ID             = 0;
     StartingAmount = orderContainer.StartingAmount;
     StartingPrice  = orderContainer.StartingPrice;
     HandlerDLL     = orderContainer.HandlerDLL;
 }
Beispiel #13
0
        static void Main()
        {
            PoolContainer.Initialize();
            SettingsContainer.Initialize();
            OrderContainer.Initialize();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormMain());

            OrderContainer.Deinitialize();
        }
Beispiel #14
0
        private void speedLimitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }

            FormNumberInput FNI = new FormNumberInput("Set new limit", 0, 1000, OrderContainer.GetLimit(listView1.SelectedIndices[0]), 2);

            if (FNI.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                OrderContainer.SetLimit(listView1.SelectedIndices[0], FNI.Value);
            }
        }
Beispiel #15
0
        private void TimerRefresh_Tick(object sender, EventArgs e)
        {
            if (!APIWrapper.ValidAuthorization)
            {
                return;
            }

            OrderContainer[] Orders = OrderContainer.GetAll();
            int Selected            = -1;

            if (listView1.SelectedIndices.Count > 0)
            {
                Selected = listView1.SelectedIndices[0];
            }
            listView1.Items.Clear();
            for (int i = 0; i < Orders.Length; i++)
            {
                int          Algorithm = Orders[i].Algorithm;
                ListViewItem LVI       = new ListViewItem(APIWrapper.SERVICE_NAME[Orders[i].ServiceLocation]);
                LVI.SubItems.Add(APIWrapper.ALGORITHM_NAME[Algorithm]);
                if (Orders[i].OrderStats != null)
                {
                    LVI.SubItems.Add("#" + Orders[i].OrderStats.ID.ToString());
                    string PriceText = Orders[i].OrderStats.Price.ToString("F4") + " (" + Orders[i].MaxPrice.ToString("F4") + ")";
                    PriceText += " BTC/" + APIWrapper.SPEED_TEXT[Algorithm] + "/Day";
                    LVI.SubItems.Add(PriceText);
                    LVI.SubItems.Add(Orders[i].OrderStats.BTCAvailable.ToString("F8"));
                    LVI.SubItems.Add(Orders[i].OrderStats.BTCPaid.ToString("F8"));
                    string SpeedText = (Orders[i].OrderStats.Speed * APIWrapper.ALGORITHM_MULTIPLIER[Algorithm]).ToString("F4") + " (" + Orders[i].Limit.ToString("F2") + ") " + APIWrapper.SPEED_TEXT[Algorithm] + "/s";
                    LVI.SubItems.Add(SpeedText);
                    LVI.SubItems.Add(Orders[i].OrderStats.Workers.ToString());
                    if (!Orders[i].OrderStats.Alive)
                    {
                        LVI.BackColor = Color.PaleVioletRed;
                    }
                    else
                    {
                        LVI.BackColor = Color.LightGreen;
                    }
                    //LVI.SubItems.Add("View competing orders");
                }

                if (Selected >= 0 && Selected == i)
                {
                    LVI.Selected = true;
                }

                listView1.Items.Add(LVI);
            }
        }
Beispiel #16
0
        private void setMaximalPriceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }

            FormNumberInput FNI = new FormNumberInput("Set new price", 0.0001, 100, OrderContainer.GetMaxPrice(listView1.SelectedIndices[0]), 4);

            if (FNI.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                OrderContainer.SetMaxPrice(listView1.SelectedIndices[0], FNI.Value);
            }
        }
Beispiel #17
0
        public static bool Add(int SL, int Algo, double Price, double SpeedLimit, Pool PoolInfo, int OrderID, double StartPrice, double StartAmount, string HandlerFile)
        {
            foreach (OrderContainer OC_ in OrderList)
            {
                if (OC_.ID == OrderID)
                {
                    return(false);
                }
            }

            OrderContainer OC = new OrderContainer(SL, Algo, Price, SpeedLimit, PoolInfo, OrderID, StartPrice, StartAmount, HandlerFile);

            OC.Launch();
            OrderList.Add(OC);
            Commit();

            return(true);
        }
Beispiel #18
0
        private async Task <bool> DeleteOrdersAsync(OrderContainer[] Orders)
        {
            bool needWait = false;

            for (int i = Orders.Length - 1; i >= 0; i--)
            {
                if (Orders[i].Algorithm == AlgorithmComboBox.SelectedIndex)
                {
                    if (needWait)
                    {
                        await Task.Delay(1100);
                    }
                    OrderContainer.Remove(i);
                    needWait = true;
                }
            }
            return(true);
        }
Beispiel #19
0
        private async void RemoveAllButton_Click(object sender, EventArgs e)
        {
            bool empty = true;

            OrderContainer[] Orders = OrderContainer.GetAll();
            for (int i = Orders.Length - 1; i >= 0; i--)
            {
                if (Orders[i].Algorithm == AlgorithmComboBox.SelectedIndex)
                {
                    empty = false;
                }
            }
            if (empty)
            {
                return;
            }

            string       algo         = APIWrapper.ALGORITHM_NAME[AlgorithmComboBox.SelectedIndex];
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all [" + algo + "] orders?", "Warning", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                FormPleaseWait pleaseWait = new FormPleaseWait();
                try
                {
                    pleaseWait.StartPosition = FormStartPosition.CenterScreen;
                    pleaseWait.Show();
                    //
                    await DeleteOrdersAsync(Orders);

                    pleaseWait.Close();
                }
                catch (Exception ex) { Console.WriteLine(ex); }
            }
            Refresh();
        }
Beispiel #20
0
        private void FillPanel()
        {
            IDLabel = new Label
            {
                Text     = "# " + order.ID.ToString(),
                Location = new System.Drawing.Point(5, 7),
                AutoSize = true,
            };
            panel.Controls.Add(IDLabel);
            IDLabel.Click += (o, args) =>
            {
                System.Diagnostics.Process.Start("https://www.nicehash.com/order/" + order.ID.ToString());
            };

            var DeleteButton = new Button
            {
                Text      = "X",
                Location  = new System.Drawing.Point(170, 3),
                Width     = 25,
                BackColor = SystemColors.ButtonFace,
            };

            panel.Controls.Add(DeleteButton);
            DeleteButton.Click += (o, args) =>
            {
                OrderContainer.Remove(id);
            };
            DeleteButton.Click += TimerRefresh;

            if (order.OrderStats == null)
            {
                return;
            }

            var LimitTextBox = new TextBox
            {
                Text     = order.Limit.ToString(),
                Location = new System.Drawing.Point(5, 32),
                Width    = 40,
            };

            panel.Controls.Add(LimitTextBox);

            var PriceTextBox = new TextBox
            {
                Text     = order.MaxPrice.ToString("F4"),
                Location = new System.Drawing.Point(50, 32),
                Width    = 50,
            };

            panel.Controls.Add(PriceTextBox);
            PriceTextBox.TextChanged += PriceTextBox_TextChanged;

            if (order.MaxPriceInput != 0)
            {
                PriceTextBox.Text = order.MaxPriceInput.ToString("F4");
            }

            ToolTip currentPriceTooltip = new ToolTip();

            currentPriceTooltip.ToolTipIcon = ToolTipIcon.Info;
            currentPriceTooltip.IsBalloon   = true;
            currentPriceTooltip.ShowAlways  = true;

            currentPriceTooltip.SetToolTip(PriceTextBox, order.MaxPrice.ToString("F4"));

            var AddBitsTextBox = new TextBox
            {
                Text     = "0",
                Location = new System.Drawing.Point(105, 32),
                Width    = 30,
            };

            panel.Controls.Add(AddBitsTextBox);
            AddBitsTextBox.TextChanged += AddBitsTextBox_TextChanged;

            if (order.BitsInput != 0)
            {
                AddBitsTextBox.Text = order.BitsInput.ToString();
            }

            panel.Controls.Add(new Label
            {
                Text     = "Speed: " + order.OrderStats.Speed + " (" + order.OrderStats.Workers + " workers)",
                Location = new System.Drawing.Point(5, 55),
                AutoSize = true,
            });

            panel.Controls.Add(new Label
            {
                Text     = "Availiable BTC: " + order.OrderStats.BTCAvailable,
                Location = new System.Drawing.Point(5, 75),
                AutoSize = true,
            });

            var SetButton = new Button
            {
                Text      = "Set",
                Location  = new System.Drawing.Point(145, 30),
                Width     = 50,
                BackColor = SystemColors.ButtonFace,
            };

            panel.Controls.Add(SetButton);
            SetButton.Click += async(o, args) =>
            {
                await SetValuesAsync();

                TimerRefresh(null, null);
            };
            //SetButton.Click += TimerRefresh;

            async Task <bool> SetValuesAsync()
            {
                int  delayTime = 1900;
                int  i         = 0;
                bool needDelay = false;

                FormPleaseWait pleaseWait = new FormPleaseWait();

                try
                {
                    pleaseWait.StartPosition = FormStartPosition.CenterScreen;
                    pleaseWait.Show();
                }
                catch (Exception ex) { Console.WriteLine(ex); }

                foreach (OrderContainer _order in OrderContainer.GetAll())
                {
                    if (_order.ID == order.ID)
                    {
                        if (_order.Limit != Convert.ToDouble(LimitTextBox.Text))
                        {
                            if (needDelay)
                            {
                                await Task.Delay(delayTime);
                            }
                            OrderContainer.SetLimit(i, Convert.ToDouble(LimitTextBox.Text));
                            APIWrapper.OrderSetLimit(_order.ServiceLocation, _order.Algorithm, _order.ID, Convert.ToDouble(LimitTextBox.Text));
                            needDelay = true;
                        }

                        if (_order.MaxPrice != Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001)
                        {
                            if (needDelay)
                            {
                                await Task.Delay(delayTime);
                            }
                            OrderContainer.SetMaxPrice(i, Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001);
                            APIWrapper.OrderSetPrice(_order.ServiceLocation, _order.Algorithm, _order.ID, Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001);
                            needDelay            = true;
                            _order.MaxPriceInput = _order.MaxPrice;
                            _order.BitsInput     = 0;
                        }

                        if (Sync != -1)
                        {
                            OrderContainer[] Orders = OrderContainer.GetAll();
                            int _i = 0;
                            foreach (OrderContainer _orderSynced in Orders)
                            {
                                if (_orderSynced.ID == Sync)
                                {
                                    if (_orderSynced.Limit != Convert.ToDouble(LimitTextBox.Text))
                                    {
                                        if (needDelay)
                                        {
                                            await Task.Delay(delayTime);
                                        }
                                        OrderContainer.SetLimit(_i, Convert.ToDouble(LimitTextBox.Text));
                                        APIWrapper.OrderSetLimit(_orderSynced.ServiceLocation, _orderSynced.Algorithm, _orderSynced.ID, Convert.ToDouble(LimitTextBox.Text));
                                        needDelay = true;
                                    }

                                    if (_orderSynced.MaxPrice != Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001)
                                    {
                                        if (needDelay)
                                        {
                                            await Task.Delay(delayTime);
                                        }
                                        OrderContainer.SetMaxPrice(_i, Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001);
                                        APIWrapper.OrderSetPrice(_orderSynced.ServiceLocation, _orderSynced.Algorithm, _orderSynced.ID, Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001);
                                        needDelay = true;
                                        _orderSynced.MaxPriceInput = _orderSynced.MaxPrice;
                                        _orderSynced.BitsInput     = 0;
                                    }

                                    break;
                                }
                                _i++;
                            }
                        }
                    }

                    i++;
                }
                try { pleaseWait.Close(); }
                catch (Exception ex) { Console.WriteLine(ex); }

                return(true);
            }

            var RefillButton = new Button
            {
                Text      = "Refill",
                Location  = new System.Drawing.Point(145, 68),
                Width     = 50,
                BackColor = SystemColors.ButtonFace,
            };

            panel.Controls.Add(RefillButton);
            RefillButton.Click += (o, args) =>
            {
                order.OrderStats.Refill(0.005);
            };
            RefillButton.Click += TimerRefresh;
        }
Beispiel #21
0
        private void TimerRefresh_Tick(object sender, EventArgs e)
        {
            EUOrderPanel.Controls.Clear();
            USOrderPanel.Controls.Clear();
            SyncOrderPanel.Controls.Clear();

            if (!APIWrapper.ValidAuthorization)
            {
                return;
            }

            //APIWrapper.GetAllOrders();
            OrderContainer[] Orders = OrderContainer.GetAll();
            if (Orders.Count() > OrderID)
            {
                OrderID = Orders.Count();
            }

            if (Orders.Length == 0)
            {
                return;
            }

            List <OrderPanel> OrderPanels = new List <OrderPanel>();

            bool needRefresh = false;

            for (int i = 0; i < Orders.Length; i++)
            {
                if (Orders[i].Algorithm == AlgorithmComboBox.SelectedIndex)
                {
                    OrderPanels.Add(new OrderPanel(i, Orders[i], new EventHandler(TimerRefresh_Tick)));
                }

                if (Orders[i].OrderStats != null)
                {
                    if (Orders[i].OrderStats.Price > Orders[i].MaxPrice)
                    {
                        Orders[i].MaxPrice = Orders[i].OrderStats.Price;
                        needRefresh        = true;
                    }
                }
            }

            PositionPanels(ref OrderPanels);

            foreach (OrderPanel panel in OrderPanels)
            {
                if (panel.order.ServiceLocation == 0)
                {
                    panel.Place(ref EUOrderPanel, ref SyncOrderPanel);
                }
                else if (panel.order.ServiceLocation == 1)
                {
                    panel.Place(ref USOrderPanel, ref SyncOrderPanel);
                }
            }
            SyncOrderPanel.Height = EUOrderPanel.Height > USOrderPanel.Height ? EUOrderPanel.Height : USOrderPanel.Height;

            if (needRefresh)
            {
                Refresh();
            }
        }
Beispiel #22
0
        private void TimerRefresh_Tick(object sender, EventArgs e)
        {
            if (!APIWrapper.ValidAuthorization)
            {
                return;
            }

            int tempTick = ++Tick;

            OrderContainer[] Orders = OrderContainer.GetAll();
            int Selected            = -1;

            if (listView1.SelectedIndices.Count > 0)
            {
                Selected = listView1.SelectedIndices[0];
            }
            listView1.Items.Clear();
            for (int i = 0; i < Orders.Length; i++)
            {
                int          Algorithm = Orders[i].Algorithm;
                ListViewItem LVI       = new ListViewItem(APIWrapper.SERVICE_NAME[Orders[i].ServiceLocation]);
                LVI.SubItems.Add(APIWrapper.ALGORITHM_NAME[Algorithm]);
                if (Orders[i].OrderStats != null)
                {
                    if (tempTick % 120 == 0)
                    {
                        if ((Orders[i].OrderStats.Price > 1.025 * Orders[i].MaxPrice) && (Orders[i].OrderStats.Speed > 0))
                        {
                            OrderContainer copy = new OrderContainer(Orders[i]);
                            OrderContainer.Remove(i);
                            OrderContainer.Add(copy.ServiceLocation, copy.Algorithm, copy.MaxPrice, copy.Limit, copy.PoolData, copy.ID, copy.StartingPrice, copy.StartingAmount, copy.HandlerDLL);
                            Console.WriteLine("Order recreated");
                        }
                    }
                    else
                    {
                        LVI.SubItems.Add("#" + Orders[i].OrderStats.ID.ToString());
                        string PriceText = Orders[i].OrderStats.Price.ToString("F4") + " (" + Orders[i].MaxPrice.ToString("F4") + ")";
                        PriceText += " BTC/" + APIWrapper.SPEED_TEXT[Algorithm] + "/Day";
                        LVI.SubItems.Add(PriceText);
                        LVI.SubItems.Add(Orders[i].OrderStats.BTCAvailable.ToString("F8"));
                        LVI.SubItems.Add(Orders[i].OrderStats.Workers.ToString());
                        string SpeedText = (Orders[i].OrderStats.Speed * APIWrapper.ALGORITHM_MULTIPLIER[Algorithm]).ToString("F4") + " (" + Orders[i].Limit.ToString("F2") + ") " + APIWrapper.SPEED_TEXT[Algorithm] + "/s";
                        LVI.SubItems.Add(SpeedText);
                        if (!Orders[i].OrderStats.Alive)
                        {
                            LVI.BackColor = Color.PaleVioletRed;
                        }
                        else
                        {
                            LVI.BackColor = Color.LightGreen;
                        }
                        LVI.SubItems.Add("View competing orders");
                    }
                }

                if (Selected >= 0 && Selected == i)
                {
                    LVI.Selected = true;
                }

                listView1.Items.Add(LVI);
            }
        }
Beispiel #23
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!");
            }
        }