lastDate = datetime.strptime(csv['DATE'].iloc[-1], '%Y-%m-%d') # If we have a new update: if lastAvailableDate < lastDate: # Pull rate from 2 yrs ago, 1 yr ago, etc dates['twoYearsAgo'] = (lastDate - timedelta(days=730)).date() dates['oneYearAgo'] = (lastDate - timedelta(days=365)).date() dates['sixMonthsAgo'] = (lastDate - timedelta(days=182)).date() dates['threeMonthsAgo'] = (lastDate - timedelta(days=91)).date() dates['oneMonthAgo'] = (lastDate - timedelta(days=30)).date() dates['twoWeeksAgo'] = (lastDate - timedelta(days=14)).date() dates['oneWeekAgo'] = (lastDate - timedelta(days=7)).date() dates['yesterday'] = (lastDate - timedelta(days=1)).date() dates['today'] = lastDate.date() dates = verifyDates( csv, dates, 'DATE', 'DGS3MO' ) # If above dates (2 yrs ago, 1 yr ago) are weekends, fix to weekday values = { 'twoYearsAgo': getValueFromCSV(csv, dates['twoYearsAgo'].strftime('%Y-%m-%d'), 'DATE', 'DGS3MO'), 'oneYearAgo': getValueFromCSV(csv, dates['oneYearAgo'].strftime('%Y-%m-%d'), 'DATE', 'DGS3MO'), 'sixMonthsAgo': getValueFromCSV(csv, dates['sixMonthsAgo'].strftime('%Y-%m-%d'), 'DATE', 'DGS3MO'), 'threeMonthsAgo': getValueFromCSV(csv, dates['threeMonthsAgo'].strftime('%Y-%m-%d'), 'DATE', 'DGS3MO'), 'oneMonthAgo':
'T10Y2Y'), 'twoWeeksAgo': getValueFromCSV(csv, dates['twoWeeksAgo'].strftime('%Y-%m-%d'), 'DATE', 'T10Y2Y'), 'oneWeekAgo': getValueFromCSV(csv, dates['oneWeekAgo'].strftime('%Y-%m-%d'), 'DATE', 'T10Y2Y'), 'yesterday': getValueFromCSV(csv, dates['yesterday'].strftime('%Y-%m-%d'), 'DATE', 'T10Y2Y'), 'today': getValueFromCSV(csv, dates['today'].strftime('%Y-%m-%d'), 'DATE', 'T10Y2Y'), } dates = verifyDates( csv, dates, 'DATE', 'T10Y2Y') # Verify all dates are weekdays and not weekends # Send tweet tweet = f"US 10Y-2Y Treasury Yield - {lastDate.strftime('%Y-%m-%d')}: {values['today']}%\n\ 1d: {values['yesterday']}% ({((values['today']-values['yesterday'])/values['yesterday'])*100:.1f}%)\n\ 1w: {values['oneWeekAgo']}% ({((values['today']-values['oneWeekAgo'])/values['oneWeekAgo'])*100:.1f}%)\n\ 2w: {values['twoWeeksAgo']}% ({((values['today']-values['twoWeeksAgo'])/values['twoWeeksAgo'])*100:.1f}%)\n\ 1m: {values['oneMonthAgo']}% ({((values['today']-values['oneMonthAgo'])/values['oneMonthAgo'])*100:.1f}%)\n\ 3m: {values['threeMonthsAgo']}% ({((values['today']-values['threeMonthsAgo'])/values['threeMonthsAgo'])*100:.1f}%)\n\ 6m: {values['sixMonthsAgo']}% ({((values['today']-values['sixMonthsAgo'])/values['sixMonthsAgo'])*100:.1f}%)\n\ 1y: {values['oneYearAgo']}% ({((values['today']-values['oneYearAgo'])/values['oneYearAgo'])*100:.1f}%)\n\ 2y: {values['twoYearsAgo']}% ({((values['today']-values['twoYearsAgo'])/values['twoYearsAgo'])*100:.1f}%)" notification(tweet)
# get date of last datapoint, in CSV file lastDate = datetime.strptime(csv['DATE'].iloc[-1],'%Y-%m-%d') # If we have a new update: if lastAvailableDate < lastDate: # Pull values from 2 yrs ago, 1 yr ago, etc dates['twoYearsAgo'] = (lastDate - timedelta(days=730)).date() dates['oneYearAgo'] = (lastDate - timedelta(days=365)).date() dates['sixMonthsAgo'] = (lastDate - timedelta(days=182)).date() dates['threeMonthsAgo'] = (lastDate - timedelta(days=91)).date() dates['oneMonthAgo'] = (lastDate - timedelta(days=30)).date() dates['twoWeeksAgo'] = (lastDate - timedelta(days=14)).date() dates['oneWeekAgo'] = (lastDate - timedelta(days=7)).date() dates['yesterday'] = (lastDate - timedelta(days=1)).date() dates['today'] = lastDate.date() dates = verifyDates(csv,dates,'DATE','EFFR') # Verify days are weekdays and not weekends values = { 'twoYearsAgo': getValueFromCSV(csv,dates['twoYearsAgo'].strftime('%Y-%m-%d'),'DATE','EFFR'), 'oneYearAgo': getValueFromCSV(csv,dates['oneYearAgo'].strftime('%Y-%m-%d'),'DATE','EFFR'), 'sixMonthsAgo': getValueFromCSV(csv,dates['sixMonthsAgo'].strftime('%Y-%m-%d'),'DATE','EFFR'), 'threeMonthsAgo': getValueFromCSV(csv,dates['threeMonthsAgo'].strftime('%Y-%m-%d'),'DATE','EFFR'), 'oneMonthAgo': getValueFromCSV(csv,dates['oneMonthAgo'].strftime('%Y-%m-%d'),'DATE','EFFR'), 'twoWeeksAgo': getValueFromCSV(csv,dates['twoWeeksAgo'].strftime('%Y-%m-%d'),'DATE','EFFR'), 'oneWeekAgo': getValueFromCSV(csv,dates['oneWeekAgo'].strftime('%Y-%m-%d'),'DATE','EFFR'), 'yesterday': getValueFromCSV(csv,dates['yesterday'].strftime('%Y-%m-%d'),'DATE','EFFR'), 'today': getValueFromCSV(csv,dates['today'].strftime('%Y-%m-%d'),'DATE','EFFR'), } # Send tweet tweet = f"Effective Federal Funds Rate (overnight) - {lastDate.strftime('%Y-%m-%d')}: {values['today']}%\n\ 1d: {values['yesterday']}% ({((values['today']-values['yesterday'])/values['yesterday'])*100:.1f}%)\n\
# get date of last datapoint, in CSV file lastDate = datetime.strptime(csv['DATE'].iloc[-1], '%Y-%m-%d') # If we have a new update: if lastAvailableDate < lastDate: # Pull rate from 2 yrs ago, 1 yr ago, etc dates['twoYearsAgo'] = (lastDate - timedelta(days=730)).date() dates['oneYearAgo'] = (lastDate - timedelta(days=365)).date() dates['sixMonthsAgo'] = (lastDate - timedelta(days=182)).date() dates['threeMonthsAgo'] = (lastDate - timedelta(days=91)).date() dates['oneMonthAgo'] = (lastDate - timedelta(days=30)).date() dates['twoWeeksAgo'] = (lastDate - timedelta(days=14)).date() dates['oneWeekAgo'] = (lastDate - timedelta(days=7)).date() dates['yesterday'] = (lastDate - timedelta(days=1)).date() dates['today'] = lastDate.date() dates = verifyDates(csv, dates, 'DATE', 'BAMLH0A0HYM2') values = { 'twoYearsAgo': getValueFromCSV(csv, dates['twoYearsAgo'].strftime('%Y-%m-%d'), 'DATE', 'BAMLH0A0HYM2'), 'oneYearAgo': getValueFromCSV(csv, dates['oneYearAgo'].strftime('%Y-%m-%d'), 'DATE', 'BAMLH0A0HYM2'), 'sixMonthsAgo': getValueFromCSV(csv, dates['sixMonthsAgo'].strftime('%Y-%m-%d'), 'DATE', 'BAMLH0A0HYM2'), 'threeMonthsAgo': getValueFromCSV(csv, dates['threeMonthsAgo'].strftime('%Y-%m-%d'), 'DATE', 'BAMLH0A0HYM2'), 'oneMonthAgo': getValueFromCSV(csv, dates['oneMonthAgo'].strftime('%Y-%m-%d'), 'DATE',