What is the formula to retreive daily VWAP data using Python?

What is the formula to retreive daily VWAP data using Python? (For example for 7203.T)

Do I use eikon.get_data or eikon.get_timeseries?
Please provide me with a sample formula to retreive historical VWAP (Ex for 20days).

Best Answer

  • TimeSeries provides following daily data:

    >>> ek.get_timeseries('7203.T')
    7203.T HIGH CLOSE LOW OPEN VOLUME COUNT
    Date
    2017-06-29 5934.0 5910.0 5886.0 5930.0 6462300.0 -1.0
    2017-06-30 5906.0 5893.0 5867.0 5896.0 7372400.0 -1.0
    2017-07-03 5996.0 5950.0 5887.0 5893.0 11484000.0 -1.0
    ... ... ... ... ... ... ...
    2017-10-04 6802.0 6730.0 6719.0 6800.0 6968500.0 -1.0
    2017-10-05 6805.0 6784.0 6773.0 6790.0 6378400.0 -1.0
    2017-10-06 6890.0 6889.0 6810.0 6815.0 10004000.0 10995.0
    [69 rows x 6 columns]
    >>>

    In your case, you should use get_data.

    To identify which field to request, you can search with the Data Item Browser (link available in the Eikon API Proxy window), type the RIC (ex:7203.T) then key word (ex:VWAP) :

    image

    TR.TSVWAP field seems to match with your needs :

    >>> vwap,err=ek.get_data('7203.T', ['TR.TSVWAP','TR.TSVWAP.Date'], parameters={'SDate':'20170906','EDate':'20171005'})
    >>> vwap
    Instrument VWAP Date
    0 7203.T 6168.9320 2017-09-06T00:00:00Z
    1 7203.T 6235.1348 2017-09-07T00:00:00Z
    2 7203.T 6257.3599 2017-09-08T00:00:00Z
    3 7203.T 6294.5292 2017-09-11T00:00:00Z
    4 7203.T 6368.8700 2017-09-12T00:00:00Z
    5 7203.T 6410.2355 2017-09-13T00:00:00Z
    6 7203.T 6427.6915 2017-09-14T00:00:00Z
    7 7203.T 6469.6285 2017-09-15T00:00:00Z
    8 7203.T 6668.0025 2017-09-19T00:00:00Z
    9 7203.T 6701.9567 2017-09-20T00:00:00Z
    10 7203.T 6763.2350 2017-09-21T00:00:00Z
    11 7203.T 6756.1145 2017-09-22T00:00:00Z
    12 7203.T 6779.5475 2017-09-25T00:00:00Z
    13 7203.T 6810.9750 2017-09-26T00:00:00Z
    14 7203.T 6753.8888 2017-09-27T00:00:00Z
    15 7203.T 6760.6621 2017-09-28T00:00:00Z
    16 7203.T 6708.2255 2017-09-29T00:00:00Z
    17 7203.T 6691.0715 2017-10-02T00:00:00Z
    18 7203.T 6738.9075 2017-10-03T00:00:00Z
    19 7203.T 6759.8712 2017-10-04T00:00:00Z
    20 7203.T 6789.5579 2017-10-05T00:00:00Z
    >>>