本文整理汇总了C#中StockSerie.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# StockSerie.Remove方法的具体用法?C# StockSerie.Remove怎么用?C# StockSerie.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockSerie
的用法示例。
在下文中一共展示了StockSerie.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseIntradayData
private static void ParseIntradayData(StockSerie stockSerie, string folder, string fileName)
{
try
{
if (File.Exists(folder + "\\" + fileName))
{
using (StreamReader sr = new StreamReader(folder + "\\" + fileName))
{
string line = sr.ReadLine();
string[] row = line.Replace("\"", "").Replace(" - ", ",").Split(',');
if (row.Length == 7)
{
try
{
StockDailyValue dailyValue = new StockDailyValue(stockSerie.StockName,
float.Parse(row[2], usCulture),
float.Parse(row[4], usCulture),
float.Parse(row[3], usCulture),
float.Parse(row[5], usCulture),
long.Parse(row[6]),
DateTime.Parse(row[0] + " " + row[1], usCulture));
StockDailyValue lastValue = stockSerie.Values.Last();
if (lastValue.DATE.Date == dailyValue.DATE.Date)
{
if (lastValue.DATE.Hour == 0 && lastValue.DATE.Minute == 0) return;
stockSerie.Remove(lastValue.DATE);
}
stockSerie.Add(dailyValue.DATE, dailyValue);
stockSerie.ClearBarDurationCache();
}
catch (System.Exception e)
{
StockLog.Write("Unable to parse intraday data for " + stockSerie.StockName);
StockLog.Write(line);
StockLog.Write(e);
}
}
}
}
}
catch (System.Exception e)
{
StockLog.Write("Unable to parse intraday data for " + stockSerie.StockName);
StockLog.Write(e);
}
}
示例2: DownloadDailyData
public override bool DownloadDailyData(string rootFolder, StockSerie stockSerie)
{
StockLog.Write("DownloadDailyData Group: " + stockSerie.StockGroup + " - " + stockSerie.StockName);
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
{
bool isUpTodate = false;
stockSerie.Initialise();
if (stockSerie.Count > 0)
{
DateTime lastDate = stockSerie.Keys.Last();
if (lastDate.TimeOfDay != TimeSpan.Zero)
{
stockSerie.Remove(lastDate);
lastDate = stockSerie.Keys.Last();
}
isUpTodate = (lastDate >= DateTime.Today) ||
(lastDate.DayOfWeek == DayOfWeek.Friday && (DateTime.Now - lastDate).Days <= 3 &&
(DateTime.Today.DayOfWeek == DayOfWeek.Monday && DateTime.Now.Hour < 18)) ||
(lastDate == DateTime.Today.AddDays(-1) && DateTime.Now.Hour < 18);
if (!isUpTodate)
{
NotifyProgress("Downloading " + stockSerie.StockGroup.ToString() + " - " + stockSerie.StockName);
// Happy new year !!! it's time to archive old data...
for (int year = lastDate.Year; year < DateTime.Today.Year; year++)
{
if (
!File.Exists(rootFolder + ARCHIVE_FOLDER + "\\" + stockSerie.ShortName + "_" +
stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" +
year.ToString() + ".csv"))
{
this.DownloadFileFromProvider(rootFolder + ARCHIVE_FOLDER,
stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() +
"_" + year.ToString() + ".csv", new DateTime(year, 1, 1), new DateTime(year, 12, 31),
stockSerie.ShortName);
}
}
DateTime startDate = new DateTime(DateTime.Today.Year, 01, 01);
string fileName = stockSerie.ShortName + "_" + stockSerie.StockName + "_" +
stockSerie.StockGroup.ToString() + ".csv";
this.DownloadFileFromProvider(rootFolder + ABC_DAILY_FOLDER, fileName, startDate, DateTime.Today,
stockSerie.ISIN);
if (stockSerie.StockName == "CAC40")
// Check if something new has been downloaded using CAC40 as the reference for all downloads
{
this.ParseCSVFile(stockSerie, rootFolder + ABC_DAILY_FOLDER + "\\" + fileName);
if (lastDate == stockSerie.Keys.Last())
{
this.needDownload = false;
}
else
{
DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "eurolistap");
DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "eurolistbp");
DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "eurolistcp");
DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "alterp");
//DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "srdp");
DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "sp500u");
DownloadMonthlyFileFromABC(rootFolder + ABC_DAILY_FOLDER, DateTime.Today, "indicessecp");
}
}
}
else
{
if (stockSerie.StockName == "CAC40")
// Check if something new has been downloaded using CAC40 as the reference for all downloads
{
this.needDownload = false;
}
}
stockSerie.IsInitialised = isUpTodate; // && !needReloadIntraday; Why need reload intraday ???
}
else
{
NotifyProgress("Creating archive for " + stockSerie.StockName + " - " + stockSerie.StockGroup.ToString());
DateTime lastDate = new DateTime(DateTime.Today.Year, 01, 01);
if (stockSerie.StockName == "CAC40")
{
for (int m = DateTime.Today.Month - 1; m >= 1; m--)
{
DateTime month = new DateTime(lastDate.Year, m, 1);
DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistap");
DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistbp");
DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "eurolistcp");
DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "alterp");
//DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "srdp");
DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "sp500u");
DownloadMonthlyFileFromABC(rootFolder + ARCHIVE_FOLDER, month, "indicessecp");
}
}
for (int i = lastDate.Year - 1; i > ARCHIVE_START_YEAR; i--)
{
if (
!this.DownloadFileFromProvider(rootFolder + ARCHIVE_FOLDER,
stockSerie.ShortName + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + "_" +
i.ToString() + ".csv", new DateTime(i, 1, 1), new DateTime(i, 12, 31), stockSerie.ISIN))
//.........这里部分代码省略.........