/// <summary> /// Stop this order instance monitoring. /// </summary> /// <param name="RemoveOrder">Set to true to remove order.</param> public void Stop(bool RemoveOrder) { lock (this) { if (RemoveOrder && OrderID != 0) { APIWrapper.OrderRemove(ServiceLocation, Algorithm, OrderID); } CanRun = false; } OrderThread.Join(); }
private void ThreadRun() { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; while (CanRun) { if (!APIWrapper.ValidAuthorization) { System.Threading.Thread.Sleep(500); continue; } lock (this) { bool NewOrder = false; // Verify, if we have order. if (OrderID == 0) { // Need to create order. OrderID = APIWrapper.OrderCreate(ServiceLocation, Algorithm, StartingAmount, StartingPrice, StartLimit, PoolData); if (OrderID > 0) { NewOrder = true; LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Created new order #" + OrderID.ToString()); } } if (OrderID > 0) { // Get all orders. List <Order> AllOrders = APIWrapper.GetAllOrders(ServiceLocation, Algorithm, NewOrder); if (AllOrders != null) { // Find our order. Order MyOrder = null; foreach (Order O in AllOrders) { if (O.ID == OrderID) { MyOrder = O; break; } } // Get total hashing speed double TS = APIWrapper.GetTotalSpeed(ServiceLocation, Algorithm); if (MyOrder != null) { ProcessMyOrder(MyOrder, AllOrders.ToArray(), TS); LastOrderStats = new Order(MyOrder); } else { // Our order does not exist anymore, create new... OrderID = 0; LastOrderStats = null; } } } } // Wait 30 seconds. for (int i = 0; i < 30; i++) { if (!CanRun) { break; } System.Threading.Thread.Sleep(1000); } } }
/// <summary> /// Decrease order price for this order. /// </summary> /// <returns>New order price. If price was not decreased, -1 is returned.</returns> public double SetPriceDecrease() { return(APIWrapper.OrderSetPriceDecrease(ServiceLocation, Algorithm, ID)); }
/// <summary> /// Set limit for this order /// </summary> /// <param name="Limit">New order limit in GH/s (TH/s for Algorithm 1 - SHA256). 0 for unlimited.</param> /// <returns>New order limit. If limit was not changed, -1 is returned.</returns> public double SetLimit(double Limit) { return(APIWrapper.OrderSetLimit(ServiceLocation, Algorithm, ID, Limit)); }
/// <summary> /// Set price for this order. Only price increase allowed. /// </summary> /// <param name="Price">New order price.</param> /// <returns>New order price. If price was not changed, -1 is returned.</returns> public double SetPrice(double Price) { return(APIWrapper.OrderSetPrice(ServiceLocation, Algorithm, ID, Price)); }
/// <summary> /// Refill this order. /// </summary> /// <param name="BTCAmount">Amount of BTC to refill.</param> /// <returns>True if order was refilled.</returns> public bool Refill(double BTCAmount) { return(APIWrapper.OrderRefill(ServiceLocation, Algorithm, ID, BTCAmount)); }
/// <summary> /// Remove this order. /// </summary> /// <returns>True if order was removed.</returns> public bool Remove() { return(APIWrapper.OrderRemove(ServiceLocation, Algorithm, ID)); }