示例#1
0
        public void TD_RequestAsyncLevel2Streaming(string symbol, Level2DataSource Level2DataSourceType, Form oForm)
        {
            /*/
             * Old code used for requesting NON-TotalView based on compressed data.
            /*/
            //string _streamerCommand = "S=" + this.getLevel2SourceName(Level2DataSourceType) + "&C=SUBS&P=" + symbol + "&T=0+1";

            /*/
             * New code used for requesting TotalView based on uncompressed data.
            /*/


            string _streamerCommand = "S=TOTAL_VIEW&C=SUBS&P=" + symbol + ">L2&T=0+1+2+3";



            if (this.TD_loginStatus == true)
            {

                XMLHTTP xmlHttp_ = new XMLHTTP();
                StringBuilder cpostdata = new StringBuilder();
                string lcPostUrl = string.Empty;

                cpostdata.Append("!U=" + _accountid);
                cpostdata.Append("&W=" + _token);
                cpostdata.Append("&A=userid=" + _accountid);
                cpostdata.Append("&token=" + _token);
                cpostdata.Append("&company=" + _company);
                cpostdata.Append("&segment=" + _segment);
                cpostdata.Append("&cddomain=" + _cdDomain);
                cpostdata.Append("&usergroup=" + _usergroup);
                cpostdata.Append("&accesslevel=" + _accesslevel);
                cpostdata.Append("&authorized=" + _authorized);
                cpostdata.Append("&acl=" + _acl);
                cpostdata.Append("&timestamp=" + _timestamp);
                cpostdata.Append("&appid=" + _appid);
                cpostdata.Append("|" + _streamerCommand);

                string encodedString = Encode_URL(cpostdata.ToString());
                cpostdata = new StringBuilder();
                cpostdata.Append(encodedString);

                lcPostUrl = "http://" + this._streamerurl + "/" + cpostdata;

                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(lcPostUrl);
                req.ContentType = "application/x-www-form-urlencoded";
                req.Accept = "Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*";
                req.Method = "GET";
                req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                req.Timeout = 60000;
                req.ServicePoint.ConnectionLimit = 50;



                //// Add the request into the state so it can be passed around

                this.rs_LevelTwoStreaming = new RequestState();
                //this.rs_LevelTwoStreaming.TickWithArgs += new AmeritradeBrokerAPI.EventHandlerWithArgs(((Form1)oForm).processEvent);
                this.rs_LevelTwoStreaming.oParentForm = oForm;
                this.rs_LevelTwoStreaming.lNewStockSymbol = false;


                this.rs_LevelTwoStreaming.oParent = this;
                this.rs_LevelTwoStreaming.Level2DataSourceType = Level2DataSourceType;
                this.rs_LevelTwoStreaming.stockSymbol = symbol;
                this.rs_LevelTwoStreaming.ServiceName = Level2DataSourceType.ToString();
                this.rs_LevelTwoStreaming.Request = req;
                this.rs_LevelTwoStreaming.FunctionType = RequestState.AsyncType.LevelTwoStreaming;

                // Issue the async request                
                IAsyncResult r = (IAsyncResult)req.BeginGetResponse(new AsyncCallback(RespCallback), this.rs_LevelTwoStreaming);
            }

        }
示例#2
0
        public string getLevel2SourceName(Level2DataSource Level2Source)
        {
            string cReplySource = string.Empty;

            switch (Level2Source)
            {
                case Level2DataSource.AMEX:
                    cReplySource = "NYSE_BOOK";
                    break;

                case Level2DataSource.NYSE:
                    cReplySource = "NYSE_BOOK";
                    break;

                case Level2DataSource.NASDAQ:
                    cReplySource = "LEVELII";
                    break;

                case Level2DataSource.INET:
                    cReplySource = "ADAP_INET";
                    break;

                default:
                    cReplySource = "NYSE_BOOK";
                    break;

            }

            return cReplySource;
        }