Ejemplo n.º 1
0
        protected override TraderResult internalBuyStock(string code, float price, int amount)
        {
            const int ID_TXT_CODE  = 0x0408;
            const int ID_TXT_PRICE = 0x0409;
            const int ID_TXT_NUM   = 0x040A;
            const int ID_BTN_BUY   = 0x3EE;

            ClickBuyTreeViewItem();

            // 设定代码,价格,数量
            IntPtr hBuySell = GetDetailPanel();

            Win32API.SendDlgItemMessage(hBuySell, ID_TXT_CODE, Win32Code.WM_SETTEXT, 0, code);
            PeekAndDelay(50);
            Win32API.SendDlgItemMessage(hBuySell, ID_TXT_PRICE, Win32Code.WM_SETTEXT, 0, price.ToString());
            Win32API.SendDlgItemMessage(hBuySell, ID_TXT_NUM, Win32Code.WM_SETTEXT, 0, amount.ToString());

            // 点击买入按钮
            Win32API.PostMessage(hBuySell, Win32Code.WM_COMMAND, ID_BTN_BUY, 0);

            int no = waitAndGetTradeID(hBuySell, code, price, amount);

            TraderResult result = new TraderResult();

            result.Code      = TraderResultEnum.SUCCESS;
            result.EntrustNo = no;
            return(result);
        }
Ejemplo n.º 2
0
        public TraderResult CancelStock(int entrustNo)
        {
            TraderResult ret = internalCancelStock(entrustNo);

            switch (ret.Code)
            {
            case TraderResultEnum.TIMEOUT:
                return(CancelStock(entrustNo));

            case TraderResultEnum.UNLOGIN:
                Login();
                return(CancelStock(entrustNo));

            case TraderResultEnum.ERROR:
            case TraderResultEnum.SUCCESS:
                return(ret);

            default:
                return(null);
            }
        }
Ejemplo n.º 3
0
        public TraderResult GetTradingAccountInfo()
        {
            TraderResult ret = internalGetTradingAccountInfo();

            switch (ret.Code)
            {
            case TraderResultEnum.TIMEOUT:
                return(GetTradingAccountInfo());

            case TraderResultEnum.UNLOGIN:
                Login();
                return(GetTradingAccountInfo());

            case TraderResultEnum.ERROR:
            case TraderResultEnum.SUCCESS:
                return(ret);

            default:
                return(null);
            }
        }
Ejemplo n.º 4
0
        public TraderResult BuyStock(string code, float price, int num)
        {
            lock (this)
            {
                TraderResult ret = internalBuyStock(code, price, num);
                switch (ret.Code)
                {
                case TraderResultEnum.TIMEOUT:
                    return(BuyStock(code, price, num));

                case TraderResultEnum.UNLOGIN:
                    Login();
                    return(BuyStock(code, price, num));

                case TraderResultEnum.ERROR:
                case TraderResultEnum.SUCCESS:
                    return(ret);

                default:
                    return(null);
                }
            }
        }
Ejemplo n.º 5
0
        protected override TraderResult internalBuyStock(string code, float price, int amount)
        {
            const int ID_TXT_CODE = 0x0408;
            const int ID_TXT_PRICE = 0x0409;
            const int ID_TXT_NUM = 0x040A;
            const int ID_BTN_BUY = 0x3EE;

            ClickBuyTreeViewItem();

            // 设定代码,价格,数量
            IntPtr hBuySell = GetDetailPanel();
            Win32API.SendDlgItemMessage(hBuySell, ID_TXT_CODE, Win32Code.WM_SETTEXT, 0, code);
            PeekAndDelay(50);
            Win32API.SendDlgItemMessage(hBuySell, ID_TXT_PRICE, Win32Code.WM_SETTEXT, 0, price.ToString());
            Win32API.SendDlgItemMessage(hBuySell, ID_TXT_NUM, Win32Code.WM_SETTEXT, 0, amount.ToString());

            // 点击买入按钮
            Win32API.PostMessage(hBuySell, Win32Code.WM_COMMAND, ID_BTN_BUY, 0);

            int no = waitAndGetTradeID(hBuySell, code, price, amount);

            TraderResult result = new TraderResult();
            result.Code = TraderResultEnum.SUCCESS;
            result.EntrustNo = no;
            return result;
        }