Message Boards Message Boards

0
|
3041 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Formatting FinancialData[ ] output?

Posted 2 years ago

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..

POSTED BY: Raymond Low
2 Replies
Posted 2 years 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 BY: Rohit Namjoshi
Posted 2 years ago

Thanks Rohit -- yes, that worked very well.

POSTED BY: Raymond Low
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