Ejemplo n.º 1
0
        private List <StockInfo> getstoke(string code)
        {
            Sina             con = new Sina();
            List <StockInfo> now = new List <StockInfo>();

            now = con.GetCurrent(code);
            return(now);
        }
Ejemplo n.º 2
0
 public void ToWeiBo(ResultItem item)
 {
     if (_sina == null)
     {
         _sina = new Sina(openAuth);
         _sina.UpdateUIEvent += _sina_UpdateUIEvent;
     }
     _sina.PostMsg(new FileInfo(System.Windows.Forms.Application.StartupPath + "/1.png"),
                   string.Format(item.Title + Encode.UrlDecode("%0A") +
                                 "现价:{0} 【用券价:{1}】" + Encode.UrlDecode("%0A") +
                                 "{2}" + Encode.UrlDecode("%0A") +
                                 "优惠券地址:{3}" + Encode.UrlDecode("%0A") +
                                 "购买地址:{4}" + Encode.UrlDecode("%0A") + txt_sina_ht.Text, item.Org_Price, item.Price, item.Introduce, item.Quan_link, item.ali_click));
 }
        public tt getselllist(string code, double price, double sum)
        {
            tt               t   = new tt();
            Sina             con = new Sina();
            List <StockInfo> now = new List <StockInfo>();

            now = con.GetCurrent(code);
            if (now[0].Name == null)
            {
                t.direction = null;
                return(t);
            }
            t.price     = price;
            t.code      = code;
            t.name      = now[0].Name;
            t.direction = "卖出";
            t.current   = now[0].Current;
            t.amount    = (int)Math.Ceiling(sum / 200 / price) * 100;
            t.profit    = t.amount * price * (1 - double.Parse(yjfl.Text) - double.Parse(yhsl.Text) - double.Parse(rqlx.Text) * int.Parse(rqday.Text) / 365) - t.amount * t.current * (1 + double.Parse(yjfl.Text));
            return(t);
        }
        private int show(ListView listview, string code, int state)
        {
            if (update == 1)
            {
                listview.EndUpdate();
            }
            listview.BeginUpdate();
            update = 1;
            listview.Items.Clear();
            Sina             con = new Sina();
            List <StockInfo> now = new List <StockInfo>();

            now = con.GetCurrent(code);
            if (now[0].Name == null)
            {
                return(0);
            }
            if (state == 1)
            {
                Buyname.Text = now[0].Name;
                buytime.Text = now[0].Time.TimeOfDay.ToString();
            }
            if (state == 2)
            {
                Sellname.Text = now[0].Name;
                selltime.Text = now[0].Time.TimeOfDay.ToString();
            }
            ListViewItem items;

            items = new ListViewItem("卖五");
            items.SubItems.Add(now[0].SellList[4].Price.ToString());
            items.SubItems.Add(now[0].SellList[4].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("卖四");
            items.SubItems.Add(now[0].SellList[3].Price.ToString());
            items.SubItems.Add(now[0].SellList[3].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("卖三");
            items.SubItems.Add(now[0].SellList[2].Price.ToString());
            items.SubItems.Add(now[0].SellList[2].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("卖二");
            items.SubItems.Add(now[0].SellList[1].Price.ToString());
            items.SubItems.Add(now[0].SellList[1].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("卖一");
            items.SubItems.Add(now[0].SellList[0].Price.ToString());
            items.SubItems.Add(now[0].SellList[0].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("最新");
            items.SubItems.Add(now[0].Current.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("买一");
            items.SubItems.Add(now[0].BuyList[0].Price.ToString());
            items.SubItems.Add(now[0].BuyList[0].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("买二");
            items.SubItems.Add(now[0].BuyList[1].Price.ToString());
            items.SubItems.Add(now[0].BuyList[1].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("买三");
            items.SubItems.Add(now[0].BuyList[2].Price.ToString());
            items.SubItems.Add(now[0].BuyList[2].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("买四");
            items.SubItems.Add(now[0].BuyList[3].Price.ToString());
            items.SubItems.Add(now[0].BuyList[3].Amount.ToString());
            listview.Items.Add(items);
            items = new ListViewItem("买五");
            items.SubItems.Add(now[0].BuyList[4].Price.ToString());
            items.SubItems.Add(now[0].BuyList[4].Amount.ToString());
            listview.Items.Add(items);
            update = 0;
            listview.EndUpdate();
            return(1);
        }
Ejemplo n.º 5
0
        private void Watching_Click(object sender, RoutedEventArgs e)
        {
            myThread temp = new myThread();

            if (string.IsNullOrWhiteSpace(buycode.Text) || string.IsNullOrWhiteSpace(buyprice.Text) || string.IsNullOrWhiteSpace(buyamount.Text))
            {
                ModernDialog.ShowMessage("输入错误", "", MessageBoxButton.OK);
            }
            else
            {
                Auto con = new Auto();
                temp.Code   = buycode.Text;
                temp.Price  = double.Parse(buyprice.Text);
                temp.Amount = int.Parse(buyamount.Text);

                temp.State = (SelectState)(this.SelectDealState.SelectedIndex);

                thishwnd      = con.GetWindowHwnd("融资融券");
                temp.mainhwnd = thishwnd;
                temp.treeview = tv;
                temp.window   = this;
                int inputlength = buyprice.Text.Length - buyprice.Text.IndexOf(".") - 1;

                double           pz = 0, pd = 0;
                Sina             link = new Sina();
                List <StockInfo> now  = new List <StockInfo>();
                now = link.GetCurrent(temp.Code);
                int length = now[0].YesterdayClose.ToString().Length - now[0].YesterdayClose.ToString().IndexOf(".") - 1;
                if (length == 2)
                {
                    pz = (double)((int)((now[0].YesterdayClose * 1.1 + 0.005) * 100)) / 100;
                    pd = (double)((int)((now[0].YesterdayClose * 0.9 + 0.005) * 100)) / 100;
                }
                else if (length == 3)
                {
                    pz = (double)((int)((now[0].YesterdayClose * 1.1 + 0.0005) * 1000)) / 1000;
                    pd = (double)((int)((now[0].YesterdayClose * 0.9 + 0.0005) * 1000)) / 1000;
                }

                if (temp.Amount % 100 != 0 || inputlength > 3)
                {
                    ModernDialog.ShowMessage("输入错误", "", MessageBoxButton.OK);
                }
                else if (temp.Price > pz || temp.Price < pd)
                {
                    ModernDialog.ShowMessage("输入价格超出当天涨跌停限制", "", MessageBoxButton.OK);
                }
                else
                {
                    DateTime  time  = DateTime.Now;
                    string    st    = time.ToLongTimeString();
                    watchitem tempw = new watchitem {
                        Name = now[0].Name, Code = temp.Code, WatchPrice = temp.Price, Amount = temp.Amount, Time = st, State = temp.State
                    };
                    temp.Select = tempw;
                    Thread t = new Thread(new ThreadStart(temp.autobuy));
                    t.IsBackground = true;
                    //t.Name = "监控" + ('0'+sysint);
                    //sysint++;
                    t.Start();
                    Systhread.Add(st, t);
                    watchitems.Add(tempw);
                }
            }
        }
Ejemplo n.º 6
0
            public void autobuy()
            {
                bool       flag = false;
                InputStock temp = new InputStock();

                temp.Code   = this.Code;
                temp.Price  = this.Price;
                temp.Amount = this.Amount;
                temp.State  = (DealState)((int)this.State + 1);
                List <StockInfo> now = new List <StockInfo>();

                while (true)
                {
                    Sina con = new Sina();
                    now = con.GetCurrent(temp.Code);
                    if (now[0].Name == null)
                    {
                        break;
                    }
                    if (temp.Price == now[0].Current)
                    {
                        flag = true;
                        break;
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                }
                if (flag)
                {
                    if (treeview.Count != 7)
                    {
                        window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "未匹配到下单软件");
                    }
                    else
                    {
                        Auto auto = new Auto();
                        bool t    = auto.AutoSelect(treeview, this.State.ToString());
                        if (t)
                        {
                            System.Threading.Thread.Sleep(300);
                            int i = auto.AutoBuy(temp);
                            auto.SetWindow(mainhwnd);

                            /*
                             *  return 0 成功操作
                             *  return 1 没找到button
                             *  return 2 没有找到msg标题
                             *  return 3 没找到button与text
                             *  return 4 输入价格超出当天涨跌停限制
                             *  return 5 msg标题没有匹配的操作
                             *  return 6 tv选择与操作不匹配
                             *  return 7 输入stock错误
                             *  return 8 没有找到相应窗体
                             *  return 9 没有找到下单程序
                             */
                            if (i == 0)
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "成功下单");
                                window.Dispatcher.BeginInvoke(new removeitem(remove), Select);
                            }
                            else if (i == 4)
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "输入价格超出当天涨跌停限制");
                            }
                            else if (i == 5)
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "弹出消息框未知");
                            }
                            else if (i == 6)
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "选择不匹配");
                            }
                            else if (i == 7)
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "输入数据不正确");
                            }
                            else if (i == 8)
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "获取窗体出错");
                            }
                            else if (i == 9)
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "未启动下单软件");
                            }
                            else if (i > 10)
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "发生未知错误");
                            }
                            else
                            {
                                window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "控件获取发生错误");
                            }
                        }
                        else
                        {
                            window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "选择出错");
                        }
                    }
                }
                else
                {
                    window.Dispatcher.BeginInvoke(new showmsg(showmsgbx), "无法获取当前股票价格");
                }
            }