private void GetPrices(Chrome chrome, string pair) { Stopwatch timer = Stopwatch.StartNew(); string pricesResult; if (pair.IndexOf("/KRW") != -1) { pricesResult = chrome.EvalAndGet(Commands.GetPriceKRW()); pricesResult = pricesResult.Replace("__buffer__", ""); } else { pricesResult = chrome.EvalAndGet(Commands.GetPriceUSDT()); pricesResult = pricesResult.Replace("__buffer__", ""); pricesResult = pricesResult.Replace(" KRW", ""); } Price price = null; try { price = JsonConvert.DeserializeObject <Price>(pricesResult); price.Pair = pair; } catch (Exception) { this.OnError(this, new EventArgs()); } lock (locker) { this.Prices[pair] = price; this.CountComplete++; Console.WriteLine(pair + " it self:" + timer.Elapsed.TotalSeconds); if (this.CountComplete == this.CountTotal) { this.OnComplete(this, new ParsePricesCompleteEventArgs(this.Prices)); Utils.Debug.End("Parse Prices Finish:"); } } }
private void PremiumBuy(string pair, decimal amount) { Chrome chrome = Browsers[pair]; // Order tab chrome.Eval(Commands.ClickBuyTab()); // tested // Check for enough fund decimal fiat = Properties.Settings.Default.CycleMoney * (decimal)1.5; bool available = chrome.EvalAndGet(Commands.CheckAmountAvailable(fiat)); // 0.01 if (!available) { throw new Exception(String.Format("Not enough funds (USDT): Need {0}", fiat)); } // Order chrome.Eval(Commands.Buy(9, amount)); Debug.End("fill in and click buy: "); // chrome.EvalUntil(Commands.WaitConfirmBuy()); string orderResult; orderResult = chrome.EvalAndGet(Commands.ConfirmBuy()); orderResult = orderResult.Replace("__buffer__", ""); Console.WriteLine(orderResult); OrderResult result = JsonConvert.DeserializeObject <OrderResult>(orderResult); result.Type = OrderResult.BUY; result.Pair = pair; result.Fee = result.TotalCost * (decimal)0.0025; Debug.End("order result: "); chrome.EvalUntil(Commands.ConfirmOrderWait()); chrome.Eval(Commands.ConfirmOrder()); Debug.End("confirm: "); }
private void SetBrowser(Chrome chrome, string pair) { chrome.EvalUntil(Commands.PageLoaded(), 10); chrome.EvalAndGet(Commands.SetElements()); bool logged = chrome.EvalAndGet(Commands.BuyButtonExists()); //if (!logged) // throw new Exception("Login required."); //chrome.Eval(Commands.GotoCoinPage(pair)); //chrome.EvalUntil(Commands.PageLoaded(), 5); //Thread.Sleep(1000); lock (locker) { this.CompleteCount++; if (this.CompleteCount == this.TotalCount) { this.OnComplete(this, new SetBrowsersCompleteEventArgs()); } } }
private void DiscountBuy(string pair, decimal amount) { Chrome chrome = Browsers[pair]; // Order tab chrome.Eval(Commands.ClickBuyTab()); // Check for enough fund decimal fiat = Properties.Settings.Default.CycleMoney * (decimal)2 * 1000; bool available = chrome.EvalAndGet(Commands.CheckAmountAvailable(amount)); if (!available) { throw new Exception(String.Format("Not enough funds (KRW): Need {0}", fiat)); } // Order chrome.Eval(Commands.Buy(9, amount)); }