Historical quotes without preprocessing

Hi everyone.
I’d like to fetch historical quotes from a website that uses the following link on their own website to fetch JSON quotes:
Brazilian Dólar PTAX
The json result is this:

{
    "@odata.context": "https://was-p.bcnet.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata$metadata#_CotacaoDolarDia(cotacaoCompra,dataHoraCotacao)",
    "value": [
        {
            "cotacaoCompra": 5.4641,
            "dataHoraCotacao": "2024-06-19 13:09:27.702"
        }
    ]
}

I`m using this configurations in PP:
Path to Date: $.value[].dataHoraCotacao
Date format: yyyy-MM-dd HH:mm:ss.SSS
Path to Close: $.value[
].cotacaoCompra

I also tried to use in URL “{DATE:MM-01-yyyy}” or “{DATE:MM-32-yyyy}”, but I think that PP only is prepared for “dd-MM-yyyy” format, for it upload only the one day per month. Can this be implemented?

Another question is that the Date format some times give me a result error in the index “.SSS”. Than, is there a way to PP truncate the date result to take only the date or the work with this format correctly?

Thanks for the great job!

Based on the given URL https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata/CotacaoDolarDia(dataCotacao=@dataCotacao)?@dataCotacao=%2706-19-2024%27&$top=100&$format=json&$select=cotacaoCompra,dataHoraCotacao the PP corresponding one could be https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata/CotacaoDolarDia(dataCotacao=@dataCotacao)?@dataCotacao=%27{DATE:MM-dd-yyyy}%27&$top=100&$format=json&$select=cotacaoCompra,dataHoraCotacaoas the macro is {DATE:MM-dd-yyyy}.

I’ve tried it this way (and others), but it didn’t work.
I seems that PP does not recognize the macro and treats it as literal.

But if I use this…
https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata/CotacaoDolarDia(dataCotacao=@dataCotacao)?@dataCotacao=%27{DATE:MM-02-yyyy}%27&$top=100&$format=json&$select=cotacaoCompra,dataHoraCotacao
PP, without result, stopped with this message:

Text '2023-08-02 13:10:20.27' could not be parsed at index 20

I think that it’s trying one day per month until 08/2023.

Your request returns just one day. Fechting historical quotes is better with a given period, because otherwise you have to open PP every day.

“Cotação do Dólar por período” is described here https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/swagger-ui3#/

The resulting URL is for example

https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata/CotacaoDolarPeriodo(dataInicial=@dataInicial,dataFinalCotacao=@dataFinalCotacao)?@dataInicial=%2701-01-2024%27&@dataFinalCotacao=%2706-21-2024%27&$format=json

with the response

{"@odata.context":"https://was-p.bcnet.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata$metadata#_CotacaoDolarPeriodo",
"value":[{"cotacaoCompra":4.89100,"cotacaoVenda":4.89160,"dataHoraCotacao":"2024-01-02 13:05:50.319"},
{"cotacaoCompra":4.92060,"cotacaoVenda":4.92120,"dataHoraCotacao":"2024-01-03 13:14:41.153"},
{"cotacaoCompra":4.91820,"cotacaoVenda":4.91880,"dataHoraCotacao":"2024-01-04 13:05:35.048"},
{"cotacaoCompra":4.88930,"cotacaoVenda":4.88990,"dataHoraCotacao":"2024-01-05 13:10:31.843"},
{"cotacaoCompra":4.88440,"cotacaoVenda":4.88500,"dataHoraCotacao":"2024-01-08 13:11:30.76"},
{"cotacaoCompra":4.89310,"cotacaoVenda":4.89370,"dataHoraCotacao":"2024-01-09 13:09:30.847"},
{"cotacaoCompra":4.88950,"cotacaoVenda":4.89010,"dataHoraCotacao":"2024-01-10 13:09:34.773"},
{"cotacaoCompra":4.87880,"cotacaoVenda":4.87940,"dataHoraCotacao":"2024-01-11 17:03:40.62"},
{"cotacaoCompra":4.85370,"cotacaoVenda":4.85430,"dataHoraCotacao":"2024-01-12 13:26:56.442"},

and so on

This works in PP

Now use the macros, for a period of maybe 3 month.

https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata/CotacaoDolarPeriodo(dataInicial=@dataInicial,dataFinalCotacao=@dataFinalCotacao)?@dataInicial=%27{TODAY:MM-dd-yyyy:-P3M}%27&@dataFinalCotacao=%27{TODAY:MM-dd-yyyy:-P1D}%27&$format=json

$.value[*].dataHoraCotacao

$.value[*].cotacaoCompra

Espero que ajude

1 Like

You’re the best! Thanks a lot. Configure two dates was another way that I didn’t can’t undestood how to set in PP.
It worked perfectly.
:trophy: