def main(): log('Starting') # Need to pre-pend 'D@' to show the provider. ser = fetch('D@Eurostat/namq_10_gdp/Q.CP_MEUR.SCA.B1GQ.EL', database='TEXT') # Load the same series multiple times; see the log to see that it is only fetched at most once from # the provider log('Load loop') for i in range(0, 10): fetch('D@Eurostat/namq_10_gdp/Q.CP_MEUR.SCA.B1GQ.EL', database='TEXT') quick_plot(ser)
""" Plot the 10-year US Treasury/Euro area AAA govvie spread in 4 -- count'em, 4 -- lines of code. (Couldn't find a daily bund series...) """ from econ_platform.start import fetch, quick_plot ust10 = fetch('F@DGS10') euro_AAA_10 = fetch('D@Eurostat/irt_h_euryld_d/D.PAR.Y10.EA') quick_plot(100 * (ust10 - euro_AAA_10), title='U.S. 10Y Spread Over Euro Govvie')
""" Plot the 10-year US Treasury/Euro area AAA govvie spread in 4 -- count'em, 4 -- lines of code. (Couldn't find a daily bund series...) """ from econ_platform.start import fetch, quick_plot ust10 = fetch('F@DGS10') euro_AAA_10 = fetch('D@Eurostat/irt_euryld_d/D.EA.PYC_RT.Y10.CGB_EA_AAA') quick_plot(ust10 - euro_AAA_10, title='U.S. 10Y Spread Over AAA-Rated Euro Govvie')
annualised = pow(factor, 12. / float(N_months)) annualised = 100. * (annualised - 1.) group_df[group] = annualised group_df.dropna(axis=0, inplace=True) if return_type == 'MIN': out = group_df.min(axis=1) series_meta.series_name = f'Minimum {N_months}-annualised inflation for major groups in U.S.' else: out = group_df.max(axis=1) series_meta.series_name = f'Maximum {N_months}-annualised inflation for major groups in U.S.' series_meta.series_description = 'Calculated series' return out, series_meta # Push the handler into the UserProvider user_provider = Providers.UserProvider user_provider.FunctionMapper['US_INF_DISPERSION'] = inflation_fn # End of code that should be in a library. #-------------------------------------------------------------------- # Now we can fetch it. # Note that since this calculated series uses the US CPI index level, the system # automatically also creates the CPI series on the database when this is called. # Call reset_update_time() to force an update of the series while the code is under development. # Note that this does not affect the series fetched from the external provider. reset_update_time('U@US_INF_DISPERSION(24, MAX)') inf = fetch('U@US_INF_DISPERSION(24, MAX)') quick_plot(inf)
""" hello_world.py Minimal econ_platform example. Note: Will not run "out of the box"; need to install dependencies, mainly Pandas, DB.nomics, and matplotlib... """ # Step 0: Overhead; need to import the package, and initialise it. # (Using econ_platform.start forces the initialisation step.) from econ_platform.start import fetch, quick_plot # Step 1: Fetch input data - Iceland HICP Inflation (Monthly) level = fetch('D@Eurostat/prc_hicp_midx/M.I05.CP00.IS') # Step 2: Highly complex quantitative stuff! inflation_rate = 100. * level.pct_change(12) # Step 3: Output. quick_plot(inflation_rate, title='Iceland HICP Inflation')
:return: """ if not str(series_meta.ticker_query) in ('GREEK_DRACHMA_OVERNIGHT_AVG', 'GREEK_DRACHMA_OVERNIGHT_EOM'): raise ValueError('Wrong series!') full_ticker = tickers.TickerFull(series_meta.ticker_full) # I will assume that the file is downloaded to the current directory sheet = pandas.read_excel('drachma_overnight_rate.xls', header=2) if str(series_meta.ticker_query) == 'GREEK_DRACHMA_OVERNIGHT_AVG': ser = pandas.Series(sheet['monthly averages']) ser.index = sheet['Unnamed: 0'] series_meta.series_name = 'Average pre-Euro Greek Drachma Bank Overnight Rate' series_meta.series_description = 'Monthly average bank overnight rate from Bank of Greece' # quick_plot(ser) else: print(sheet) raise NotImplementedError('Bam!') ser.name = str(full_ticker) return ser # Push the handler into the UserProvider user_provider = Providers.UserProvider user_provider.SeriesMapper['GREEK_DRACHMA_OVERNIGHT_AVG'] = greek_overnight user_provider.SeriesMapper['GREEK_DRACHMA_OVERNIGHT_EOM'] = greek_overnight # End of code that should be in a library. #-------------------------------------------------------------------- # Now we can fetch it. ser = fetch('U@GREEK_DRACHMA_OVERNIGHT_AVG') quick_plot(ser)