imf_reader.sdr.read_announcements ================================= .. py:module:: imf_reader.sdr.read_announcements .. autoapi-nested-parse:: Module to get SDR data from the IMF website info: https://www.imf.org/en/About/Factsheets/Sheets/2023/special-drawing-rights-sdr Attributes ---------- .. autoapisummary:: imf_reader.sdr.read_announcements.BASE_URL imf_reader.sdr.read_announcements.MAIN_PAGE_URL Functions --------- .. autoapisummary:: imf_reader.sdr.read_announcements.read_tsv imf_reader.sdr.read_announcements.clean_df imf_reader.sdr.read_announcements.format_date imf_reader.sdr.read_announcements.get_holdings_and_allocations_data imf_reader.sdr.read_announcements.fetch_latest_allocations_holdings_date imf_reader.sdr.read_announcements.fetch_allocations_holdings Module Contents --------------- .. py:data:: BASE_URL :value: 'https://www.imf.org/external/np/fin/tad/' .. py:data:: MAIN_PAGE_URL :value: 'https://www.imf.org/external/np/fin/tad/extsdr1.aspx' .. py:function:: read_tsv(url: str) -> pandas.DataFrame Read a tsv file from url and return a dataframe .. py:function:: clean_df(df: pandas.DataFrame) -> pandas.DataFrame Clean the SDR dataframe .. py:function:: format_date(month: int, year: int) -> str Return a date as year-month-day where day is the last day in the month .. py:function:: get_holdings_and_allocations_data(year: int, month: int) Get sdr allocations and holdings data for a given month and year .. py:function:: fetch_latest_allocations_holdings_date() -> tuple[int, int] Get the latest available SDR allocation holdings date. :returns: A tuple containing the year and month of the latest SDR data. :rtype: tuple[int, int] .. py:function:: fetch_allocations_holdings(date: tuple[int, int] | None = None) -> pandas.DataFrame Fetch SDR holdings and allocations data for a given date. If date is not specified, it fetches data for the latest date :param date: tuple[int, int]. The year and month to get allocations and holdings data for. e.g. (2024, 11) for November 2024. :param If None: :param the latest announcements released are fetched.: :returns: A dataframe with the SDR allocations and holdings data