Best way to store "collection" of time series; issues with "execute" on structure array

12 次查看(过去 30 天)
Hi,
I am trying to create a structure array or other aggregate object of time series objects (a "collection"). The idea is to have a dataset fully encapsulated by this large object. I will have multiple stocks in each time series, and each time series will have a name, like "average_price" for example.
I am writing a script that takes an excel file with one variable per sheet (and many stocks per sheet). For convenience, I name each of the sheets with the name of each variable. I want to use these sheet names as my variable names.
The "importdata" function works well to get all the data I need. However, to extract data after using importdata, I need to use fieldnames originating from excel (i.e. variable names). I can get these into a text variable, but then in order to access the data, I must do it with this text variable (not knowing the actual text itself). This is where I run into a problem. I have tried "execute" and "eval" with a concatenated string, but get this error "Undefined function 'execute' for input arguments of type 'cell'."
Perhaps I am going about it the wrong way, but my idea is to have a collection of times series, where I can call a variable such as daily.average_price and the result is a time series object for average price (with many stocks in that single object). The alternative is to have many different time series variables floating around, but I will have so many I am worried about getting confused as to what was updated when, etc.
I would appreciate any help. Also, any help as to what data structure is best to store these time series. THANKS!
Mike

采纳的回答

per isakson
per isakson 2014-7-17
编辑:per isakson 2014-7-17
"[...] text variable, but then in order to access the data, I must do it with this text variable [...]" . See containers.Map class
  2 个评论
Michael
Michael 2014-7-17
Hi iakson,
Thank you for your answer. Unfortunately, I probably wasn't specific enough.
First note, I must use time series arrays (from Financial Toolbox) in order to preserve financial time series functionality.
Second, note that each financial time series will have information on many stocks for many time periods. Consider year of stock prices for say 500 stocks (for one time series), or a year of volume values for 500 stocks for a year.
My goal is to aggregate into an array or structure of some kind so that I can have an entire dataset in this single array and can call it easily. In the example, a dataset will encompass both prices and volumes (for 500 stocks each for a whole year).
What I would like to do is define, say one time series as "prices" and another as "volumes". Next, I would create this custom array called for example "data_7_17_2014", and would assign "data_7_17_2014.prices" to be equal to "prices" and "data_7_17_2014.volumes" to be equal to "volumes".
Since I will likely have up to say 40-50 different types of data organized as financial time series, this will help keep me organized, since I will know that the array data_7_17_2014 includes data up until 7_17_2014.
I looked into doing this with an "object array" but the problem there and with other options is that you can't actually call an array element by name...you have to use its index. I would rather just create the 40-50 time series and have 40-50 variables independent than have to somehow remember their index number in the array.
Here is another way to explain what I am trying to do. With normal times series, a time series collection is a collection of multiple vectors of data with the same date. A financial time series already is a collection of multiple vectors with the same date (in addition to other properties). I am trying to create a name-accessible collection of financial time series.
Sorry if I confused you or anybody else...but I would greatly appreciate additional help.
Thank you.
Best, Michael
per isakson
per isakson 2014-7-17
编辑:per isakson 2014-7-17
Yes, in my world the financial time series object is a collections of time series.
I'm definitely not an expert in OOD and I do my OOD by trial and error. My first idea is
classdef my_stock_class < handle
properties
price % array of fints object
volume % array of fints object
lib % containers.Map object
end
methods
function foo( this, name )
price_obj = this.price( this.lib( name ) );
end
end
end
  • persistent storage of data in some kind of database. Storage of objects in a mat-file is a possibility (technically). (HDF5 is my "hammer".)
  • creation of an instance of my_stock_class my take some time
"called for example "data_7_17_2014", and would assign" &nbsp I doubt that is a good idea.
Saving data-objects in a mat-file may (/will) eventually lead to
  • many objects with overlapping data
  • need for documentation of stored objects
  • needs for tools for merging and inspecting objects

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Price and Analyze Financial Instruments 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by