error while getting turnover data using get_timeseries

Hi, tried using the below formula to get turnover time series data

import datetime

from dateutil.relativedelta import relativedelta

endDate = datetime.datetime.today()
startDate = endDate - relativedelta(months = 3)

temp = eikon.get_timeseries('BATS.L', fields='VALUE', start_date=startDate, end_date=endDate)

but the result is

BATS.L VALUE
Date
2017-06-28 NaN
2017-06-29 NaN
2017-06-30 NaN
2017-07-03 NaN
2017-07-04 NaN
...
2017-09-21 NaN
2017-09-22 NaN
2017-09-25 NaN
2017-09-26 NaN

[64 rows x 1 columns]

Is there any syntax error or is there any alternate formula which I can use to get the data?

Also Can I get the turnover values in EUR only and I don't need to multiply be any factors.

ex: I need to multiply turnover value by 10^6 in excel to get actual turnover

=TR("BATS.L","TR.TURNOVER*1000000","Frq=D SDate=2017-06-25 EDate=2017-09-25 Curn=EUR CH=Fd")

Best Answer

  • For eikon.get_timeseries, if you don't specify the fields parameter, all fields will be returned. From the result, there is no "VALUE" field.

    data = ek.get_timeseries('BATS.L', start_date=startDate, end_date=endDate)

    ...
    BATS.L HIGH LOW OPEN CLOSE COUNT VOLUME
    Date
    2017-06-28 5426.00000 5346.00000 5409.0 5351.0 15958.0 3021602.0
    2017-06-29 5371.00000 5235.00000 5340.0 5235.0 16880.0 3635156.0
    2017-06-30 5280.00000 5189.17539 5235.0 5234.0 15255.0 3621102.0
    2017-07-03 5253.00000 5210.00000 5214.0 5236.0 13974.0 2503098.0
    2017-07-04 5228.00000 5177.00000 5205.0 5177.0 9081.0 2095120.0

    I think that this is why the value of "VALUE" field returns NaN.

    For TR.TURNOVER, you can apply the Eikon Excel formula to Eikon Scripting API. For example, if Eikon Excel formula is:

    =TR("BATS.L","TR.TURNOVER*1000000","Frq=D SDate=2017-06-25 EDate=2017-09-25 Curn=EUR CH=Fd")

    the python code will be:

    data = ek.get_data(
    instruments=['BATS.L'],
    fields = [
    'TR.TURNOVER*1000000'
    ],
    parameters = {
    'CH' : 'Fd',
    'SDate' : '2017-06-25',
    'EDate' : '2017-09-25',
    'Curn' : 'EUR',
    'Frq' : 'D'
    })

    Refer to Data Item Browser app, TR.TURNOVER is the unscaled turnover value (summation of the value of all trades during the market day) for a particular instrument.

    Moreover, I found that the TR function doesn't have a parameter to automatically apply factors to the turnover value as this is market specific. Therefore, Eikon Scripting API is unable to do it too.

Answers

  • TimeSeries service doesn't provide VALUE field but only HIGH, LOW, OPEN, CLOSE, COUNT and VOLUME.

    To check available fields, don't detail field list :

    >>> temp = ek.get_timeseries('BATS.L', start_date=startDate, end_date=endDate)
    >>> temp
    BATS.L HIGH LOW OPEN CLOSE COUNT VOLUME
    Date
    2017-06-28 5426.00000 5346.00000 5409.0 5351.0 15958.0 3021602.0
    2017-06-29 5371.00000 5235.00000 5340.0 5235.0 16880.0 3635156.0
    2017-06-30 5280.00000 5189.17539 5235.0 5234.0 15255.0 3621102.0
    ... ... ... ... ... ... ...
    2017-09-25 4613.50000 4550.00000 4613.5 4585.0 14948.0 3711885.0
    2017-09-26 4655.00000 4508.50000 4595.5 4650.0 23032.0 4485152.0
    2017-09-27 4717.00000 4638.00000 4664.5 4663.5 9135.0 1368120.0
    [65 rows x 6 columns]

    To get Turnover, you have to request on DataGrid service with get_data function:

    >>> temp = eikon.get_data('BATS.L', ['TR.TURNOVER.Date','TR.TURNOVER'], parameters={'SDate': '2017-06-25', 'EDate': '2017-0 9-25'})
    >>> temp
    ( Instrument Date Turnover
    0 BATS.L 2017-06-26T00:00:00Z 134.927570
    1 BATS.L 2017-06-27T00:00:00Z 174.867660
    2 BATS.L 2017-06-28T00:00:00Z 162.414590
    .. ... ... ...
    62 BATS.L 2017-09-21T00:00:00Z 185.998271
    63 BATS.L 2017-09-22T00:00:00Z 141.654754
    64 BATS.L 2017-09-25T00:00:00Z 170.441317
    [65 rows x 3 columns], None)

    If you want TURNOVER in EUR, add 'curn':'EUR in parameters :

    >>> temp = ek.get_data('BATS.L', ['TR.TURNOVER.Date','TR.TURNOVER'], parameters={'SDate': '2017-06-25', 'EDate': '2017-0
    9-25', 'curn':'EUR'})
    >>> temp
    ( Instrument Date Turnover
    0 BATS.L 2017-06-26T00:00:00Z 1.535270
    1 BATS.L 2017-06-27T00:00:00Z 1.976493
    2 BATS.L 2017-06-28T00:00:00Z 1.845156
    .. ... ... ...
    62 BATS.L 2017-09-21T00:00:00Z 2.115308
    63 BATS.L 2017-09-22T00:00:00Z 1.598960
    64 BATS.L 2017-09-25T00:00:00Z 1.937354
    [65 rows x 3 columns], None)

    As values are provided in millions, you can also adjust by multiplying turnover value by 10^6:

    >>> temp = ek.get_data('BATS.L', ['TR.TURNOVER.Date','TR.TURNOVER*1000000'], parameters={'SDate': '2017-06-25', 'EDate':
    >>> temp
    ( Instrument Date TR.TURNOVER*1000000
    0 BATS.L 2017-06-26T00:00:00Z 1.535270e+06
    1 BATS.L 2017-06-27T00:00:00Z 1.976493e+06
    2 BATS.L 2017-06-28T00:00:00Z 1.845156e+06
    .. ... ... ...
    62 BATS.L 2017-09-21T00:00:00Z 2.115308e+06
    63 BATS.L 2017-09-22T00:00:00Z 1.598960e+06
    64 BATS.L 2017-09-25T00:00:00Z 1.937354e+06
    [65 rows x 3 columns], None)