Ejemplo n.º 1
0
        public void loadSecurityMaster()
        {
            string [] lines = File.ReadAllLines(@"c:\windows\s2trading\zmqhubresource\contractdetails\SecurityMaster.csv");
            foreach (string line in lines)
            {
                if (line.Contains("ScripNo"))
                {
                    continue;
                }
                //ScripNo,Exch,series,symbol,opttype,StrikePrice,ExpiryDate,MLot
                //ScripNo	underlyingScripNo	Instrument	symbol	tradeSymbol	MLot	expiryDate	StrikePrice	OptType

                string[] arr               = line.Split(',');
                string   TokenNo           = arr[0];
                string   UnderlyingScripNo = arr[1];
                string   Instrument        = arr[2];
                string   Symbol            = arr[3];
                string   TradeSymbol       = arr[4];
                string   MLot              = arr[5];
                string   ExpiryDate        = arr[6];
                string   StrikePrice       = arr[7];
                string   OptType           = arr[8];
                string   fullname          = arr[9];

                SecurityMaster data = new SecurityMaster(TokenNo, UnderlyingScripNo, Instrument, Symbol, TradeSymbol, MLot, ExpiryDate, StrikePrice, OptType, fullname);
                dictSecurityMaster[TokenNo] = data;
            }
        }
Ejemplo n.º 2
0
        public void loadSecurityMaster()
        {
            string [] lines = File.ReadAllLines(@"C:\s2trading\zmqhubresource\SecurityMaster.csv");
            foreach (string line in lines)
            {
                if (line.Contains("ScripNo"))
                {
                    continue;
                }
                //ScripNo,Exch,series,symbol,opttype,StrikePrice,ExpiryDate,MLot

                string[] arr         = line.Split(',');
                string   ScripNo     = arr[0];
                string   Exch        = arr[1];
                string   series      = arr[2];
                string   symbol      = arr[3];
                string   opttype     = arr[4];
                string   StrikePrice = arr[5];
                string   ExpiryDate  = arr[6];
                string   MLot        = arr[7];

                SecurityMaster data = new SecurityMaster(ScripNo, Exch, series, symbol, opttype, StrikePrice, ExpiryDate, MLot);
                dictSecurityMaster[ScripNo] = data;

                // ScripNo -> Symbol -> Exch -> Series -> Expiry -> OptType -> Strike
            }
        }
Ejemplo n.º 3
0
        public void AddListItemMethod()
        {
            //String myItem;
            if (ScannerBox.qfeed.Count > 0)
            {
                Feed feed = ScannerBox.qfeed.Dequeue();
                try
                {
                    string symbol  = "";
                    string expiry  = "";
                    string strike  = "";
                    string callput = "";

                    if (ScannerDashboard.dictSecurityMaster.ContainsKey(feed.tokenno))
                    {
                        SecurityMaster secMaster = ScannerDashboard.dictSecurityMaster[feed.tokenno];
                        symbol = secMaster.Symbol;
                        if (secMaster.Instrument != "EQ") // its a future or option stock,then we will get expirydate
                        {
                            expiry = secMaster.ExpiryDate;
                        }
                        if (secMaster.Instrument == "OPTIDX" || secMaster.Instrument == "OPTSTK")
                        {
                            strike  = secMaster.StrikePrice;
                            callput = secMaster.OptType;
                        }
                    }

                    var exisiting = dtFeed.Rows.Find(new Object[] { feed.tokenno });
                    if (exisiting != null)
                    {
                        exisiting.ItemArray = new object[] { feed.tokenno, feed.feedtime, symbol, expiry, strike, callput, feed.ltp, feed.ltq, feed.bidsize, feed.bidprice, feed.askprice, feed.asksize, Convert.ToString(Math.Round((Convert.ToDouble(feed.askprice) - Convert.ToDouble(feed.bidprice)), 2)) }
                    }
                    ;
                    else
                    {
                        if (ScannerDashboard.dictSecurityMaster.ContainsKey(feed.tokenno))
                        {
                            dtFeed.Rows.Add(new Object[] { feed.tokenno, feed.feedtime, symbol, expiry, strike, callput, feed.ltp, feed.ltq, feed.bidsize, feed.bidprice, feed.askprice, feed.asksize, Convert.ToString(Math.Round((Convert.ToDouble(feed.askprice) - Convert.ToDouble(feed.bidprice)), 2)) });
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Ejemplo n.º 4
0
        public void AddListItemMethod()
        {
            //String myItem;
            if (ScannerBox.qfeed.Count > 0)
            {
                //calculate microseconds
                Feed feed = ScannerBox.qfeed.Dequeue();
                //calculate microseconds
                try
                {
                    string symbol  = "";
                    string expiry  = "";
                    string strike  = "";
                    string callput = "";

                    long   millis      = (long)((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
                    string feedMessage = ScannerBox.qOrgfeed.Dequeue();
                    feedMessage = feedMessage + "," + millis;

                    if (ScannerDashboard.dictSecurityMaster.ContainsKey(feed.tokenno))
                    {
                        SecurityMaster secMaster = ScannerDashboard.dictSecurityMaster[feed.tokenno];
                        symbol = secMaster.Symbol;
                        if (secMaster.Instrument != "EQ") // its a future or option stock,then we will get expirydate
                        {
                            expiry = secMaster.ExpiryDate;
                        }
                        if (secMaster.Instrument == "OPTIDX" || secMaster.Instrument == "OPTSTK")
                        {
                            strike  = secMaster.StrikePrice;
                            callput = secMaster.OptType;
                        }
                    }

                    millis      = (long)((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
                    feedMessage = feedMessage + "," + millis;

                    var exisiting = dtFeed.Rows.Find(new Object[] { feed.tokenno });
                    if (exisiting != null)
                    {
                        exisiting.ItemArray = new object[] { feed.tokenno, feed.feedtime, symbol, expiry, strike, callput, feed.ltp, feed.ltq, feed.bidsize, feed.bidprice, feed.askprice, feed.asksize, Convert.ToString(Math.Round((Convert.ToDouble(feed.askprice) - Convert.ToDouble(feed.bidprice)), 2)) }
                    }
                    ;
                    else
                    {
                        if (ScannerDashboard.dictSecurityMaster.ContainsKey(feed.tokenno))
                        {
                            dtFeed.Rows.Add(new Object[] { feed.tokenno, feed.feedtime, symbol, expiry, strike, callput, feed.ltp, feed.ltq, feed.bidsize, feed.bidprice, feed.askprice, feed.asksize, Convert.ToString(Math.Round((Convert.ToDouble(feed.askprice) - Convert.ToDouble(feed.bidprice)), 2)) });
                        }
                    }

                    millis      = (long)((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
                    feedMessage = feedMessage + "," + millis;

                    //calculate microseconds
                    //Log into file.
                    //feed, time1, time2, time3, time4, time5
                    File.AppendAllText("D:/FeedLog.txt", feedMessage + "\n");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }