Esempio n. 1
0
        public void test_More_Sell()
        {
            int maxValue = 1000;

            fileName = "10个线程_买吃卖.txt";
            List <Order> orders = SYRequest.OureyAllOrder(userId, coinSymbol);

            foreach (var order in orders)
            {
                if (SYRequest.QureyCancelOrder(userId, order.orderId))
                {
                    Console.WriteLine("撤单成功!");
                }
            }
            object obj  = SYRequest.QureySell(userId, coinSymbol, "" + maxValue, "102.60");
            string time = DateTime.Now.ToString("yyy-MM-dd HH:mm:ss");

            File.AppendAllText(".\\TradeTest\\" + fileName, maxValue + "手买单已经准备完成。\r\n");
            File.AppendAllText(".\\TradeTest\\" + fileName, "开始吃盘口,分" + maxValue + "笔吃每次吃一手。\r\n");
            File.AppendAllText(".\\TradeTest\\" + fileName, "起始时间:" + time + "\r\n");
            cancelCount = maxValue / 10;
            for (int i = 1; i <= 10; i++)
            {
                th_s = new Thread(new ParameterizedThreadStart(test_More_Sell));
                th_s.Start(this);
            }
        }
Esempio n. 2
0
        public static void test_More_Buy(object o)
        {
            Example exp = o as Example;
            int     i   = exp.cancelCount;
            int     cnt = 0;

            double milSum = 0;
            double secSum = 0;

            while (i-- > 0)
            {
                cnt++;
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start(); //  开始监视代码运行时间

                var resObj = SYRequest.QureySell(exp.userId, exp.coinSymbol, "1", "102.50");

                stopwatch.Stop();                                   //  停止监视
                TimeSpan timespan     = stopwatch.Elapsed;          //  获取当前实例测量得出的总时间
                double   hours        = timespan.TotalHours;        // 总小时
                double   minutes      = timespan.TotalMinutes;      // 总分钟
                double   seconds      = timespan.TotalSeconds;      //  总秒数
                double   milliseconds = timespan.TotalMilliseconds; //  总毫秒数
                Console.WriteLine("第一" + cnt + "次请求,总毫秒数:" + milliseconds);

                milSum += milliseconds;
                secSum += seconds;
            }
            string time = DateTime.Now.ToString("yyy-MM-dd HH:mm:ss");

            File.AppendAllText(".\\TradeTest\\" + exp.fileName, "线程" + exp.thread_number + "结束时间:" + time + "\r\n");
        }
Esempio n. 3
0
 /// <summary>
 /// 转让
 /// </summary>
 /// <param name="_vol">数量</param>
 /// <param name="_price">价格</param>
 /// <returns></returns>
 protected bool Sell(long _vol, double _price, bool beIsMust = false)
 {
     try
     {
         if (position == null)
         {
             position = SYRequest.QureyPosition(userId, coinSymbol);
             if (position == null)
             {
                 Print("转卖仓位不足,无法进行转卖。");
                 return(false);
             }
         }
         if (position.balance <= 0)
         {
             position = SYRequest.QureyPosition(userId, coinSymbol);
             if (position.balance == 0)
             {
                 Print("转卖仓位不足,无法进行转卖。");
                 return(false);
             }
         }
         if (_vol > position.balance)
         {
             Print("转卖数量大于实际持有量,已按实际拥有数量专卖。");
             _vol = (long)position.balance;
         }
         double limit = _price;
         if (limit < lowLimitPrice)
         {
             limit = lowLimitPrice;
         }
         if (limit > upLimitPrice)
         {
             limit = upLimitPrice;
         }
         string             orderId = ProduceOrderID.GetOrderID(EnumBuySellType.转让); //订单ID
         request_OrderLimit ol      = SYRequest.QureySell(userId, coinSymbol, _vol + "", limit + "", orderId);
         if (ol != null)
         {
             position.balance -= _vol;
             Print("订单【转卖】成功!商品编号:" + coinSymbol + ", 数量:" + _vol + ", 价格:" + limit + ", 订单号:" + orderId);
             if (beIsMust == false)
             {
                 orderLimitSells.Add(ol);
             }
             return(true);
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }