![]() |
| 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 ... |
|
|||||||
| Notices |
| Data Feeds Real time and end-of-day data feeds. |
![]() |
|
|
Thread Tools |
| Sponsored Links |
|
#11
|
|||
|
|||
|
Quote:
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. |
|
#12
|
|||
|
|||
|
Quote:
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();
}
}
|
|
#13
|
|||
|
|||
|
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: |
|
#14
|
|||
|
|||
|
Awesome, fantastic, brilliant.
I will definitely use it. Please upload NIFTY INDEX historical data in METASTOCK format. |
|
#15
|
|||
|
|||
|
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;
}
}
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 |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
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 |
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.