在C#中管理时间序列 [英] Managing timeseries in c#
问题描述
我想就您认为在c#中管理时间序列的最佳方法是什么发表您的看法.我需要有一个二维矩阵,如Datetime对象,作为行的索引(有序且无重复),每列将代表相关Datetime的库存值.我想知道这些对象中的任何一个是否能够处理某个日期的缺失数据:添加列或时间序列会在行索引中添加缺失的日期,并且会为"null"或"N/a"添加现有日期缺少值.
I wanted to have your opinion on what is the best way to manage time series in c# according to you. I need to have a 2 dimensions matrix-like with Datetime object as an index of rows (ordered and without duplicate) and each columns would represent the stock value for the relevant Datetime. I would like to know if any of those objects would be able to handle missing data for a date: adding a column or a time serie would add the missing date in the row index and would add "null" or "N/a" for missing values for existing dates.
与c ++相比,c#已经提供了很多东西,我不想错过任何显而易见的东西.
A lot of stuff are already available in c# compared to c++ and I don't want to miss something obvious.
推荐答案
You could use a mapping between the date and the stock value, such as Dictionary<DateTime, decimal>
. This way the dates can be sparse.
如果您需要每个日期多个股票的价格,而并非每个日期都出现每只股票,则可以在 Dictionary< DateTime,Dictionary< Stock,decimal>>之间进行选择;
和 Dictionary< Stock,Dictionary< DateTime,decimal>>
,具体取决于您以后如何访问这些值(或者即使您不介意两次存储这些值,也可以同时访问这两个值)).
If you need the prices of multiple stocks at each date, and not every stock appears for every date, then you could choose between Dictionary<DateTime, Dictionary<Stock, decimal>>
and Dictionary<Stock, Dictionary<DateTime, decimal>>
, depending on how you want to access the values afterwards (or even both if you don't mind storing the values twice).
这篇关于在C#中管理时间序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!