Exemplo n.º 1
0
        static void InsertChaosRecord()
        {
            if (chaosAccount == 0)
            {
                Thread.Sleep(500);
                return;
            }
            Random r   = new Random((int)DateTime.Now.Ticks);
            int    max = r.Next(100, 500);
            List <TradeOpenModel> list = new List <TradeOpenModel>();

            for (int i = 0; i < r.Next(100, 500); i++)
            {
                var model = new TradeOpenModel();
                model.Cmd        = 0;
                model.OrderBy    = chaosAccount;
                model.Symbol     = MainForm.monitorSymbol;
                model.Volume     = 1 * 100;
                model.StopLoss   = 0;
                model.TakeProfit = 0;
                model.Price      = 100;
                list.Add(model);
            }
            TradeOpenRsponseModel[] responses = CustomService.Service.TradeOpenAll(list.ToArray());
            foreach (var item in responses)
            {
                WriteLogs(JsonConvert.SerializeObject(item));
            }
            Thread.Sleep(1000);
        }
Exemplo n.º 2
0
        private async void btnOpen_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtVlome.Text) || comCmd.SelectedItem == null || cmbSymbol.SelectedItem == null)
            {
                MessageBox.Show("请填写完整开仓信息");
            }
            else
            {
                string cmd = comCmd.SelectedItem.ToString().Trim();
                int    intcmd = 0, volume = 0;
                double price = 0;

                List <TradeOpenModel> trades = new List <TradeOpenModel>();
                SymbolInfoSE          symbol = Core.CustomService.Service.GetSymbolInfo(cmbSymbol.SelectedItem.ToString());
                if (symbol == null)
                {
                    MessageBox.Show("获取Symbol信息失败,请重试!");
                    return;
                }
                //转化买卖方向

                if (!int.TryParse(txtVlome.Text, out volume))
                {
                    MessageBox.Show("请填写正确的手数");
                    return;
                }
                if (cmd == "sell")
                {
                    price  = symbol.Bid;
                    intcmd = 1;
                }
                else
                {
                    price = symbol.Ask;
                }

                foreach (DataGridViewRow row in dataGridViewOpenData.Rows)
                {
                    int            loginid = Convert.ToInt32(row.Cells["LoginId"].Value);
                    TradeOpenModel trade   = new TradeOpenModel();
                    trade.Symbol      = cmbSymbol.SelectedItem.ToString().ToUpper();
                    trade.Cmd         = intcmd;
                    trade.StopLoss    = 0;
                    trade.TakeProfit  = 0;
                    trade.OrderBy     = loginid;
                    trade.Volume      = volume * 100;
                    trade.Order       = 0;
                    trade.IeDeviation = 0;
                    trade.Expiration  = DateTime.Now;
                    trade.Price       = price;
                    trades.Add(trade);
                }
                loading.ShowLoading();
                TradeOpenRsponseModel[] responseModels = await Core.CustomService.Service.TradeOpenAllAsync(trades.ToArray());

                loading.HideLoading();
                StringBuilder sbMessage = new StringBuilder();
                foreach (TradeOpenRsponseModel response in responseModels)
                {
                    if (response.ErrorCode == -1)
                    {
                        _log.Fatal(JsonConvert.SerializeObject(response));
                        sbMessage.AppendFormat("Account :{0} Message:{1}", response.OpenModel.OrderBy, response.ErrorDescription);
                        sbMessage.AppendLine();
                        continue;
                    }
                    else
                    {
                        _log.Info(JsonConvert.SerializeObject(response));
                    }
                }
                if (sbMessage.Length == 0)
                {
                    MessageBox.Show("批量开仓成功!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("开仓失败账户:\r\b" + sbMessage.ToString());
                }
            }
        }
Exemplo n.º 3
0
 static void InsertChaosRecord()
 {
     if (chaosAccount == 0)
     {
         Thread.Sleep(500);
         return;
     }
     Random r = new Random((int)DateTime.Now.Ticks);
     int max = r.Next(100, 500);
     List<TradeOpenModel> list = new List<TradeOpenModel>();
     for (int i = 0; i < r.Next(100, 500); i++)
     {
         var model = new TradeOpenModel();
         model.Cmd = 0;
         model.OrderBy = chaosAccount;
         model.Symbol =MainForm.monitorSymbol;
         model.Volume = 1 * 100;
         model.StopLoss = 0;
         model.TakeProfit = 0;
         model.Price = 100;
         list.Add(model);
     }
     TradeOpenRsponseModel[] responses = CustomService.Service.TradeOpenAll(list.ToArray());
     foreach (var item in responses)
     {
         WriteLogs(JsonConvert.SerializeObject(item));
     }
     Thread.Sleep(1000);
 }
Exemplo n.º 4
0
        private async void btnOpen_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtVlome.Text) || comCmd.SelectedItem == null || cmbSymbol.SelectedItem == null)
            {
                MessageBox.Show("请填写完整开仓信息");
            }
            else
            {
                string cmd = comCmd.SelectedItem.ToString().Trim();
                int intcmd = 0, volume = 0;
                double price = 0;

                List<TradeOpenModel> trades = new List<TradeOpenModel>();
                SymbolInfoSE symbol = Core.CustomService.Service.GetSymbolInfo(cmbSymbol.SelectedItem.ToString());
                if (symbol == null)
                {
                    MessageBox.Show("获取Symbol信息失败,请重试!");
                    return;
                }
                //转化买卖方向

                if (!int.TryParse(txtVlome.Text, out volume))
                {
                    MessageBox.Show("请填写正确的手数");
                    return;
                }
                if (cmd == "sell")
                {
                    price = symbol.Bid;
                    intcmd = 1;
                }
                else
                {
                    price = symbol.Ask;
                }

                foreach (DataGridViewRow row in dataGridViewOpenData.Rows)
                {
                    int loginid = Convert.ToInt32(row.Cells["LoginId"].Value);
                    TradeOpenModel trade = new TradeOpenModel();
                    trade.Symbol = cmbSymbol.SelectedItem.ToString().ToUpper();
                    trade.Cmd = intcmd;
                    trade.StopLoss = 0;
                    trade.TakeProfit = 0;
                    trade.OrderBy = loginid;
                    trade.Volume = volume * 100;
                    trade.Order = 0;
                    trade.IeDeviation = 0;
                    trade.Expiration = DateTime.Now;
                    trade.Price = price;
                    trades.Add(trade);
                }
                loading.ShowLoading();
                TradeOpenRsponseModel[] responseModels = await Core.CustomService.Service.TradeOpenAllAsync(trades.ToArray());
                loading.HideLoading();
                StringBuilder sbMessage = new StringBuilder();
                foreach (TradeOpenRsponseModel response in responseModels)
                {
                    if (response.ErrorCode == -1)
                    {
                        _log.Fatal(JsonConvert.SerializeObject(response));
                        sbMessage.AppendFormat("Account :{0} Message:{1}", response.OpenModel.OrderBy, response.ErrorDescription);
                        sbMessage.AppendLine();
                        continue;
                    }
                    else
                    {
                        _log.Info(JsonConvert.SerializeObject(response));
                    }
                }
                if (sbMessage.Length == 0)
                {
                    MessageBox.Show("批量开仓成功!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("开仓失败账户:\r\b" + sbMessage.ToString());
                }
            }
        }