Take a look at the following code snippets to see how to use MetaLib in your project!
Reading MetaStock directories
Use the following code to display all security details (name, symbol, periodicity, etc.) of a MetaStock directory in a console window.
private
void ShowSecurityDetails()
{
MetaLib m =
new
MetaLib();
m.OpenDirectory("C:\\MetaStock",
System.IO.FileAccess.ReadWrite);
int nrSec =
m.Securities.Count;
if (nrSec == 0)
{
Console.WriteLine("No
securities are stored in the directory!");
return;
}
for
(int i = 0; i < nrSec; i++)
{
Console.WriteLine("Security
name: " + m.Securities[i].Name);
Console.WriteLine("Security
symbol: " + m.Securities[i].Symbol);
Console.WriteLine("Start
date: " + m.Securities[i].StartDate.MLDate);
Console.WriteLine("Last
date: " + m.Securities[i].LastDate.MLDate);
Console.WriteLine("Periodicity:
" + m.Securities[i].Periodicity.ToString());
Console.WriteLine("Interval:
" + m.Securities[i].Interval.ToString ());
Console.WriteLine("Price
record file: " + m.Securities[i].FileName);
}
m.CloseDirectory();
}
|