Exemplo n.º 1
0
        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: ");
        }
Exemplo n.º 2
0
        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());
                }
            }
        }