Say I have a toy package, something like:
BeginPackage["myPackage`"]
plotSomeData::usage = "plotFinancialData[symbol]... some usage language";
Begin["`Private`"]
plotSomeData[symbol_]:= DateListPlot[FinancialData[symbol, All]]
End[]
EndPackage[]
This should work fine, nothing particularly complicated here.
So now, I'd like to extend the FinancialData[]
function embedded in the package to enable it to seamlessly access non-Wolfram curated data stored locally on my computer.
I could rewrite the package and set up some conditional code that would replace FinancialData[]
with Import[]
, something like:
plotSomeData[symbol_] := DateListPlot[
Which[
symbol == "xyz", Import[pathAndFileName],
symbol != "xyz", FinancialData[symbol, All]
]]
But, in my case, that would mean rewriting a bunch of perfectly good packges, so I'd like another solution. Some of the questions and answers such as:
have me wondering if another more elegant way exists to do this.
Could, for instance, one extend the paclet information for a set of curated data?
I've used TagSet
before to do things like define how to calculate the CDF
of a custom distribution, but I don't see a clear way to use it to enable a curated data function to recognize the location of a data symbol it doesn't already know.
SetOptions
doesn't seem like the thing either.
UpVales
and UpSet
might do it, but I don't see it yet.
Ideally, I'd simply like to extend a curated data function to recognize the location of a data symbol it doesn't already know and thereby enable it to get the newly identified data.
Best if I can do this outside of the packages I already have.
Any ideas?
(The tags I have on this question could use some improvement, if anyone has some better ideas.)
FinancialData
, since it isLocked
. As you mentioned yourself,UpValues
can help. You can define a given symbol assym/: FinancialData[sym,...]:=...
, where you can insert on the r.h.s. the definition you want. $\endgroup$