1
$\begingroup$

Could you perhaps explain me the following behaviour? My code is:

sp500 = FinancialData["^SPX", {2007, 1, 1}, Method -> "Legacy"]

This gives me a list that ends with yesterday's value (4,509.37 at 2021-08-27).

But without "Method->Legacy" it shows the last value somewhere in the middle of 2020.

In addition, when I run this:

DateListPlot[{zlato, sp500}, PlotLegends -> {"gold", "SP500"}]

I get a chart where you can see the gold price is up-to-date, but SP500 is not.

enter image description here

Any idea, why would that be?

Thanks,

Jiri

P.S. zlato is gold, is defined as

zlato = FinancialData["XAU/USD", {2007, 1, 1}, Method -> "Legacy"]

With PlotRange limited to 2020-2021, the Plot looks like this: enter image description here

$\endgroup$
5
  • 1
    $\begingroup$ What is zlato? You forgot to include its definition. DateListPlot[sp500] is up to date for me in v12.3.1. Are you sure you aren't just missing a PlotRange option in the DateListPlot ? $\endgroup$
    – flinty
    Commented Aug 28, 2021 at 21:32
  • $\begingroup$ zlato is zlato = FinancialData["XAU/USD", {2007, 1, 1}, Method -> "Legacy"] $\endgroup$
    – Jiri
    Commented Aug 29, 2021 at 5:58
  • $\begingroup$ PlotRange doesn't change anything with DateListPlot[{zlato, sp500}, PlotLegends -> {"gold", "SP500"}, PlotRange -> {{{2020}, {2021}}, Automatic}] you get a more detailed plot obviously, but still with missing data for SP500. $\endgroup$
    – Jiri
    Commented Aug 29, 2021 at 6:02
  • $\begingroup$ I think the issue is the different dimension of the two time series - the gold has got more trading dates (entries) than there are trading dates of SP500. Would you agree? $\endgroup$
    – Jiri
    Commented Aug 29, 2021 at 6:34
  • 3
    $\begingroup$ Try adding the PlotRange -> All option to each DateListPlot. $\endgroup$
    – creidhne
    Commented Aug 30, 2021 at 2:49

1 Answer 1

2
$\begingroup$

To make the plot synchoronized I had to do TimeSeriesResample so that both time-series had the same "DatePath". Then the DateListPlot works without problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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