6
$\begingroup$
Map[
 QuantityMagnitude@
   CurrencyConvert[DatedUnit["USDollars", #], DatedUnit["Euro", #]] &,
  Range[2008, 2015]]
(* {0.683367, 0.719004, 0.754938, 0.718962, 0.778094, 0.753209, \
0.753825, 0.888133} *)

This simple download takes 5 seconds, which is significantly slower than downloading hundreds of share prices with FinancialData.

Also, very often I get the following message:

"A network operation for InflationAdjust timed out. Please try again later."

and one or more values are missing.

Any idea how I can speed this up and how I can avoid the timeouts?

$\endgroup$
4
$\begingroup$

I found a certain improvement using WolframAlpha.

To get the rates for the last 20 days I wrote:

GetRates[c1_, c2_] :=
 With[{rt = WolframAlpha["Exchange rate " <> c1 <> " " <> c2, {{"History", 1}, "FormattedData"}]},
  Round[#, 0.01]& @ Take[Cases[rt, {DateObject[__], a_Real} :> a/100, Infinity], -20]]

GetRates["USDollars", "Euro"]

{0.95, 0.94, 0.92, 0.94, 0.93, 0.93, 0.92, 0.91, 0.92, 0.91, 0.92, 0.92, 0.92, 0.92, 0.92, 0.93, 0.93, 0.92, 0.91, 0.91}

This is still slow (3 seconds), but much faster than the approach in the question (13 seconds).

Above all : I don' t get timeouts anymore, because WolframAlpha employs in this case the option

TimeConstraint -> {30, Automatic, Automatic, Automatic}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.