Tool to download months old NSE BhavCopy in one go

Discuss Tool to download months old NSE BhavCopy in one go at the Data Feeds within the Traderji.com - Discussion forum for Stocks Commodities & Forex; Originally Posted by pokrate Hi buddy, I have got Amibroker now. Kindly help me in ...


Go Back   Traderji.com - Discussion forum for Stocks Commodities & Forex > TOOLS & RESOURCES > Data Feeds

Notices

Data Feeds Real time and end-of-day data feeds.


Reply
 
Thread Tools
Sponsored Links
  #11  
Old 25th September 2007, 12:45 AM
Member
 
Join Date: Aug 2007
Posts: 13
flyingdeath is on a distinguished road
Default Re: Tool to download months old NSE BhavCopy in one go



Quote:
Originally Posted by pokrate View Post
Hi buddy,
I have got Amibroker now. Kindly help me in managing it.
How to get historical data and how to update data ?
Eagerly awaiting your friendly reply.
Sorry for the late reply. was kindda busy..

I uploaded data for the metastock. You can use same data for metastock also. Search for my old posts. its uploaded at my esnips account.
For updating data you will have to regularly download and convert the data and import into metastock or amibroker.
Reply With Quote
  #12  
Old 25th September 2007, 12:48 AM
Member
 
Join Date: Aug 2007
Posts: 13
flyingdeath is on a distinguished road
Default Re: Tool to download months old NSE BhavCopy in one go

Quote:
Originally Posted by rajuwaste View Post
When I refer NSE bhavcopy there is a mix of EQ and BE series how do you people handle this.For example several entries of same date's data exist in NSE Bhavcopy what should I do to solve this problem.
I was facing the same stupid problem with my EODCoverter as well.. and it screwed up my data big time. Anyways I created a new utility to convert the NSE Bhav Copy to Metastock format text file.
Im attaching the code for the same here. You can modify it as you wish.
Dont have time to write a beautiful application so I apologize for that.

You can use this program in conjuction with my earlier posted BhavCopyDownloder.

Code:
static void Main(string[] args)
        {
            StreamReader reader = null;
            StreamWriter writer = null;
            string fileName = @"C:\Program Files\EODdlc\DATA\NSE\EQUITIES\20070924.csv";
            try
            {
                reader = new StreamReader(fileName);
                writer = new StreamWriter(fileName + ".txt");
                
                string str = reader.ReadLine();
                Console.WriteLine(str);
                writer.WriteLine("<ticker>,<Date>,<open>,<high>,<low>,<close>,<vol>,");
                int i = 0;
                StringBuilder strBuilder = new StringBuilder();
                while (!reader.EndOfStream)
                {
                    str = reader.ReadLine();
                    if (!str.Contains(",EQ,"))
                        Console.WriteLine(str);
                    else
                    {
                        strBuilder.Remove(0, strBuilder.Length);
                        ++i;
                        string[] tempStr = str.Split(new char[] { ',' });
                        DateTime dateTime = DateTime.Parse(tempStr[10]);

                        strBuilder.Append(tempStr[0] + ",");
                        string dateStr = dateTime.Year
                            + (dateTime.Month < 10 ?
                            "0" + dateTime.Month.ToString() : dateTime.Month.ToString()) +
                            (dateTime.Day < 10 ?
                            "0" + dateTime.Day.ToString() : dateTime.Day.ToString());
                        strBuilder.Append(dateStr + ",");
                        strBuilder.Append(tempStr[2] + ",");
                        strBuilder.Append(tempStr[3] + ",");
                        strBuilder.Append(tempStr[4] + ",");
                        strBuilder.Append(tempStr[5] + ",");
                        strBuilder.Append(tempStr[8] + ",");
                        writer.WriteLine(strBuilder.ToString());
                    }
                }
                Console.WriteLine("Total " + i + " Scrips written to the file");
                writer.Flush();
                Console.ReadLine();
            }
            finally
            {
                if (reader != null)
                    reader.Close();
                if (writer != null)
                    writer.Close();
            }
        }
Reply With Quote
  #13  
Old 25th September 2007, 12:49 AM
Member
 
Join Date: Aug 2007
Posts: 13
flyingdeath is on a distinguished road
Talking Re: Tool to download months old NSE BhavCopy in one go

This will only convert the EQ series from the bhavcopy.

Working and tested right now..
I'll myself be using this program only from now onwards: cool:
Reply With Quote
  #14  
Old 25th September 2007, 09:55 AM
Member
 
Join Date: Apr 2007
Posts: 21
pokrate is on a distinguished road
Default Re: Tool to download months old NSE BhavCopy in one go

Awesome, fantastic, brilliant.
I will definitely use it.
Please upload NIFTY INDEX historical data in METASTOCK format.
Reply With Quote
  #15  
Old 26th September 2007, 01:44 AM
Member
 
Join Date: Aug 2007
Posts: 13
flyingdeath is on a distinguished road
Default Re: Tool to download months old NSE BhavCopy in one go

This is the Code and executable for downloading daily NSE Bhavcopy data in Metastock format.

Code:
static void Main(string[] args)
        {
            StreamReader reader = null;
            StreamWriter writer = null;
            //string fileName = @"C:\Program Files\EODdlc\DATA\NSE\EQUITIES\20070924.csv";
            string fileName = DownloadBhavCopy();
            if (String.IsNullOrEmpty(fileName))
            {
                Console.WriteLine("Couldn't download BhavCopy");
                return;
            }
            try
            {
                Console.WriteLine("Converting " + fileName);
                reader = new StreamReader(fileName);
                writer = new StreamWriter(fileName + ".txt");

                string str = reader.ReadLine();
                Console.WriteLine(str);
                writer.WriteLine("<ticker>,<Date>,<open>,<high>,<low>,<close>,<vol>,");
                int i = 0;
                StringBuilder strBuilder = new StringBuilder();
                while (!reader.EndOfStream)
                {
                    str = reader.ReadLine();
                    if (!str.Contains(",EQ,"))
                        Console.WriteLine(str);
                    else
                    {
                        strBuilder.Remove(0, strBuilder.Length);
                        ++i;
                        string[] tempStr = str.Split(new char[] { ',' });
                        DateTime dateTime = DateTime.Parse(tempStr[10]);

                        strBuilder.Append(tempStr[0] + ",");
                        string dateStr = dateTime.Year
                            + (dateTime.Month < 10 ?
                            "0" + dateTime.Month.ToString() : dateTime.Month.ToString()) +
                            (dateTime.Day < 10 ?
                            "0" + dateTime.Day.ToString() : dateTime.Day.ToString());
                        strBuilder.Append(dateStr + ",");
                        strBuilder.Append(tempStr[2] + ",");
                        strBuilder.Append(tempStr[3] + ",");
                        strBuilder.Append(tempStr[4] + ",");
                        strBuilder.Append(tempStr[5] + ",");
                        strBuilder.Append(tempStr[8] + ",");
                        writer.WriteLine(strBuilder.ToString());
                    }
                }
                Console.WriteLine("Total " + i + " Scrips written to the file");
                writer.Flush();
                Console.ReadLine();
            }
            finally
            {
                if (reader != null)
                    reader.Close();
                if (writer != null)
                    writer.Close();
            }
        }
        static string DownloadBhavCopy()
        {
            WebClient client = new WebClient();
            string dlFile = String.Empty;
            FileStream writer;
            try
            {
                string month = monthList[ DateTime.Today.Month - 1];
                string day = (DateTime.Today.Day <= 9) ? "0" + DateTime.Today.Day.ToString() :
                    DateTime.Today.Day.ToString(); ;
                string year = DateTime.Today.Year.ToString();
                Uri uri = new Uri(@"http://www.nse-india.com/content/historical/EQUITIES/2007/");
                Uri tempUri = new Uri(uri, month + "/cm" + day + month + year + "bhav.csv");
                Debug.WriteLine("Downloading " + tempUri.ToString());
                Console.WriteLine("Downloading " + tempUri.ToString());
                byte[] data = client.DownloadData(tempUri);
                dlFile = Path.Combine(Path.GetTempPath()/*@"C:\Program Files\EODdlc\DATA\NSE\EQUITIES"*/, "cm" + day + month + year + "bhav.csv");
                using (writer = File.Create(dlFile))
                {
                    try
                    {
                        writer.Write(data, 0, data.Length);
                    }
                    finally
                    {
                        if (writer != null)
                            writer.Close();
                    }
                }
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError && ex.Message.Contains("404"))
                    Debug.WriteLine("FileNotFound");
                dlFile = string.Empty;
            }
            return dlFile;
        }
    }
@PokRate
Check the following link. I guess it contains NSE Index till 21st August. Look for the ^NSEI or S&N Nifty index

http://www.esnips.com/doc/f08d537c-4.../NSE_MetaStock
Attached Files
File Type: zip ConsoleApplication1.zip (8.4 KB, 22 views)
Reply With Quote
Sponsored Links


Reply

Bookmarks


Advertise Here


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads for: Tool to download months old NSE BhavCopy in one go
Thread Thread Starter Forum Replies Last Post
Power IPOs will take six more months to light up Robbie Initial Public Offers (IPO's) 0 25th November 2006 10:30 AM
6 weeks , 6 months, 6 years . . . mohdbinhaid General Chit Chat 0 9th June 2006 07:33 PM
5 mins intraday data dor 2 months tanewbie Data Feeds 47 18th March 2006 03:19 PM


All times are GMT +5.5. The time now is 02:43 PM.

Indemnity, Disclaimer & Disclosure Notice:
• By visiting Traderji.com you indicate your acceptance of our Forum Rules Disclaimer & Disclosure and indemnify Traderji.com, its associates and related parties of all claims howsoever resulting from the usage of the forum.
Disclaimer: Trading or investing in stocks & commodities is a high risk activity. Any action you choose to take in the markets is totally your own responsibility. Traderji.com will not be liable for any, direct or indirect, consequential or incidental damages or loss arising out of the use of this information.
Disclosure: The information in this forum is neither an offer to sell nor solicitation to buy any of the securities mentioned herein. The writers may or may not be trading in the securities mentioned.
• All names or products mentioned are trademarks or registered trademarks of their respective owners.
General Content Disclaimer Notice:
In light of our policy of encouraging candid, open exchanges of views and the rapid distribution of information originating from many sources, Traderji.com cannot determine the accuracy of information that may be uploaded to the forum. Opinions, advice and all other information expressed by participants in discussions are those of the author. You rely on such information at your own risk. You are urged to seek professional advice for specific, individual situations and not rely solely on advice or opinions given in the discussions. Since Traderji.com is an open and free discussion forum, any comments made by members of this forum in their posts reflect their own views and not of the owner or administrator of Traderji.com. Thus the owner/administrator indemnify themselves of all claims whatsoever and will not be liable or responsible for any members comments/views in this forum Traderji.com. If you find any objectionable or offensive posts made by members of this forum which you would like to bring to our notice for removal then please Contact Us.
 


Copyright © 2001 - 2008, Traderji.com All Rights Reserved.

Recommended Websites - www.TradersEdgeIndia.com - www.TradingPicks.com - www.MasterOfTrading.com