public void test_More_Buy() { 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.QureyBuy(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_Buy)); th_s.Start(this); } }
/// <summary> /// 购买 /// </summary> /// <param name="_vol">数量</param> /// <param name="_price">价格</param> /// <returns></returns> protected bool Buy(int _vol, double _price, bool beIsMust = false) { try { double limit = _price; if (limit > upLimitPrice) { limit = upLimitPrice; } request_OrderLimit ol = SYRequest.QureyBuy(userId, coinSymbol, _vol + "", limit + ""); if (ol != null) { Print("订单【买入】成功!商品编号:" + coinSymbol + ", 数量:" + _vol + ", 价格:" + limit); if (beIsMust == false) { orderLimitBuys.Add(ol); } return(true); } return(false); } catch { return(false); } }
public static void test_More_Sell(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.QureyBuy(exp.userId, exp.coinSymbol, "1", "102.70"); 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"); }
/// <summary> /// 购买 /// </summary> /// <param name="_vol">数量</param> /// <param name="_price">价格</param> /// <returns></returns> protected bool Buy(int _vol, double _price, bool beIsMust = false) { try { double limit = _price; if (limit > upLimitPrice) { limit = upLimitPrice; } if (limit < lowLimitPrice) { limit = lowLimitPrice; } string orderId = ProduceOrderID.GetOrderID(EnumBuySellType.购买); //订单ID request_OrderLimit ol = SYRequest.QureyBuy(userId, coinSymbol, _vol + "", limit + "", orderId); if (ol != null) { Print("订单【买入】成功!商品编号:" + coinSymbol + ", 数量:" + _vol + ", 价格:" + limit + ", 订单号:" + orderId); if (beIsMust == false) { orderLimitBuys.Add(ol); } return(true); } return(false); } catch { return(false); } }