This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| This script converts a properly formatted CSV file to a JSON list. | |
| The CSV must have the `Project ID` in the first column and `OP Amount` in the second column. | |
| The `Project ID` can be found at the end of the voting URL, eg: | |
| https://vote.optimism.io/retropgf/3/application/0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f | |
| https://round3.optimism.io/projects/0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f | |
| `Project ID` = 0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import os | |
| import requests | |
| PROJECT_APP_SCHEMA = "0x76e98cce95f3ba992c2ee25cef25f756495147608a3da3aa2e5ca43109fe77cc" | |
| PROJECT_REVIEW_SCHEMA = "0xebbf697d5d3ca4b53579917ffc3597fb8d1a85b8c6ca10ec10039709903b9277" | |
| REVIEWER_ADDRESS = "0x621477dBA416E12df7FF0d48E14c4D20DC85D7D9" | |
| DATA_EXPORT_JSON = "rpgf3_applicant_data.json" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import os | |
| import requests | |
| EAS_SCHEMA = "0x76e98cce95f3ba992c2ee25cef25f756495147608a3da3aa2e5ca43109fe77cc" | |
| START_TIME = 0 | |
| RAW_APPLICANT_JSON = "raw_applicant_data.json" | |
| CLEANED_APPLICANT_JSON = "cleaned_applicant_data.json" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import matplotlib.pyplot as plt | |
| fig, ax = plt.subplots(figsize=(20,8)) | |
| df.plot(kind='line', y=['C Market (Real)', 'C Market (Nominal)'], ax=ax) | |
| current_price = df.iloc[-1]['C Market (Nominal)'] | |
| ax.axhline(current_price, color='black') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df['C Market (Real)'] = df['C Market'] * df['FX Index'] * df['Inflation Index'] | |
| df.rename(columns={'C Market': 'C Market (Nominal)'}, inplace=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def index_annual_rate_to_date(date, series): | |
| daily_rate = (1 + series/100) ** (1/365) | |
| cumulative_rate = daily_rate.sort_index(ascending=False).cumprod() | |
| return index_to_date(date, cumulative_rate) | |
| df['Inflation Index'] = index_annual_rate_to_date(index_date, df['Inflation']) | |
| df.plot(kind='line', y=['Inflation', 'Inflation Index'], secondary_y='Inflation') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| index_date = datetime(2019,3,31) | |
| def index_to_date(date, series): | |
| index_val = series.loc[date] | |
| indexed_series = series / index_val | |
| return indexed_series | |
| df['FX Index'] = index_to_date(index_date, df['FX']) | |
| df.plot(kind='line', y=['FX', 'FX Index'], secondary_y='FX', alpha=.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df.set_index('Date', inplace=True) | |
| df.rename(columns={ | |
| 'Value_x': 'FX', | |
| 'Value_y': 'Inflation', | |
| 'CLOSE': 'C Market' | |
| }, inplace=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df = pd.merge_asof(continuous_dates, currency[['Date', 'Value']], on='Date', direction='nearest') | |
| df = pd.merge_asof(df, inflation[['Date', 'Value']], on='Date', direction='forward') | |
| df = pd.merge_asof(df, prices[['Date', 'CLOSE']], on='Date', direction='backward') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import timedelta | |
| start_date = datetime(1999, 4, 1) | |
| end_date = datetime(2019, 3, 31) | |
| this_date = start_date | |
| date_range = [] | |
| while this_date <= end_date: | |
| date_range.append(this_date) | |
| this_date += timedelta(1) | |