本文整理汇总了C#中data.NewpriceDataRow方法的典型用法代码示例。如果您正苦于以下问题:C# data.NewpriceDataRow方法的具体用法?C# data.NewpriceDataRow怎么用?C# data.NewpriceDataRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data
的用法示例。
在下文中一共展示了data.NewpriceDataRow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportOHLCV_CSV
//Use the idea from http://www.codeproject.com/KB/database/CsvReader.aspx by Sebastien Lorion
public static bool ImportOHLCV_CSV(string csvFileName, char delimiter, common.dateTimeLibs.DateTimeFormats dataDateFormat,
string stockExchangeForNewCode, CultureInfo culture,
data.baseDS.priceDataDataTable priceDataTbl,
ImportRow ImportRowFunc,
OnUpdatePriceData onUpdateDataFunc,
OnEndImportPriceData onEndImportFunc)
{
libs.importStat myImportStat = new libs.importStat();
myImportStat.Reset();
myImportStat.dateFormat = dataDateFormat;
myImportStat.culture = culture;
data.baseDS.stockCodeDataTable stockCodeTbl = new data.baseDS.stockCodeDataTable();
data.baseDS.priceDataRow priceDataRow;
DataRowView[] foundRows;
application.DbAccess.LoadData(stockCodeTbl, AppTypes.CommonStatus.Enable);
DataView stockCodeView = new DataView(stockCodeTbl);
stockCodeView.Sort = stockCodeTbl.codeColumn.ColumnName;
bool fCanceled = false;
DateTime lastPriceDate = common.Consts.constNullDate;
importOHLCV data;
// open the file "data.csv" which is a CSV file with headers
using (CsvReader csv = new CsvReader(new StreamReader(csvFileName), true, delimiter))
{
// missing fields will not throw an exception,
// but will instead be treated as if there was a null value
csv.MissingFieldAction = MissingFieldAction.ReplaceByNull;
int fieldCount = csv.FieldCount;
if (fieldCount < 7) return false;
while (csv.ReadNextRecord())
{
Application.DoEvents();
myImportStat.dataCount++;
data = ImportRowFunc(csv, myImportStat);
if (myImportStat.cancel)
{
fCanceled = true; break;
}
if (data == null)
{
myImportStat.errorCount++;
continue;
}
//Assume that all price must be valid
if (data.Open <= 0 || data.High <= 0 || data.Low <= 0 || data.Close <= 0) continue;
foundRows = stockCodeView.FindRows(data.code);
if (foundRows.Length == 0)
{
//Try to add new stock code
libs.AddNewCode(data.code, stockExchangeForNewCode, stockCodeTbl);
application.DbAccess.UpdateData(stockCodeTbl);
}
// Ignore all data that was in database
//if (!foundLastPriceDate)
//{
// lastPriceDate = libs.FindLastPriceDate(data.code);
// foundLastPriceDate = true;
//}
if (lastPriceDate != common.Consts.constNullDate && data.dateTime <= lastPriceDate)
{
continue;
}
if (priceDataTbl.FindBystockCodeonDate(data.code, data.dateTime) != null)
{
myImportStat.errorCount++;
continue;
}
myImportStat.updateCount++;
priceDataRow = priceDataTbl.NewpriceDataRow();
commonClass.AppLibs.InitData(priceDataRow);
priceDataRow.stockCode = data.code;
priceDataRow.onDate = data.dateTime;
//Try to fix some error in data
priceDataRow.openPrice = (decimal)data.Open;
priceDataRow.highPrice = (decimal)data.High;
priceDataRow.lowPrice = (decimal)data.Low;
priceDataRow.closePrice = (decimal)data.Close;
priceDataRow.volume = (decimal)data.Volume;
priceDataTbl.AddpriceDataRow(priceDataRow);
if (onUpdateDataFunc != null) onUpdateDataFunc(priceDataRow, myImportStat);
}
}
if (fCanceled)
{
priceDataTbl.Clear();
return false;
}
if (onEndImportFunc != null) onEndImportFunc(priceDataTbl);
return true;
}
示例2: AddImportPrice
// importPrice->priceData
private static void AddImportPrice(data.importDS.importPriceDataTable importPriceTbl,
DailyPrice dailyPrice,data.baseDS.priceDataDataTable priceDataTbl)
{
data.baseDS.priceDataSumRow dailyPriceRow;
data.baseDS.priceDataRow priceDataRow;
decimal volume = 0;
for (int idx = 0; idx < importPriceTbl.Count; idx++)
{
//Invalid price, ignore
if (importPriceTbl[idx].closePrice <= 0) continue;
volume = importPriceTbl[idx].volume;
// If this is totail volume then minus the last volume to get the real volume in the period
if (importPriceTbl[idx].isTotalVolume)
{
dailyPriceRow = dailyPrice.GetData(importPriceTbl[idx]);
if (dailyPriceRow != null)
{
volume -= dailyPriceRow.volume;
}
if (volume <= 0) continue;
}
priceDataRow = priceDataTbl.NewpriceDataRow();
commonClass.AppLibs.InitData(priceDataRow);
priceDataRow.onDate = importPriceTbl[idx].onDate;
priceDataRow.stockCode = importPriceTbl[idx].stockCode;
priceDataRow.openPrice = importPriceTbl[idx].openPrice;
priceDataRow.lowPrice = importPriceTbl[idx].lowPrice;
priceDataRow.highPrice = importPriceTbl[idx].highPrice;
priceDataRow.closePrice = importPriceTbl[idx].closePrice;
priceDataRow.volume = volume;
//Fix other invalid price
if (priceDataRow.highPrice <= 0) priceDataRow.highPrice = priceDataRow.closePrice;
if (priceDataRow.lowPrice <= 0) priceDataRow.highPrice = priceDataRow.lowPrice;
if (priceDataRow.openPrice <= 0) priceDataRow.highPrice = priceDataRow.openPrice;
priceDataTbl.AddpriceDataRow(priceDataRow);
//Update the last row
dailyPrice.UpdateData(importPriceTbl[idx]);
}
}