Message Boards Message Boards

GROUPS:

Formatting FinancialData[ ] output?

Posted 1 month ago
309 Views
|
2 Replies
|
1 Total Likes
|

Having problems with "Parts" seems to work differently with FinancialData

In[291]:= Flatten@FinancialData["aapl", {2021, 8, 20}][[2]] // Normal

Out[291]= {Quantity[148.19000244140625`, "USDollars"], 
 Quantity[149.7100067138672, "USDollars"], 
 Quantity[149.6199951171875, "USDollars"], 
 Quantity[148.36000061035156`, "USDollars"], 
 Quantity[147.5399932861328, "USDollars"], 
 Quantity[148.60000610351562`, "USDollars"], 
 Quantity[153.1199951171875, "USDollars"], 
 Quantity[151.8300018310547, "USDollars"], 
 Quantity[152.50999450683594`, "USDollars"], 
 TemporalData`UniformTimeSpecification[{3838406400, 3838665600, 
   3838752000, 3838838400, 3838924800, 3839011200, 3839270400, 
   3839356800, 3839443200}], 1, "Continuous", 1, "Discrete", 1, 1, 
 ValueDimensions -> 1, DateFunction -> Automatic, 
 ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}, 
 TemporalRegularity -> True} 

How do I get rid of the stuff at the end of the list?? and if possible how to get rid of the Quantity US Dollars??

I tried Method->"Legacy" , but ended up with worst results.

Thanks for any help..

2 Replies
Posted 1 month ago

Hi Raymond,

Something like this?

data = FinancialData["AAPL", {2021, 8, 20}];

(* Using Pattern replacement *)
data["DatePath"] /. {d_, p_} :> {d, QuantityMagnitude@p}

(* Using MapAt *)
data["DatePath"] // MapAt[QuantityMagnitude, #, {All, 2}] &

or

data["Values"] // QuantityMagnitude
Posted 1 month ago

Thanks Rohit -- yes, that worked very well.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract