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(); }
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(); }
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); } }
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(); }
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; }
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!"); } }
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); } }
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(); } }