MattCocci / FredFetch

For pulling current and vintage date from FRED and ALFRED API
5 stars 9 forks source link

Refactor entire thing into Matlab class? #5

Open micahjsmith opened 9 years ago

micahjsmith commented 9 years ago

Some inefficiencies that stand out include:

These behaviors can be achieved easily by having an object of class fred or of class FredFetch be created at the beginning of the session:

f = fred(MY_API_KEY,'defaultUnits','lin')
% alternately
f = FredFetch(MY_API_KEY)
set(f, 'defaultParWorkers',3) % one way to set/get fields of object
f.defaultOtherOption = 'hello' % another way to set/get fields of object

Then, a future call is made as:

latest(f, 'GDCP1')
% or, completely equivalent syntactically
f.latest('GDPC1')

The object f already has "embedded" all the relevant global options and the API key without needed to do everything from scratch. This is also what the actual Matlab Datafeed Toolbox fred routines (as for all other data sources) do.

See my bls interface for a simple example of what this looks like/how it is implemented.

micahjsmith commented 9 years ago

Additional advantage of setting global options in a first, initial step: f.defaultParWorkers can be specified, but then the class tests for the existance of a Parallel Computing Toolbox license and sets to 0 otherwise.

MattCocci commented 9 years ago

Into it. But I want to implement time-aggregation of series first. I'd rather devote coding effort to that at this point. That's really the last major feature that's missing.

Then longer-term, I think this is a good idea.

micahjsmith commented 9 years ago

Seems fair enough