How do you access excel Stocks data fields using Python in Excel (eg Price, Volume etc).
A workaround is to put each field in a separate cell and then put them all in a python dataframe but this seems a bit clunky.
Here is the scenario –
I enter MSFT in cell A1 and use Excel’s built-in Stocks feature to convert it to a Stocks data type.
I then make cell A2 a python formula and enter xl(“A1”)
A2 then indicates it contains a python dict
In cell A3 I enter A2.text and it displays “MICROSOFT CORPORATION (XNAS:MSFT)”
However, I don’t know how to access this field using Python in Excel
I would have expected that changing A2 to xl(“A1”)[“text”] would also give “MICROSOFT CORPORATION (XNAS:MSFT)” but instead I get an error.
And it gets more complicated since the dict in A2 contains nested dicts
If I change A3 to A2.properties then A3 is another dict
If I make A4 = A3.price then A4 is yet another dict
If I make A5 = A4.basicValue then A5 finally displays the price!
And I have no idea how I would access that in Python
I suspect the issue is that Excel Stocks data types are converted to a python RichValue type and I don’t know how to handle them.
Any advice gratefully received!