The composite leading indicator (CLI) is designed to provide early signals of turning points in business cycles showing fluctuation of the economic activity around its long term potential level. CLIs show short-term economic movements in qualitative rather than quantitative terms.

개요

OECD 경기선행지수(Composite Leading Indicators Index)

  • OECD/MEI/CLI
  • MEI
    • Main Economic Indicators
  • CLI
    • Composite leading indicators
  • SDMX
    • Statistical Data and Metadata eXchange
    • 통계에 특화된 XML
    • DSD
      • Data Structure Definition
      • 통계자료에 대한 의미와 구조를 정의
    • DATA
      • DSD에서 정의한 구성정보에 주기, 시점에 따른 수치정보를 정의

Python으로 가져오기

import pandasdmx
oecd = pandasdmx.Request('OECD')
data_response = oecd.data(resource_id='MEI_CLI', key='all?startTime=2018')
df = data_response.write(data_response.data.series, parse_time=False)

Python으로 가져와서 정리하기

import telegram
import pandasdmx
from config import Config

class CLI:
    MEASURE_TYPES = {
        'LORSGPOR_IXOBSA': 'LORSGPOR_IXOBSA',
        'LORSGPTD': 'LORSGPTD',
        'LORSGPOR_GYSA': 'LORSGPOR_GYSA',
        'BSCICP03': 'BSCICP03',
        'CSCICP03': 'CSCICP03',
        'LOLITOAA': 'Amplitude adjusted',
        'LOLITONO': 'LOLITONO',
        'LOLITOTR_STSA': 'LOLITOTR_STSA',
        'LOLITOTR_GYSA': 'LOLITOTR_GYSA',
        'LORSGPRT': 'LORSGPRT',
        'LORSGPNO': 'LORSGPNO',
    }
    REGIONS = {
        'OECD': 'OECD Total',
        'USA': 'United States',
        'KOR': 'Korean',
        'CHN': 'China',
    }
    MEASURE = 'LOLITOAA'
    AMQ = 'M' # ['A', 'M', 'Q']
        
    def __init__(self, start_time=2018):
        self.summary = ''
        start_time = str(start_time)
        oecd = pandasdmx.Request('OECD')
        resp = oecd.data(resource_id='MEI_CLI', key=f'all?startTime={start_time}')
        self.df = resp.write(resp.data.series, parse_time=False)
        self.summary += f'OECD CompositeLeadingIndicator:\n'
        for region in CLI.REGIONS:
            try:
                series = self.df[(CLI.MEASURE, region, CLI.AMQ)]
            except:
                print(f'{CLI.MEASURE} {region} {CLI.AMQ} = ERR')
            series_dict = series.filter(regex='[0-9].-[0-9].').sort_index().to_dict()
            self.summary += f' {CLI.REGIONS[region]}:\n'
            for year, value in series_dict.items():
                self.summary += f'  {year}: {value}\n'
        self.summary += 'https://data.oecd.org/leadind/composite-leading-indicator-cli.htm\n'

    def __str__(self):
        return self.summary

if __name__ == '__main__':
    cli = CLI(start_time=2019)
    telegram.send(str(cli))

참고자료