├── code ├── Readme.md ├── Process_Data.ipynb ├── Query_Data.ipynb └── Analyze_Data.ipynb ├── spotlight ├── Readme.md └── figures │ └── Readme.md ├── data ├── Queried_Data │ └── Readme.md ├── Processed_Data │ └── Readme.md └── Readme.md ├── _config.yml ├── markdown_cheatsheet └── Readme.md ├── LICENSE ├── .github └── workflows │ └── jekyll-gh-pages.yml ├── .gitignore └── README.md /code/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spotlight/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /data/Queried_Data/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /spotlight/figures/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /data/Processed_Data/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /data/Readme.md: -------------------------------------------------------------------------------- 1 | Data Source: https://github.com/SciEcon/SoK_Blockchain_Decentralization/tree/main/Data_TokenIndex 2 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | remote_theme: pages-themes/architect@v0.2.0 2 | plugins: 3 | - jekyll-remote-theme 4 | title: Stats201 Profile 5 | description: The page of Stats201 Profile 6 | -------------------------------------------------------------------------------- /markdown_cheatsheet/Readme.md: -------------------------------------------------------------------------------- 1 | **References** 2 | - https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code 3 | - https://github.com/sunshineluyao/Readme-Cheatsheet 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Luyao (Sunshine) Zhang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/jekyll-gh-pages.yml: -------------------------------------------------------------------------------- 1 | # Sample workflow for building and deploying a Jekyll site to GitHub Pages 2 | name: Deploy Jekyll with GitHub Pages dependencies preinstalled 3 | 4 | on: 5 | # Runs on pushes targeting the default branch 6 | push: 7 | branches: ["main"] 8 | 9 | # Allows you to run this workflow manually from the Actions tab 10 | workflow_dispatch: 11 | 12 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 13 | permissions: 14 | contents: read 15 | pages: write 16 | id-token: write 17 | 18 | # Allow one concurrent deployment 19 | concurrency: 20 | group: "pages" 21 | cancel-in-progress: true 22 | 23 | jobs: 24 | # Build job 25 | build: 26 | runs-on: ubuntu-latest 27 | steps: 28 | - name: Checkout 29 | uses: actions/checkout@v3 30 | - name: Setup Pages 31 | uses: actions/configure-pages@v2 32 | - name: Build with Jekyll 33 | uses: actions/jekyll-build-pages@v1 34 | with: 35 | source: ./ 36 | destination: ./_site 37 | - name: Upload artifact 38 | uses: actions/upload-pages-artifact@v1 39 | 40 | # Deployment job 41 | deploy: 42 | environment: 43 | name: github-pages 44 | url: ${{ steps.deployment.outputs.page_url }} 45 | runs-on: ubuntu-latest 46 | needs: build 47 | steps: 48 | - name: Deploy to GitHub Pages 49 | id: deployment 50 | uses: actions/deploy-pages@v1 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Skip to content 2 | Search or jump to… 3 | Pull requests 4 | Issues 5 | Codespaces 6 | Marketplace 7 | Explore 8 | 9 | @sunshineluyao 10 | Rising-Stars-by-Sunshine 11 | / 12 | posters 13 | Public 14 | Code 15 | Issues 16 | Pull requests 17 | Actions 18 | Projects 19 | Wiki 20 | Security 21 | Insights 22 | Settings 23 | posters/.gitignore 24 | @sunshineluyao 25 | sunshineluyao Initial commit 26 | Latest commit 48fd45b on Nov 7 27 | History 28 | 1 contributor 29 | 129 lines (105 sloc) 1.76 KB 30 | 31 | # Byte-compiled / optimized / DLL files 32 | __pycache__/ 33 | *.py[cod] 34 | *$py.class 35 | 36 | # C extensions 37 | *.so 38 | 39 | # Distribution / packaging 40 | .Python 41 | build/ 42 | develop-eggs/ 43 | dist/ 44 | downloads/ 45 | eggs/ 46 | .eggs/ 47 | lib/ 48 | lib64/ 49 | parts/ 50 | sdist/ 51 | var/ 52 | wheels/ 53 | pip-wheel-metadata/ 54 | share/python-wheels/ 55 | *.egg-info/ 56 | .installed.cfg 57 | *.egg 58 | MANIFEST 59 | 60 | # PyInstaller 61 | # Usually these files are written by a python script from a template 62 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 63 | *.manifest 64 | *.spec 65 | 66 | # Installer logs 67 | pip-log.txt 68 | pip-delete-this-directory.txt 69 | 70 | # Unit test / coverage reports 71 | htmlcov/ 72 | .tox/ 73 | .nox/ 74 | .coverage 75 | .coverage.* 76 | .cache 77 | nosetests.xml 78 | coverage.xml 79 | *.cover 80 | *.py,cover 81 | .hypothesis/ 82 | .pytest_cache/ 83 | 84 | # Translations 85 | *.mo 86 | *.pot 87 | 88 | # Django stuff: 89 | *.log 90 | local_settings.py 91 | db.sqlite3 92 | db.sqlite3-journal 93 | 94 | # Flask stuff: 95 | instance/ 96 | .webassets-cache 97 | 98 | # Scrapy stuff: 99 | .scrapy 100 | 101 | # Sphinx documentation 102 | docs/_build/ 103 | 104 | # PyBuilder 105 | target/ 106 | 107 | # Jupyter Notebook 108 | .ipynb_checkpoints 109 | 110 | # IPython 111 | profile_default/ 112 | ipython_config.py 113 | 114 | # pyenv 115 | .python-version 116 | 117 | # pipenv 118 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 119 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 120 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 121 | # install all needed dependencies. 122 | #Pipfile.lock 123 | 124 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 125 | __pypackages__/ 126 | 127 | # Celery stuff 128 | celerybeat-schedule 129 | celerybeat.pid 130 | 131 | # SageMath parsed files 132 | *.sage.py 133 | 134 | # Environments 135 | .env 136 | .venv 137 | env/ 138 | venv/ 139 | ENV/ 140 | env.bak/ 141 | venv.bak/ 142 | 143 | # Spyder project settings 144 | .spyderproject 145 | .spyproject 146 | 147 | # Rope project settings 148 | .ropeproject 149 | 150 | # mkdocs documentation 151 | /site 152 | 153 | # mypy 154 | .mypy_cache/ 155 | .dmypy.json 156 | dmypy.json 157 | 158 | # Pyre type checker 159 | .pyre/ 160 | Footer 161 | © 2022 GitHub, Inc. 162 | Footer navigation 163 | Terms 164 | Privacy 165 | Security 166 | Status 167 | Docs 168 | Contact GitHub 169 | Pricing 170 | API 171 | Training 172 | Blog 173 | About 174 | posters/.gitignore at main · Rising-Stars-by-Sunshine/posters 175 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Image Classification Algorithms for NFTs: a Comparative Analysis 2 | 3 | Disclaimer: This article is a final deliverable from Prof. Luyao Zhang's project entitled "From 'Code is Law' to 'Code and Law': A Comparative Study on Blockchain Governance," supported by the 2023 Summer Research Scholarship (SRS) program at Duke Kunshan University. SciEcon wholeheartedly supports DKU's noble mission of advancing interdisciplinary research and fostering integrated talents. Our support is solely focused on promoting academic excellence and knowledge exchange. SciEcon does not seek any financial gains, property rights, or branding privileges from DKU. Moreover, individuals involved in this philanthropy event perform their roles independently at DKU and SciEcon. 4 | 5 | ## Project information 6 | - **Author**: Colden Johnson, Computation and Design, Class of 2026, Duke Kunshan University 7 | - **Research Mentor**: Prof. Luyao Zhang, Duke Kunshan University 8 | - **Acknowledgments**: I am deeply indebted to Professor Luyao Zhang for her invaluable feedback and patience. I am also thankful to both Yiyang Zhang and Jiayi Wang for their constructive review and commentary. 9 | - **Project Summary**: 10 | 11 | Non-fungible tokens (NFTs) have gained significant popularity in recent years as a new form of digital asset. This research focuses on improving and innovatively applying a dataset drawn from the article 'Mapping the NFT Revolution: market trends, trade networks, and visual features’ (Nadini et al., 2021). In order to provide a comprehensive analysis of NFT market data, we both provide data visualization and compare various image analysis techniques. 12 | 13 | Abstract: This research presents a comparative analysis of image classification algorithms for use in the NFT space, using a linked dataset comprising NFT images and their corresponding categorization. Initial exploratory visualizations were generated, providing insights into category distribution, temporal price trends, and the image dataset as a whole. Next, we conducted a comparative assessment of image classification methodologies, utilizing K-Nearest Neighbors (KNN), Convolutional Neural Networks (CNN), and CNN with transfer learning from ResNet50. The CNN approach demonstrates high efficacy, achieving 96.8% accuracy on validation data post-training using a subset of 25,000 images (fig. 2). KNN, which was used as a baseline model due to its comparative simplicity, also performed relatively well with a 93.7% accuracy (fig. 1). However, due to the relatively high accuracy even at low k-values, it is suspected that there may be some near-duplicate images in the dataset. In the future, these could be filtered out using image hash functions. Finally, the CNN incorporating transfer learning from ResNet50 recorded only a 91.1% accuracy(fig. 3), underscoring how this image classification task differs from standard image classification work. In the future, this could be improved by selecting a more tailored pre-trained image classification model to work with. This study presents a novel use for the dataset, as it has never been used to facilitate NFT image scraping and analysis. Additionally, looking at the comparative efficacy of three different image classification methodologies provides insights into the types of algorithms which are effective on NFT image datasets of this type, and is useful in informing future research on the topic. Subsequent research with this enhanced dataset could also benefit from incorporating image feature extraction and image sentiment analysis techniques. 14 | 15 | ## Table of Contents 16 | 17 | | Contents | Description | 18 | |--------|--------| 19 | | [Data](https://github.com/SciEcon/SRS2023_NFT_Johnson#data) | View Raw and Processed Data Files | 20 | | [Code](https://github.com/SciEcon/SRS2023_NFT_Johnson#code) | View Jupyter Notebook Code Files | 21 | | [Spotlight](https://github.com/SciEcon/SRS2023_NFT_Johnson#spotlight) | View Generated Spotlight Figures | 22 | | [About the Author](https://github.com/SciEcon/SRS2023_NFT_Johnson#more-about-the-author) | Read Author Bio and Project Background | 23 | | [References](https://github.com/SciEcon/SRS2023_NFT_Johnson#references) | View References CSV File | 24 | 25 | ## Data 26 | 27 | | File Name | Variable Name | Description | Unit | Type | 28 | | ------------- | ------------- | ------------- | ------------- | ------------- | 29 | | [Data_API.csv](https://github.com/SciEcon/SRS2023_NFT_Johnson/tree/main/data) | Unique_id_collection | Unique ID for a given NFT | ID | int | 30 | | | Price_crypto_USD | Price of NFT at sale | USD($) | int | 31 | | | Seller_address | Addresses for seller of NFT | address | int | 32 | | | Buyer_address | Addresses for buyers of NFT | address | int | 33 | | | Datetime_updated | Identifies transaction with daily resolution | days | DateTime | 34 | | | Image_url_1 | URL to digital object associated with the NFT | URL | URL | 35 | | | ID_token | ID of the NFT asset within a given smart contract | ID | int | 36 | | | Collection | Corresponds to the collection to which the NFT belongs | Categorical (Collection) | str | 37 | | | Category | Category in which the NFT belongs. Examples are: Art, Games, etc. | Categorical (Category) | str | 38 | 39 | **Data Source:** 40 | Nadini, M., Alessandretti, L., Di Giacinto, F. et al. Mapping the NFT revolution: market trends, trade networks, and visual features. Sci Rep 11, 20902 (2021). https://doi.org/10.1038/s41598-021-00053-8 41 | 42 | - Queried Data 43 | - Processed Data 44 | 45 | ## Spotlight 46 | - Posters 47 | - Figures 48 | 49 | ![Figure 1](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/1d387679-6f5b-4526-ad58-0c025548c707) 50 | 51 | Figure 1: NFT Category graphed against NFT Market. Notice the relative dominance of OpenSea in terms of trading volume, and the comparative frequencies of NFT types. 52 | 53 | 54 | ![Figure_2](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/15862e2c-b465-4a5b-a512-7e99e7c05253) 55 | Figure 2: Average price in USD by collection. Note that this is a metric of average trading price, and not of total market cap. 56 | 57 | ![Figure_3](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/bc4f4318-af5a-492c-b0a1-2c84e251a724) 58 | Figure 3: Average price in USD filtered by category. Categories are Metaverse, Utility, Art, Collectible, Games, and Other. This visualization only includes queried data and is not a truly accurate or proportional representation of the overall NFT market. For example, because all NFTs in the 'Gods Unchained' ecosystem have been queried, this has shifted the reflected average price and is not representative of, say, the average price of 'Gaming' type NFTs on OpenSea. 59 | 60 | ![Figure_4](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/7f8da240-93c4-4941-8ae7-d1b4c860ba99) 61 | Figure 4: Average price in USD by market. Note that filtering by market often results in different average and median NFT category valuations. For example, the high trading price of 'Decentraland' inflates the average valuation of 'Metaverse' NFTs, and the relatively low value of 'Gods Unchained' deflates the average value of 'Gaming' NFTs. 62 | 63 | ![Figure_5](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/27530afc-269b-4b6f-a57e-ed5d7537e66a) 64 | Figure 5: Average price in USD over time. This is measured by NFTs traded, grouped by week. Grouping by day does not significantly change the graph, and grouping by hour or minute creates misleading price fluctuation. 65 | 66 | ![Figure_6](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/9e55440c-0bb6-4c5f-abdf-f0ef49115238) 67 | Figure 6: Average trading price in USD over time. Three similar categories, Metaverse, Art, and Collectible are simultaneously displayed. 68 | 69 | ![Figure_7](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/a665d85c-8f99-4477-915a-313d2c14003f) 70 | 71 | Figure 7: A K-Nearest Neighbor (KNN) algorithm was used to create a baseline model due to its relative simplicity, and performed relatively well with a 93.7% accuracy. Notice how for low k-values the efficacy is validation error is relatively small, and also experiences a local minimum at a much higher k-value (k = 72). 72 | 73 | ![Figure_8](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/bb977f55-835d-4cbb-ab18-71db2dfd729e) 74 | 75 | Figure 8: Using a CNN (Convolutional Neural Network) has high efficacy, achieving 96.8% accuracy on validation data post-training using a subset of 25,000 images. However, due to the relative gap between predicted training accuracy (approaching 100%) and relatively smaller validation accuracy, there could be some issues with overfitting. Adding more images to the training dataset could help resolve this issue. 76 | 77 | ![Figure_9](https://github.com/SciEcon/SRS2023_NFT_Johnson/assets/118926209/2e4f20d8-75c6-45e3-8232-10ab64eca080) 78 | 79 | Figure 9: The CNN incorporating transfer learning from ResNet50 had only a 91.1% accuracy. In contrast to the other trained CNN, training accuracy at no point reached 99%, indicating that the underlying ResNet50 model may be poorly adapted to this dataset. 80 | 81 | - Slides 82 | - Presentations 83 | - Review articles 84 | - Media appearance 85 | 86 | ## More about the Author 87 | 88 | 89 | 90 | 91 | My name is Colden Johnson, I am a rising Sophomore student at Duke Kunshan University. I am considering a major in either Political Economy or Computation and Design with a track in Computer Science. My current research goals lie at the intersection of these two fields, and I am specifically interested in applying artificial intelligence and computation to address questions in the humanities. 92 | 93 | ## References 94 | 95 | ### Data Source 96 | Nadini, M., Alessandretti, L., Di Giacinto, F. et al. Mapping the NFT revolution: market trends, trade networks, and visual features. Sci Rep 11, 20902 (2021). https://doi.org/10.1038/s41598-021-00053-8 97 | 98 | ### Code Source 99 | - Code Source Title and URL 100 | ### Articles 101 | - Article Source Title and URL 102 | ### Literature 103 | - Literature References in [Chicago Author-Date](https://www.chicagomanualofstyle.org/tools_citationguide/citation-guide-2.html) Style and [BibTex](https://scholar.google.com/) 104 | 105 | Levin, Dan, and Luyao Zhang. 2020. “Bridging Level-K to Nash Equilibrium.” *The Review of Economics and Statistics* 104 (6): 1329–40. https://doi.org/10.1162/rest_a_00990. 106 | 107 | ``` 108 | @article{levin2022bridging, 109 | title={Bridging level-k to nash equilibrium}, 110 | author={Levin, Dan and Zhang, Luyao}, 111 | journal={Review of Economics and Statistics}, 112 | volume={104}, 113 | number={6}, 114 | pages={1329--1340}, 115 | year={2022}, 116 | publisher={MIT Press One Rogers Street, Cambridge, MA 02142-1209, USA journals-info~…} 117 | } 118 | ``` 119 | 120 | -------------------------------------------------------------------------------- /code/Process_Data.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyPIUvHYmyhu/DpZOLyf+7dP", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | }, 17 | "gpuClass": "standard" 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "source": [ 33 | "# Preliminary: Install and Important Packages" 34 | ], 35 | "metadata": { 36 | "id": "9xpBmfqtqwpT" 37 | } 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 1, 42 | "metadata": { 43 | "colab": { 44 | "base_uri": "https://localhost:8080/" 45 | }, 46 | "id": "T8tbLjSSqgaO", 47 | "outputId": "6c8a6e42-4a23-42d6-80ee-12fef6d6e0f9" 48 | }, 49 | "outputs": [ 50 | { 51 | "output_type": "stream", 52 | "name": "stdout", 53 | "text": [ 54 | "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", 55 | "Collecting kaleido\n", 56 | " Downloading kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl (79.9 MB)\n", 57 | "\u001b[K |████████████████████████████████| 79.9 MB 137 kB/s \n", 58 | "\u001b[?25hInstalling collected packages: kaleido\n", 59 | "Successfully installed kaleido-0.2.1\n" 60 | ] 61 | } 62 | ], 63 | "source": [ 64 | "! pip install kaleido" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "source": [ 70 | "import numpy as np # linear algebra\n", 71 | "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", 72 | "import decimal\n", 73 | "from datetime import datetime, date, timedelta, timezone\n", 74 | "from dateutil.relativedelta import relativedelta\n", 75 | "import plotly.offline as py \n", 76 | "import plotly.graph_objects as go\n", 77 | "from plotly.subplots import make_subplots\n", 78 | "import plotly.figure_factory as ff\n", 79 | "from scipy import stats\n", 80 | "from sklearn.linear_model import LinearRegression\n", 81 | "from sklearn import datasets, linear_model\n", 82 | "import statsmodels.api as sm\n", 83 | "import plotly.colors as pc\n", 84 | "import ipywidgets as ipw" 85 | ], 86 | "metadata": { 87 | "id": "bDPIBHMjq3Tn" 88 | }, 89 | "execution_count": 2, 90 | "outputs": [] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "source": [ 95 | "!wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage -O /usr/local/bin/orca\n", 96 | "!chmod +x /usr/local/bin/orca\n", 97 | "!apt-get install xvfb libgtk2.0-0 libgconf-2-4" 98 | ], 99 | "metadata": { 100 | "colab": { 101 | "base_uri": "https://localhost:8080/" 102 | }, 103 | "id": "a0L5LR7lq5Pb", 104 | "outputId": "87e3ae15-f6b6-48c4-b2dc-9451959bcbe3" 105 | }, 106 | "execution_count": 3, 107 | "outputs": [ 108 | { 109 | "output_type": "stream", 110 | "name": "stdout", 111 | "text": [ 112 | "--2022-11-16 13:41:11-- https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage\n", 113 | "Resolving github.com (github.com)... 140.82.112.4\n", 114 | "Connecting to github.com (github.com)|140.82.112.4|:443... connected.\n", 115 | "HTTP request sent, awaiting response... 302 Found\n", 116 | "Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/99037241/9dc3a580-286a-11e9-8a21-4312b7c8a512?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221116%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221116T134112Z&X-Amz-Expires=300&X-Amz-Signature=587fc814dafbd3e56c9bf972b4f26437ce23d45dc67a87753dbe908c47bc0cb2&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=99037241&response-content-disposition=attachment%3B%20filename%3Dorca-1.2.1-x86_64.AppImage&response-content-type=application%2Foctet-stream [following]\n", 117 | "--2022-11-16 13:41:12-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/99037241/9dc3a580-286a-11e9-8a21-4312b7c8a512?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221116%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221116T134112Z&X-Amz-Expires=300&X-Amz-Signature=587fc814dafbd3e56c9bf972b4f26437ce23d45dc67a87753dbe908c47bc0cb2&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=99037241&response-content-disposition=attachment%3B%20filename%3Dorca-1.2.1-x86_64.AppImage&response-content-type=application%2Foctet-stream\n", 118 | "Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.110.133, 185.199.108.133, ...\n", 119 | "Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.\n", 120 | "HTTP request sent, awaiting response... 200 OK\n", 121 | "Length: 51607939 (49M) [application/octet-stream]\n", 122 | "Saving to: ‘/usr/local/bin/orca’\n", 123 | "\n", 124 | "/usr/local/bin/orca 100%[===================>] 49.22M 70.6MB/s in 0.7s \n", 125 | "\n", 126 | "2022-11-16 13:41:12 (70.6 MB/s) - ‘/usr/local/bin/orca’ saved [51607939/51607939]\n", 127 | "\n", 128 | "Reading package lists... Done\n", 129 | "Building dependency tree \n", 130 | "Reading state information... Done\n", 131 | "The following package was automatically installed and is no longer required:\n", 132 | " libnvidia-common-460\n", 133 | "Use 'apt autoremove' to remove it.\n", 134 | "The following additional packages will be installed:\n", 135 | " gconf-service gconf-service-backend gconf2-common libdbus-glib-1-2\n", 136 | " libgail-common libgail18 libgtk2.0-bin libgtk2.0-common\n", 137 | "Suggested packages:\n", 138 | " gvfs\n", 139 | "The following NEW packages will be installed:\n", 140 | " gconf-service gconf-service-backend gconf2-common libdbus-glib-1-2\n", 141 | " libgail-common libgail18 libgconf-2-4 libgtk2.0-0 libgtk2.0-bin\n", 142 | " libgtk2.0-common xvfb\n", 143 | "0 upgraded, 11 newly installed, 0 to remove and 5 not upgraded.\n", 144 | "Need to get 3,716 kB of archives.\n", 145 | "After this operation, 17.2 MB of additional disk space will be used.\n", 146 | "Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libdbus-glib-1-2 amd64 0.110-2 [58.3 kB]\n", 147 | "Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf2-common all 3.2.6-4ubuntu1 [700 kB]\n", 148 | "Get:3 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libgconf-2-4 amd64 3.2.6-4ubuntu1 [84.8 kB]\n", 149 | "Get:4 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf-service-backend amd64 3.2.6-4ubuntu1 [58.1 kB]\n", 150 | "Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf-service amd64 3.2.6-4ubuntu1 [2,036 B]\n", 151 | "Get:6 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-common all 2.24.32-1ubuntu1 [125 kB]\n", 152 | "Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-0 amd64 2.24.32-1ubuntu1 [1,769 kB]\n", 153 | "Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgail18 amd64 2.24.32-1ubuntu1 [14.2 kB]\n", 154 | "Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgail-common amd64 2.24.32-1ubuntu1 [112 kB]\n", 155 | "Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-bin amd64 2.24.32-1ubuntu1 [7,536 B]\n", 156 | "Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 xvfb amd64 2:1.19.6-1ubuntu4.11 [785 kB]\n", 157 | "Fetched 3,716 kB in 1s (2,639 kB/s)\n", 158 | "Selecting previously unselected package libdbus-glib-1-2:amd64.\n", 159 | "(Reading database ... 123991 files and directories currently installed.)\n", 160 | "Preparing to unpack .../00-libdbus-glib-1-2_0.110-2_amd64.deb ...\n", 161 | "Unpacking libdbus-glib-1-2:amd64 (0.110-2) ...\n", 162 | "Selecting previously unselected package gconf2-common.\n", 163 | "Preparing to unpack .../01-gconf2-common_3.2.6-4ubuntu1_all.deb ...\n", 164 | "Unpacking gconf2-common (3.2.6-4ubuntu1) ...\n", 165 | "Selecting previously unselected package libgconf-2-4:amd64.\n", 166 | "Preparing to unpack .../02-libgconf-2-4_3.2.6-4ubuntu1_amd64.deb ...\n", 167 | "Unpacking libgconf-2-4:amd64 (3.2.6-4ubuntu1) ...\n", 168 | "Selecting previously unselected package gconf-service-backend.\n", 169 | "Preparing to unpack .../03-gconf-service-backend_3.2.6-4ubuntu1_amd64.deb ...\n", 170 | "Unpacking gconf-service-backend (3.2.6-4ubuntu1) ...\n", 171 | "Selecting previously unselected package gconf-service.\n", 172 | "Preparing to unpack .../04-gconf-service_3.2.6-4ubuntu1_amd64.deb ...\n", 173 | "Unpacking gconf-service (3.2.6-4ubuntu1) ...\n", 174 | "Selecting previously unselected package libgtk2.0-common.\n", 175 | "Preparing to unpack .../05-libgtk2.0-common_2.24.32-1ubuntu1_all.deb ...\n", 176 | "Unpacking libgtk2.0-common (2.24.32-1ubuntu1) ...\n", 177 | "Selecting previously unselected package libgtk2.0-0:amd64.\n", 178 | "Preparing to unpack .../06-libgtk2.0-0_2.24.32-1ubuntu1_amd64.deb ...\n", 179 | "Unpacking libgtk2.0-0:amd64 (2.24.32-1ubuntu1) ...\n", 180 | "Selecting previously unselected package libgail18:amd64.\n", 181 | "Preparing to unpack .../07-libgail18_2.24.32-1ubuntu1_amd64.deb ...\n", 182 | "Unpacking libgail18:amd64 (2.24.32-1ubuntu1) ...\n", 183 | "Selecting previously unselected package libgail-common:amd64.\n", 184 | "Preparing to unpack .../08-libgail-common_2.24.32-1ubuntu1_amd64.deb ...\n", 185 | "Unpacking libgail-common:amd64 (2.24.32-1ubuntu1) ...\n", 186 | "Selecting previously unselected package libgtk2.0-bin.\n", 187 | "Preparing to unpack .../09-libgtk2.0-bin_2.24.32-1ubuntu1_amd64.deb ...\n", 188 | "Unpacking libgtk2.0-bin (2.24.32-1ubuntu1) ...\n", 189 | "Selecting previously unselected package xvfb.\n", 190 | "Preparing to unpack .../10-xvfb_2%3a1.19.6-1ubuntu4.11_amd64.deb ...\n", 191 | "Unpacking xvfb (2:1.19.6-1ubuntu4.11) ...\n", 192 | "Setting up gconf2-common (3.2.6-4ubuntu1) ...\n", 193 | "\n", 194 | "Creating config file /etc/gconf/2/path with new version\n", 195 | "Setting up libgtk2.0-common (2.24.32-1ubuntu1) ...\n", 196 | "Setting up libdbus-glib-1-2:amd64 (0.110-2) ...\n", 197 | "Setting up xvfb (2:1.19.6-1ubuntu4.11) ...\n", 198 | "Setting up libgconf-2-4:amd64 (3.2.6-4ubuntu1) ...\n", 199 | "Setting up libgtk2.0-0:amd64 (2.24.32-1ubuntu1) ...\n", 200 | "Setting up libgail18:amd64 (2.24.32-1ubuntu1) ...\n", 201 | "Setting up libgail-common:amd64 (2.24.32-1ubuntu1) ...\n", 202 | "Setting up libgtk2.0-bin (2.24.32-1ubuntu1) ...\n", 203 | "Setting up gconf-service-backend (3.2.6-4ubuntu1) ...\n", 204 | "Setting up gconf-service (3.2.6-4ubuntu1) ...\n", 205 | "Processing triggers for libc-bin (2.27-3ubuntu1.6) ...\n", 206 | "Processing triggers for man-db (2.8.3-2ubuntu0.1) ...\n" 207 | ] 208 | } 209 | ] 210 | }, 211 | { 212 | "cell_type": "markdown", 213 | "source": [ 214 | "# Import Data" 215 | ], 216 | "metadata": { 217 | "id": "l0LGML52q7xj" 218 | } 219 | }, 220 | { 221 | "cell_type": "code", 222 | "source": [ 223 | "# Import the Queried Decentralization Index for AAVE\n", 224 | "Aave_ent = pd.read_csv('https://raw.githubusercontent.com/sunshineluyao/portfolio/main/data/Queried_Data/Aave_Queried.csv',parse_dates=['date'],index_col=\"Unnamed: 0\")\n", 225 | "Aave_ent.head()" 226 | ], 227 | "metadata": { 228 | "colab": { 229 | "base_uri": "https://localhost:8080/", 230 | "height": 206 231 | }, 232 | "id": "KLBc3NgxrFmL", 233 | "outputId": "dc2cd6ec-6f18-45e9-eae5-a4a17fe2ca43" 234 | }, 235 | "execution_count": 5, 236 | "outputs": [ 237 | { 238 | "output_type": "execute_result", 239 | "data": { 240 | "text/plain": [ 241 | " val date\n", 242 | "0 2.509188 2020-10-02\n", 243 | "1 190.326283 2020-10-03\n", 244 | "2 43.323227 2020-10-04\n", 245 | "3 7.090763 2020-10-05\n", 246 | "4 16.404632 2020-10-06" 247 | ], 248 | "text/html": [ 249 | "\n", 250 | "
\n", 251 | "
\n", 252 | "
\n", 253 | "\n", 266 | "\n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | "
valdate
02.5091882020-10-02
1190.3262832020-10-03
243.3232272020-10-04
37.0907632020-10-05
416.4046322020-10-06
\n", 302 | "
\n", 303 | " \n", 313 | " \n", 314 | " \n", 351 | "\n", 352 | " \n", 376 | "
\n", 377 | "
\n", 378 | " " 379 | ] 380 | }, 381 | "metadata": {}, 382 | "execution_count": 5 383 | } 384 | ] 385 | }, 386 | { 387 | "cell_type": "code", 388 | "source": [ 389 | "# Import the Queried Decentralization Index for COMP\n", 390 | "Comp_ent = pd.read_csv('https://raw.githubusercontent.com/sunshineluyao/portfolio/main/data/Queried_Data/Comp_Queried.csv',parse_dates=['date'],index_col=\"Unnamed: 0\")\n", 391 | "Comp_ent.head()" 392 | ], 393 | "metadata": { 394 | "colab": { 395 | "base_uri": "https://localhost:8080/", 396 | "height": 206 397 | }, 398 | "id": "Xr96IKGbrYGr", 399 | "outputId": "5364f3ef-7958-4393-81b5-e11704402b9c" 400 | }, 401 | "execution_count": 6, 402 | "outputs": [ 403 | { 404 | "output_type": "execute_result", 405 | "data": { 406 | "text/plain": [ 407 | " val date\n", 408 | "0 1.000000 2020-06-14\n", 409 | "1 16.063681 2020-06-15\n", 410 | "2 46.431202 2020-06-16\n", 411 | "3 1.758514 2020-06-17\n", 412 | "4 1.281994 2020-06-18" 413 | ], 414 | "text/html": [ 415 | "\n", 416 | "
\n", 417 | "
\n", 418 | "
\n", 419 | "\n", 432 | "\n", 433 | " \n", 434 | " \n", 435 | " \n", 436 | " \n", 437 | " \n", 438 | " \n", 439 | " \n", 440 | " \n", 441 | " \n", 442 | " \n", 443 | " \n", 444 | " \n", 445 | " \n", 446 | " \n", 447 | " \n", 448 | " \n", 449 | " \n", 450 | " \n", 451 | " \n", 452 | " \n", 453 | " \n", 454 | " \n", 455 | " \n", 456 | " \n", 457 | " \n", 458 | " \n", 459 | " \n", 460 | " \n", 461 | " \n", 462 | " \n", 463 | " \n", 464 | " \n", 465 | " \n", 466 | " \n", 467 | "
valdate
01.0000002020-06-14
116.0636812020-06-15
246.4312022020-06-16
31.7585142020-06-17
41.2819942020-06-18
\n", 468 | "
\n", 469 | " \n", 479 | " \n", 480 | " \n", 517 | "\n", 518 | " \n", 542 | "
\n", 543 | "
\n", 544 | " " 545 | ] 546 | }, 547 | "metadata": {}, 548 | "execution_count": 6 549 | } 550 | ] 551 | }, 552 | { 553 | "cell_type": "code", 554 | "source": [ 555 | "### Homework for LUSD" 556 | ], 557 | "metadata": { 558 | "id": "vNscUjiFrw2C" 559 | }, 560 | "execution_count": null, 561 | "outputs": [] 562 | }, 563 | { 564 | "cell_type": "markdown", 565 | "source": [ 566 | "# Process Data" 567 | ], 568 | "metadata": { 569 | "id": "5Et3qbGEr23l" 570 | } 571 | }, 572 | { 573 | "cell_type": "code", 574 | "source": [ 575 | "# Define the functions for Processing Data\n", 576 | "def ent(token):\n", 577 | " ent_exp = pd.DataFrame()\n", 578 | " ent_exp['val'] = token['val']\n", 579 | " ent_exp['date'] = token['date']\n", 580 | " ent_exp['n'] = range(1,ent_exp.shape[0]+1)\n", 581 | " ent_exp['SMA30'] = ent_exp.val.rolling(30, min_periods=1).mean()\n", 582 | " ent_exp['SMA60'] = ent_exp.val.rolling(60, min_periods=1).mean()\n", 583 | " ent_exp['SMA90'] = ent_exp.val.rolling(90, min_periods=1).mean()\n", 584 | " ent_exp['SMA180'] = ent_exp.val.rolling(180, min_periods=1).mean()\n", 585 | " ent_exp['EMA'] = ent_exp['val'].ewm(alpha=0.1, adjust=False).mean()\n", 586 | " ent_exp['EMA0.3'] = ent_exp['val'].ewm(alpha=0.3, adjust=False).mean()\n", 587 | " return ent_exp" 588 | ], 589 | "metadata": { 590 | "id": "fwo3AaPyr5NR" 591 | }, 592 | "execution_count": 7, 593 | "outputs": [] 594 | }, 595 | { 596 | "cell_type": "code", 597 | "source": [ 598 | "# Process the Data using the defined functions for Aave\n", 599 | "Aave_ent = ent(Aave_ent)\n", 600 | "Aave_ent.head()" 601 | ], 602 | "metadata": { 603 | "colab": { 604 | "base_uri": "https://localhost:8080/", 605 | "height": 206 606 | }, 607 | "id": "89KliRJdsCRK", 608 | "outputId": "8ad50a34-3ef2-43c9-9767-606f52457779" 609 | }, 610 | "execution_count": 8, 611 | "outputs": [ 612 | { 613 | "output_type": "execute_result", 614 | "data": { 615 | "text/plain": [ 616 | " val date n SMA30 SMA60 SMA90 SMA180 \\\n", 617 | "0 2.509188 2020-10-02 1 2.509188 2.509188 2.509188 2.509188 \n", 618 | "1 190.326283 2020-10-03 2 96.417735 96.417735 96.417735 96.417735 \n", 619 | "2 43.323227 2020-10-04 3 78.719566 78.719566 78.719566 78.719566 \n", 620 | "3 7.090763 2020-10-05 4 60.812365 60.812365 60.812365 60.812365 \n", 621 | "4 16.404632 2020-10-06 5 51.930819 51.930819 51.930819 51.930819 \n", 622 | "\n", 623 | " EMA EMA0.3 \n", 624 | "0 2.509188 2.509188 \n", 625 | "1 21.290898 58.854316 \n", 626 | "2 23.494130 54.194990 \n", 627 | "3 21.853794 40.063721 \n", 628 | "4 21.308878 32.965995 " 629 | ], 630 | "text/html": [ 631 | "\n", 632 | "
\n", 633 | "
\n", 634 | "
\n", 635 | "\n", 648 | "\n", 649 | " \n", 650 | " \n", 651 | " \n", 652 | " \n", 653 | " \n", 654 | " \n", 655 | " \n", 656 | " \n", 657 | " \n", 658 | " \n", 659 | " \n", 660 | " \n", 661 | " \n", 662 | " \n", 663 | " \n", 664 | " \n", 665 | " \n", 666 | " \n", 667 | " \n", 668 | " \n", 669 | " \n", 670 | " \n", 671 | " \n", 672 | " \n", 673 | " \n", 674 | " \n", 675 | " \n", 676 | " \n", 677 | " \n", 678 | " \n", 679 | " \n", 680 | " \n", 681 | " \n", 682 | " \n", 683 | " \n", 684 | " \n", 685 | " \n", 686 | " \n", 687 | " \n", 688 | " \n", 689 | " \n", 690 | " \n", 691 | " \n", 692 | " \n", 693 | " \n", 694 | " \n", 695 | " \n", 696 | " \n", 697 | " \n", 698 | " \n", 699 | " \n", 700 | " \n", 701 | " \n", 702 | " \n", 703 | " \n", 704 | " \n", 705 | " \n", 706 | " \n", 707 | " \n", 708 | " \n", 709 | " \n", 710 | " \n", 711 | " \n", 712 | " \n", 713 | " \n", 714 | " \n", 715 | " \n", 716 | " \n", 717 | " \n", 718 | " \n", 719 | " \n", 720 | " \n", 721 | " \n", 722 | " \n", 723 | " \n", 724 | " \n", 725 | "
valdatenSMA30SMA60SMA90SMA180EMAEMA0.3
02.5091882020-10-0212.5091882.5091882.5091882.5091882.5091882.509188
1190.3262832020-10-03296.41773596.41773596.41773596.41773521.29089858.854316
243.3232272020-10-04378.71956678.71956678.71956678.71956623.49413054.194990
37.0907632020-10-05460.81236560.81236560.81236560.81236521.85379440.063721
416.4046322020-10-06551.93081951.93081951.93081951.93081921.30887832.965995
\n", 726 | "
\n", 727 | " \n", 737 | " \n", 738 | " \n", 775 | "\n", 776 | " \n", 800 | "
\n", 801 | "
\n", 802 | " " 803 | ] 804 | }, 805 | "metadata": {}, 806 | "execution_count": 8 807 | } 808 | ] 809 | }, 810 | { 811 | "cell_type": "code", 812 | "source": [ 813 | "# Comp and Lusd for your homework" 814 | ], 815 | "metadata": { 816 | "id": "r49BOvnqsNF2" 817 | }, 818 | "execution_count": null, 819 | "outputs": [] 820 | }, 821 | { 822 | "cell_type": "markdown", 823 | "source": [ 824 | "# Export Data" 825 | ], 826 | "metadata": { 827 | "id": "KPL9J8dcsdIc" 828 | } 829 | }, 830 | { 831 | "cell_type": "code", 832 | "source": [ 833 | "Aave_ent.to_csv(\"Aave_Processed.csv\")" 834 | ], 835 | "metadata": { 836 | "id": "OP9rho6lsfyN" 837 | }, 838 | "execution_count": 9, 839 | "outputs": [] 840 | }, 841 | { 842 | "cell_type": "code", 843 | "source": [ 844 | "# Comp and Lusd for your homework" 845 | ], 846 | "metadata": { 847 | "id": "9_5yRIzUskhg" 848 | }, 849 | "execution_count": null, 850 | "outputs": [] 851 | } 852 | ] 853 | } -------------------------------------------------------------------------------- /code/Query_Data.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyNW2zZvoAHPHbqvtb40AZYJ", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | }, 17 | "gpuClass": "standard" 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "source": [ 33 | "# Preliminary: Install and Import Packages" 34 | ], 35 | "metadata": { 36 | "id": "1UxaV-mRn667" 37 | } 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 1, 42 | "metadata": { 43 | "colab": { 44 | "base_uri": "https://localhost:8080/" 45 | }, 46 | "id": "Wy7xARdvn0ko", 47 | "outputId": "5715b339-95ed-4507-bc04-a1c097cb2d3b" 48 | }, 49 | "outputs": [ 50 | { 51 | "output_type": "stream", 52 | "name": "stdout", 53 | "text": [ 54 | "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", 55 | "Collecting kaleido\n", 56 | " Downloading kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl (79.9 MB)\n", 57 | "\u001b[K |████████████████████████████████| 79.9 MB 171 kB/s \n", 58 | "\u001b[?25hInstalling collected packages: kaleido\n", 59 | "Successfully installed kaleido-0.2.1\n" 60 | ] 61 | } 62 | ], 63 | "source": [ 64 | "! pip install kaleido" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "source": [ 70 | "import numpy as np # linear algebra\n", 71 | "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", 72 | "import decimal\n", 73 | "from datetime import datetime, date, timedelta, timezone\n", 74 | "from dateutil.relativedelta import relativedelta\n", 75 | "import plotly.offline as py \n", 76 | "import plotly.graph_objects as go\n", 77 | "from plotly.subplots import make_subplots\n", 78 | "import plotly.figure_factory as ff\n", 79 | "from scipy import stats\n", 80 | "from sklearn.linear_model import LinearRegression\n", 81 | "from sklearn import datasets, linear_model\n", 82 | "import statsmodels.api as sm\n", 83 | "import plotly.colors as pc\n", 84 | "import ipywidgets as ipw" 85 | ], 86 | "metadata": { 87 | "id": "iwQtzgbBoAMh" 88 | }, 89 | "execution_count": 2, 90 | "outputs": [] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "source": [ 95 | "!wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage -O /usr/local/bin/orca\n", 96 | "!chmod +x /usr/local/bin/orca\n", 97 | "!apt-get install xvfb libgtk2.0-0 libgconf-2-4" 98 | ], 99 | "metadata": { 100 | "colab": { 101 | "base_uri": "https://localhost:8080/" 102 | }, 103 | "id": "LcPFuuzqoB8H", 104 | "outputId": "5b66efb9-9109-4c26-9776-b3853e15eb6e" 105 | }, 106 | "execution_count": 3, 107 | "outputs": [ 108 | { 109 | "output_type": "stream", 110 | "name": "stdout", 111 | "text": [ 112 | "--2022-11-16 13:28:27-- https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage\n", 113 | "Resolving github.com (github.com)... 140.82.113.3\n", 114 | "Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n", 115 | "HTTP request sent, awaiting response... 302 Found\n", 116 | "Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/99037241/9dc3a580-286a-11e9-8a21-4312b7c8a512?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221116%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221116T132827Z&X-Amz-Expires=300&X-Amz-Signature=7d6dad0dc470afd9ca9efd386f4adf16a8cdbc24586c68c683e1a4cdb4d2487d&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=99037241&response-content-disposition=attachment%3B%20filename%3Dorca-1.2.1-x86_64.AppImage&response-content-type=application%2Foctet-stream [following]\n", 117 | "--2022-11-16 13:28:27-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/99037241/9dc3a580-286a-11e9-8a21-4312b7c8a512?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221116%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221116T132827Z&X-Amz-Expires=300&X-Amz-Signature=7d6dad0dc470afd9ca9efd386f4adf16a8cdbc24586c68c683e1a4cdb4d2487d&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=99037241&response-content-disposition=attachment%3B%20filename%3Dorca-1.2.1-x86_64.AppImage&response-content-type=application%2Foctet-stream\n", 118 | "Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...\n", 119 | "Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.\n", 120 | "HTTP request sent, awaiting response... 200 OK\n", 121 | "Length: 51607939 (49M) [application/octet-stream]\n", 122 | "Saving to: ‘/usr/local/bin/orca’\n", 123 | "\n", 124 | "/usr/local/bin/orca 100%[===================>] 49.22M 26.2MB/s in 1.9s \n", 125 | "\n", 126 | "2022-11-16 13:28:30 (26.2 MB/s) - ‘/usr/local/bin/orca’ saved [51607939/51607939]\n", 127 | "\n", 128 | "Reading package lists... Done\n", 129 | "Building dependency tree \n", 130 | "Reading state information... Done\n", 131 | "The following package was automatically installed and is no longer required:\n", 132 | " libnvidia-common-460\n", 133 | "Use 'apt autoremove' to remove it.\n", 134 | "The following additional packages will be installed:\n", 135 | " gconf-service gconf-service-backend gconf2-common libdbus-glib-1-2\n", 136 | " libgail-common libgail18 libgtk2.0-bin libgtk2.0-common\n", 137 | "Suggested packages:\n", 138 | " gvfs\n", 139 | "The following NEW packages will be installed:\n", 140 | " gconf-service gconf-service-backend gconf2-common libdbus-glib-1-2\n", 141 | " libgail-common libgail18 libgconf-2-4 libgtk2.0-0 libgtk2.0-bin\n", 142 | " libgtk2.0-common xvfb\n", 143 | "0 upgraded, 11 newly installed, 0 to remove and 5 not upgraded.\n", 144 | "Need to get 3,716 kB of archives.\n", 145 | "After this operation, 17.2 MB of additional disk space will be used.\n", 146 | "Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libdbus-glib-1-2 amd64 0.110-2 [58.3 kB]\n", 147 | "Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf2-common all 3.2.6-4ubuntu1 [700 kB]\n", 148 | "Get:3 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libgconf-2-4 amd64 3.2.6-4ubuntu1 [84.8 kB]\n", 149 | "Get:4 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf-service-backend amd64 3.2.6-4ubuntu1 [58.1 kB]\n", 150 | "Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf-service amd64 3.2.6-4ubuntu1 [2,036 B]\n", 151 | "Get:6 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-common all 2.24.32-1ubuntu1 [125 kB]\n", 152 | "Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-0 amd64 2.24.32-1ubuntu1 [1,769 kB]\n", 153 | "Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgail18 amd64 2.24.32-1ubuntu1 [14.2 kB]\n", 154 | "Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgail-common amd64 2.24.32-1ubuntu1 [112 kB]\n", 155 | "Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-bin amd64 2.24.32-1ubuntu1 [7,536 B]\n", 156 | "Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 xvfb amd64 2:1.19.6-1ubuntu4.11 [785 kB]\n", 157 | "Fetched 3,716 kB in 2s (2,384 kB/s)\n", 158 | "Selecting previously unselected package libdbus-glib-1-2:amd64.\n", 159 | "(Reading database ... 123991 files and directories currently installed.)\n", 160 | "Preparing to unpack .../00-libdbus-glib-1-2_0.110-2_amd64.deb ...\n", 161 | "Unpacking libdbus-glib-1-2:amd64 (0.110-2) ...\n", 162 | "Selecting previously unselected package gconf2-common.\n", 163 | "Preparing to unpack .../01-gconf2-common_3.2.6-4ubuntu1_all.deb ...\n", 164 | "Unpacking gconf2-common (3.2.6-4ubuntu1) ...\n", 165 | "Selecting previously unselected package libgconf-2-4:amd64.\n", 166 | "Preparing to unpack .../02-libgconf-2-4_3.2.6-4ubuntu1_amd64.deb ...\n", 167 | "Unpacking libgconf-2-4:amd64 (3.2.6-4ubuntu1) ...\n", 168 | "Selecting previously unselected package gconf-service-backend.\n", 169 | "Preparing to unpack .../03-gconf-service-backend_3.2.6-4ubuntu1_amd64.deb ...\n", 170 | "Unpacking gconf-service-backend (3.2.6-4ubuntu1) ...\n", 171 | "Selecting previously unselected package gconf-service.\n", 172 | "Preparing to unpack .../04-gconf-service_3.2.6-4ubuntu1_amd64.deb ...\n", 173 | "Unpacking gconf-service (3.2.6-4ubuntu1) ...\n", 174 | "Selecting previously unselected package libgtk2.0-common.\n", 175 | "Preparing to unpack .../05-libgtk2.0-common_2.24.32-1ubuntu1_all.deb ...\n", 176 | "Unpacking libgtk2.0-common (2.24.32-1ubuntu1) ...\n", 177 | "Selecting previously unselected package libgtk2.0-0:amd64.\n", 178 | "Preparing to unpack .../06-libgtk2.0-0_2.24.32-1ubuntu1_amd64.deb ...\n", 179 | "Unpacking libgtk2.0-0:amd64 (2.24.32-1ubuntu1) ...\n", 180 | "Selecting previously unselected package libgail18:amd64.\n", 181 | "Preparing to unpack .../07-libgail18_2.24.32-1ubuntu1_amd64.deb ...\n", 182 | "Unpacking libgail18:amd64 (2.24.32-1ubuntu1) ...\n", 183 | "Selecting previously unselected package libgail-common:amd64.\n", 184 | "Preparing to unpack .../08-libgail-common_2.24.32-1ubuntu1_amd64.deb ...\n", 185 | "Unpacking libgail-common:amd64 (2.24.32-1ubuntu1) ...\n", 186 | "Selecting previously unselected package libgtk2.0-bin.\n", 187 | "Preparing to unpack .../09-libgtk2.0-bin_2.24.32-1ubuntu1_amd64.deb ...\n", 188 | "Unpacking libgtk2.0-bin (2.24.32-1ubuntu1) ...\n", 189 | "Selecting previously unselected package xvfb.\n", 190 | "Preparing to unpack .../10-xvfb_2%3a1.19.6-1ubuntu4.11_amd64.deb ...\n", 191 | "Unpacking xvfb (2:1.19.6-1ubuntu4.11) ...\n", 192 | "Setting up gconf2-common (3.2.6-4ubuntu1) ...\n", 193 | "\n", 194 | "Creating config file /etc/gconf/2/path with new version\n", 195 | "Setting up libgtk2.0-common (2.24.32-1ubuntu1) ...\n", 196 | "Setting up libdbus-glib-1-2:amd64 (0.110-2) ...\n", 197 | "Setting up xvfb (2:1.19.6-1ubuntu4.11) ...\n", 198 | "Setting up libgconf-2-4:amd64 (3.2.6-4ubuntu1) ...\n", 199 | "Setting up libgtk2.0-0:amd64 (2.24.32-1ubuntu1) ...\n", 200 | "Setting up libgail18:amd64 (2.24.32-1ubuntu1) ...\n", 201 | "Setting up libgail-common:amd64 (2.24.32-1ubuntu1) ...\n", 202 | "Setting up libgtk2.0-bin (2.24.32-1ubuntu1) ...\n", 203 | "Setting up gconf-service-backend (3.2.6-4ubuntu1) ...\n", 204 | "Setting up gconf-service (3.2.6-4ubuntu1) ...\n", 205 | "Processing triggers for libc-bin (2.27-3ubuntu1.6) ...\n", 206 | "Processing triggers for man-db (2.8.3-2ubuntu0.1) ...\n" 207 | ] 208 | } 209 | ] 210 | }, 211 | { 212 | "cell_type": "markdown", 213 | "source": [ 214 | "# Query Data \n" 215 | ], 216 | "metadata": { 217 | "id": "yxTHKtZNoIHp" 218 | } 219 | }, 220 | { 221 | "cell_type": "markdown", 222 | "source": [ 223 | "Query Data from the Source:\n", 224 | "\n", 225 | "https://github.com/SciEcon/SoK_Blockchain_Decentralization/tree/main/Data_TokenIndex" 226 | ], 227 | "metadata": { 228 | "id": "lmzScw7noxmm" 229 | } 230 | }, 231 | { 232 | "cell_type": "code", 233 | "source": [ 234 | "# Query the Decentralization Index for AAVE\n", 235 | "Aave_ent = pd.read_csv('https://raw.githubusercontent.com/SciEcon/SoK_Blockchain_Decentralization/main/Data_TokenIndex/Aave_ent.csv',parse_dates=['date'])\n", 236 | "\n", 237 | "# Query the Decentralization Index for COMP\n", 238 | "Comp_ent = pd.read_csv('https://raw.githubusercontent.com/SciEcon/SoK_Blockchain_Decentralization/main/Data_TokenIndex/Comp_ent.csv', parse_dates=['date'])\n", 239 | "# Query the Decentralization Index for LUSD\n", 240 | "Lusd_ent= pd.read_csv('https://raw.githubusercontent.com/SciEcon/SoK_Blockchain_Decentralization/main/Data_TokenIndex/Lusd_ent.csv', parse_dates=['date'],)" 241 | ], 242 | "metadata": { 243 | "id": "jkX4MSyVoGir" 244 | }, 245 | "execution_count": 4, 246 | "outputs": [] 247 | }, 248 | { 249 | "cell_type": "markdown", 250 | "source": [ 251 | "# Inspect Data" 252 | ], 253 | "metadata": { 254 | "id": "E9OmkW1Ko8Dd" 255 | } 256 | }, 257 | { 258 | "cell_type": "code", 259 | "source": [ 260 | "Aave_ent.head(10)" 261 | ], 262 | "metadata": { 263 | "colab": { 264 | "base_uri": "https://localhost:8080/", 265 | "height": 363 266 | }, 267 | "id": "44DcrBzCo4in", 268 | "outputId": "7c011c0f-76fb-437d-8950-aff3dec3166d" 269 | }, 270 | "execution_count": 5, 271 | "outputs": [ 272 | { 273 | "output_type": "execute_result", 274 | "data": { 275 | "text/plain": [ 276 | " val date\n", 277 | "0 2.509188 2020-10-02\n", 278 | "1 190.326283 2020-10-03\n", 279 | "2 43.323227 2020-10-04\n", 280 | "3 7.090763 2020-10-05\n", 281 | "4 16.404632 2020-10-06\n", 282 | "5 29.669511 2020-10-07\n", 283 | "6 23.694630 2020-10-08\n", 284 | "7 65.006381 2020-10-09\n", 285 | "8 55.381548 2020-10-10\n", 286 | "9 171.029380 2020-10-11" 287 | ], 288 | "text/html": [ 289 | "\n", 290 | "
\n", 291 | "
\n", 292 | "
\n", 293 | "\n", 306 | "\n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | " \n", 364 | " \n", 365 | " \n", 366 | "
valdate
02.5091882020-10-02
1190.3262832020-10-03
243.3232272020-10-04
37.0907632020-10-05
416.4046322020-10-06
529.6695112020-10-07
623.6946302020-10-08
765.0063812020-10-09
855.3815482020-10-10
9171.0293802020-10-11
\n", 367 | "
\n", 368 | " \n", 378 | " \n", 379 | " \n", 416 | "\n", 417 | " \n", 441 | "
\n", 442 | "
\n", 443 | " " 444 | ] 445 | }, 446 | "metadata": {}, 447 | "execution_count": 5 448 | } 449 | ] 450 | }, 451 | { 452 | "cell_type": "code", 453 | "source": [ 454 | "Comp_ent.head()" 455 | ], 456 | "metadata": { 457 | "colab": { 458 | "base_uri": "https://localhost:8080/", 459 | "height": 206 460 | }, 461 | "id": "SbSzvpzJpAnj", 462 | "outputId": "fc056edf-2032-411b-c0bd-4a3b56f2b875" 463 | }, 464 | "execution_count": 6, 465 | "outputs": [ 466 | { 467 | "output_type": "execute_result", 468 | "data": { 469 | "text/plain": [ 470 | " val date\n", 471 | "0 1.000000 2020-06-14\n", 472 | "1 16.063681 2020-06-15\n", 473 | "2 46.431202 2020-06-16\n", 474 | "3 1.758514 2020-06-17\n", 475 | "4 1.281994 2020-06-18" 476 | ], 477 | "text/html": [ 478 | "\n", 479 | "
\n", 480 | "
\n", 481 | "
\n", 482 | "\n", 495 | "\n", 496 | " \n", 497 | " \n", 498 | " \n", 499 | " \n", 500 | " \n", 501 | " \n", 502 | " \n", 503 | " \n", 504 | " \n", 505 | " \n", 506 | " \n", 507 | " \n", 508 | " \n", 509 | " \n", 510 | " \n", 511 | " \n", 512 | " \n", 513 | " \n", 514 | " \n", 515 | " \n", 516 | " \n", 517 | " \n", 518 | " \n", 519 | " \n", 520 | " \n", 521 | " \n", 522 | " \n", 523 | " \n", 524 | " \n", 525 | " \n", 526 | " \n", 527 | " \n", 528 | " \n", 529 | " \n", 530 | "
valdate
01.0000002020-06-14
116.0636812020-06-15
246.4312022020-06-16
31.7585142020-06-17
41.2819942020-06-18
\n", 531 | "
\n", 532 | " \n", 542 | " \n", 543 | " \n", 580 | "\n", 581 | " \n", 605 | "
\n", 606 | "
\n", 607 | " " 608 | ] 609 | }, 610 | "metadata": {}, 611 | "execution_count": 6 612 | } 613 | ] 614 | }, 615 | { 616 | "cell_type": "code", 617 | "source": [ 618 | "Lusd_ent.tail()" 619 | ], 620 | "metadata": { 621 | "colab": { 622 | "base_uri": "https://localhost:8080/", 623 | "height": 206 624 | }, 625 | "id": "YJLWFlR2pFTt", 626 | "outputId": "9aecddca-dcb9-459c-d647-befcc9dc4b3f" 627 | }, 628 | "execution_count": 7, 629 | "outputs": [ 630 | { 631 | "output_type": "execute_result", 632 | "data": { 633 | "text/plain": [ 634 | " val date\n", 635 | "586 35.264575 2022-11-12\n", 636 | "587 30.192471 2022-11-13\n", 637 | "588 38.745015 2022-11-14\n", 638 | "589 33.690625 2022-11-15\n", 639 | "590 23.835537 2022-11-16" 640 | ], 641 | "text/html": [ 642 | "\n", 643 | "
\n", 644 | "
\n", 645 | "
\n", 646 | "\n", 659 | "\n", 660 | " \n", 661 | " \n", 662 | " \n", 663 | " \n", 664 | " \n", 665 | " \n", 666 | " \n", 667 | " \n", 668 | " \n", 669 | " \n", 670 | " \n", 671 | " \n", 672 | " \n", 673 | " \n", 674 | " \n", 675 | " \n", 676 | " \n", 677 | " \n", 678 | " \n", 679 | " \n", 680 | " \n", 681 | " \n", 682 | " \n", 683 | " \n", 684 | " \n", 685 | " \n", 686 | " \n", 687 | " \n", 688 | " \n", 689 | " \n", 690 | " \n", 691 | " \n", 692 | " \n", 693 | " \n", 694 | "
valdate
58635.2645752022-11-12
58730.1924712022-11-13
58838.7450152022-11-14
58933.6906252022-11-15
59023.8355372022-11-16
\n", 695 | "
\n", 696 | " \n", 706 | " \n", 707 | " \n", 744 | "\n", 745 | " \n", 769 | "
\n", 770 | "
\n", 771 | " " 772 | ] 773 | }, 774 | "metadata": {}, 775 | "execution_count": 7 776 | } 777 | ] 778 | }, 779 | { 780 | "cell_type": "code", 781 | "source": [ 782 | "Aave_ent.dtypes" 783 | ], 784 | "metadata": { 785 | "colab": { 786 | "base_uri": "https://localhost:8080/" 787 | }, 788 | "id": "ZuRCBELwpJfg", 789 | "outputId": "a2941cd6-4e8c-4fdd-b470-380d0ddcfc39" 790 | }, 791 | "execution_count": 8, 792 | "outputs": [ 793 | { 794 | "output_type": "execute_result", 795 | "data": { 796 | "text/plain": [ 797 | "val float64\n", 798 | "date datetime64[ns]\n", 799 | "dtype: object" 800 | ] 801 | }, 802 | "metadata": {}, 803 | "execution_count": 8 804 | } 805 | ] 806 | }, 807 | { 808 | "cell_type": "code", 809 | "source": [ 810 | "Lusd_ent.info()" 811 | ], 812 | "metadata": { 813 | "colab": { 814 | "base_uri": "https://localhost:8080/" 815 | }, 816 | "id": "mJMiXigjpMPB", 817 | "outputId": "aaec2a7e-3c1f-4e3d-f9c2-c013bfc4307e" 818 | }, 819 | "execution_count": 9, 820 | "outputs": [ 821 | { 822 | "output_type": "stream", 823 | "name": "stdout", 824 | "text": [ 825 | "\n", 826 | "RangeIndex: 591 entries, 0 to 590\n", 827 | "Data columns (total 2 columns):\n", 828 | " # Column Non-Null Count Dtype \n", 829 | "--- ------ -------------- ----- \n", 830 | " 0 val 591 non-null float64 \n", 831 | " 1 date 591 non-null datetime64[ns]\n", 832 | "dtypes: datetime64[ns](1), float64(1)\n", 833 | "memory usage: 9.4 KB\n" 834 | ] 835 | } 836 | ] 837 | }, 838 | { 839 | "cell_type": "markdown", 840 | "source": [ 841 | "# Output Data" 842 | ], 843 | "metadata": { 844 | "id": "MabWt_cxpW0e" 845 | } 846 | }, 847 | { 848 | "cell_type": "code", 849 | "source": [ 850 | "Aave_ent.to_csv(\"Aave.csv\")" 851 | ], 852 | "metadata": { 853 | "id": "opQFQxxkpb2Y" 854 | }, 855 | "execution_count": 11, 856 | "outputs": [] 857 | }, 858 | { 859 | "cell_type": "code", 860 | "source": [ 861 | "Lusd_ent.to_csv(\"Lusd.csv\")" 862 | ], 863 | "metadata": { 864 | "id": "bTzdKMBXpheZ" 865 | }, 866 | "execution_count": 12, 867 | "outputs": [] 868 | }, 869 | { 870 | "cell_type": "code", 871 | "source": [ 872 | "Comp_ent.to_csv(\"Comp.csv\")" 873 | ], 874 | "metadata": { 875 | "id": "c6HuKuA4pygY" 876 | }, 877 | "execution_count": 13, 878 | "outputs": [] 879 | }, 880 | { 881 | "cell_type": "code", 882 | "source": [], 883 | "metadata": { 884 | "id": "RY7Xbd1Gp2HQ" 885 | }, 886 | "execution_count": null, 887 | "outputs": [] 888 | } 889 | ] 890 | } -------------------------------------------------------------------------------- /code/Analyze_Data.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyNwPJpJbyTmd/tTxprRlDdZ", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | }, 17 | "gpuClass": "standard" 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "source": [ 33 | "# Preliminary: Install and Import Packages " 34 | ], 35 | "metadata": { 36 | "id": "ujGK4zYrtVUB" 37 | } 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 1, 42 | "metadata": { 43 | "colab": { 44 | "base_uri": "https://localhost:8080/" 45 | }, 46 | "id": "mkT0WSR6tS4L", 47 | "outputId": "58fa6a0c-598e-43d7-f3d8-baf7e9d7ea04" 48 | }, 49 | "outputs": [ 50 | { 51 | "output_type": "stream", 52 | "name": "stdout", 53 | "text": [ 54 | "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", 55 | "Collecting kaleido\n", 56 | " Downloading kaleido-0.2.1-py2.py3-none-manylinux1_x86_64.whl (79.9 MB)\n", 57 | "\u001b[K |████████████████████████████████| 79.9 MB 130 kB/s \n", 58 | "\u001b[?25hInstalling collected packages: kaleido\n", 59 | "Successfully installed kaleido-0.2.1\n" 60 | ] 61 | } 62 | ], 63 | "source": [ 64 | "! pip install kaleido" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "source": [ 70 | "import numpy as np # linear algebra\n", 71 | "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", 72 | "import decimal\n", 73 | "from datetime import datetime, date, timedelta, timezone\n", 74 | "from dateutil.relativedelta import relativedelta\n", 75 | "import plotly.offline as py \n", 76 | "import plotly.graph_objects as go\n", 77 | "from plotly.subplots import make_subplots\n", 78 | "import plotly.figure_factory as ff\n", 79 | "from scipy import stats\n", 80 | "from sklearn.linear_model import LinearRegression\n", 81 | "from sklearn import datasets, linear_model\n", 82 | "import statsmodels.api as sm\n", 83 | "import plotly.colors as pc\n", 84 | "import ipywidgets as ipw" 85 | ], 86 | "metadata": { 87 | "id": "1O8O7XaPtcZR" 88 | }, 89 | "execution_count": 2, 90 | "outputs": [] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "source": [ 95 | "!wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage -O /usr/local/bin/orca\n", 96 | "!chmod +x /usr/local/bin/orca\n", 97 | "!apt-get install xvfb libgtk2.0-0 libgconf-2-4" 98 | ], 99 | "metadata": { 100 | "colab": { 101 | "base_uri": "https://localhost:8080/" 102 | }, 103 | "id": "cb0Qkvyutehk", 104 | "outputId": "d51b5c5d-084d-486b-9ce2-e7559d299f67" 105 | }, 106 | "execution_count": 3, 107 | "outputs": [ 108 | { 109 | "output_type": "stream", 110 | "name": "stdout", 111 | "text": [ 112 | "--2022-11-16 13:52:27-- https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage\n", 113 | "Resolving github.com (github.com)... 140.82.113.3\n", 114 | "Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n", 115 | "HTTP request sent, awaiting response... 302 Found\n", 116 | "Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/99037241/9dc3a580-286a-11e9-8a21-4312b7c8a512?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221116%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221116T135227Z&X-Amz-Expires=300&X-Amz-Signature=6a8d297c62802677790a377d324d45a4e5a4889d6672162ecfceb4ca11360bfb&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=99037241&response-content-disposition=attachment%3B%20filename%3Dorca-1.2.1-x86_64.AppImage&response-content-type=application%2Foctet-stream [following]\n", 117 | "--2022-11-16 13:52:27-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/99037241/9dc3a580-286a-11e9-8a21-4312b7c8a512?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20221116%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221116T135227Z&X-Amz-Expires=300&X-Amz-Signature=6a8d297c62802677790a377d324d45a4e5a4889d6672162ecfceb4ca11360bfb&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=99037241&response-content-disposition=attachment%3B%20filename%3Dorca-1.2.1-x86_64.AppImage&response-content-type=application%2Foctet-stream\n", 118 | "Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...\n", 119 | "Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.\n", 120 | "HTTP request sent, awaiting response... 200 OK\n", 121 | "Length: 51607939 (49M) [application/octet-stream]\n", 122 | "Saving to: ‘/usr/local/bin/orca’\n", 123 | "\n", 124 | "/usr/local/bin/orca 100%[===================>] 49.22M 25.4MB/s in 1.9s \n", 125 | "\n", 126 | "2022-11-16 13:52:30 (25.4 MB/s) - ‘/usr/local/bin/orca’ saved [51607939/51607939]\n", 127 | "\n", 128 | "Reading package lists... Done\n", 129 | "Building dependency tree \n", 130 | "Reading state information... Done\n", 131 | "The following package was automatically installed and is no longer required:\n", 132 | " libnvidia-common-460\n", 133 | "Use 'apt autoremove' to remove it.\n", 134 | "The following additional packages will be installed:\n", 135 | " gconf-service gconf-service-backend gconf2-common libdbus-glib-1-2\n", 136 | " libgail-common libgail18 libgtk2.0-bin libgtk2.0-common\n", 137 | "Suggested packages:\n", 138 | " gvfs\n", 139 | "The following NEW packages will be installed:\n", 140 | " gconf-service gconf-service-backend gconf2-common libdbus-glib-1-2\n", 141 | " libgail-common libgail18 libgconf-2-4 libgtk2.0-0 libgtk2.0-bin\n", 142 | " libgtk2.0-common xvfb\n", 143 | "0 upgraded, 11 newly installed, 0 to remove and 5 not upgraded.\n", 144 | "Need to get 3,716 kB of archives.\n", 145 | "After this operation, 17.2 MB of additional disk space will be used.\n", 146 | "Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libdbus-glib-1-2 amd64 0.110-2 [58.3 kB]\n", 147 | "Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf2-common all 3.2.6-4ubuntu1 [700 kB]\n", 148 | "Get:3 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libgconf-2-4 amd64 3.2.6-4ubuntu1 [84.8 kB]\n", 149 | "Get:4 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf-service-backend amd64 3.2.6-4ubuntu1 [58.1 kB]\n", 150 | "Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gconf-service amd64 3.2.6-4ubuntu1 [2,036 B]\n", 151 | "Get:6 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-common all 2.24.32-1ubuntu1 [125 kB]\n", 152 | "Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-0 amd64 2.24.32-1ubuntu1 [1,769 kB]\n", 153 | "Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgail18 amd64 2.24.32-1ubuntu1 [14.2 kB]\n", 154 | "Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgail-common amd64 2.24.32-1ubuntu1 [112 kB]\n", 155 | "Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgtk2.0-bin amd64 2.24.32-1ubuntu1 [7,536 B]\n", 156 | "Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 xvfb amd64 2:1.19.6-1ubuntu4.11 [785 kB]\n", 157 | "Fetched 3,716 kB in 1s (2,729 kB/s)\n", 158 | "Selecting previously unselected package libdbus-glib-1-2:amd64.\n", 159 | "(Reading database ... 123991 files and directories currently installed.)\n", 160 | "Preparing to unpack .../00-libdbus-glib-1-2_0.110-2_amd64.deb ...\n", 161 | "Unpacking libdbus-glib-1-2:amd64 (0.110-2) ...\n", 162 | "Selecting previously unselected package gconf2-common.\n", 163 | "Preparing to unpack .../01-gconf2-common_3.2.6-4ubuntu1_all.deb ...\n", 164 | "Unpacking gconf2-common (3.2.6-4ubuntu1) ...\n", 165 | "Selecting previously unselected package libgconf-2-4:amd64.\n", 166 | "Preparing to unpack .../02-libgconf-2-4_3.2.6-4ubuntu1_amd64.deb ...\n", 167 | "Unpacking libgconf-2-4:amd64 (3.2.6-4ubuntu1) ...\n", 168 | "Selecting previously unselected package gconf-service-backend.\n", 169 | "Preparing to unpack .../03-gconf-service-backend_3.2.6-4ubuntu1_amd64.deb ...\n", 170 | "Unpacking gconf-service-backend (3.2.6-4ubuntu1) ...\n", 171 | "Selecting previously unselected package gconf-service.\n", 172 | "Preparing to unpack .../04-gconf-service_3.2.6-4ubuntu1_amd64.deb ...\n", 173 | "Unpacking gconf-service (3.2.6-4ubuntu1) ...\n", 174 | "Selecting previously unselected package libgtk2.0-common.\n", 175 | "Preparing to unpack .../05-libgtk2.0-common_2.24.32-1ubuntu1_all.deb ...\n", 176 | "Unpacking libgtk2.0-common (2.24.32-1ubuntu1) ...\n", 177 | "Selecting previously unselected package libgtk2.0-0:amd64.\n", 178 | "Preparing to unpack .../06-libgtk2.0-0_2.24.32-1ubuntu1_amd64.deb ...\n", 179 | "Unpacking libgtk2.0-0:amd64 (2.24.32-1ubuntu1) ...\n", 180 | "Selecting previously unselected package libgail18:amd64.\n", 181 | "Preparing to unpack .../07-libgail18_2.24.32-1ubuntu1_amd64.deb ...\n", 182 | "Unpacking libgail18:amd64 (2.24.32-1ubuntu1) ...\n", 183 | "Selecting previously unselected package libgail-common:amd64.\n", 184 | "Preparing to unpack .../08-libgail-common_2.24.32-1ubuntu1_amd64.deb ...\n", 185 | "Unpacking libgail-common:amd64 (2.24.32-1ubuntu1) ...\n", 186 | "Selecting previously unselected package libgtk2.0-bin.\n", 187 | "Preparing to unpack .../09-libgtk2.0-bin_2.24.32-1ubuntu1_amd64.deb ...\n", 188 | "Unpacking libgtk2.0-bin (2.24.32-1ubuntu1) ...\n", 189 | "Selecting previously unselected package xvfb.\n", 190 | "Preparing to unpack .../10-xvfb_2%3a1.19.6-1ubuntu4.11_amd64.deb ...\n", 191 | "Unpacking xvfb (2:1.19.6-1ubuntu4.11) ...\n", 192 | "Setting up gconf2-common (3.2.6-4ubuntu1) ...\n", 193 | "\n", 194 | "Creating config file /etc/gconf/2/path with new version\n", 195 | "Setting up libgtk2.0-common (2.24.32-1ubuntu1) ...\n", 196 | "Setting up libdbus-glib-1-2:amd64 (0.110-2) ...\n", 197 | "Setting up xvfb (2:1.19.6-1ubuntu4.11) ...\n", 198 | "Setting up libgconf-2-4:amd64 (3.2.6-4ubuntu1) ...\n", 199 | "Setting up libgtk2.0-0:amd64 (2.24.32-1ubuntu1) ...\n", 200 | "Setting up libgail18:amd64 (2.24.32-1ubuntu1) ...\n", 201 | "Setting up libgail-common:amd64 (2.24.32-1ubuntu1) ...\n", 202 | "Setting up libgtk2.0-bin (2.24.32-1ubuntu1) ...\n", 203 | "Setting up gconf-service-backend (3.2.6-4ubuntu1) ...\n", 204 | "Setting up gconf-service (3.2.6-4ubuntu1) ...\n", 205 | "Processing triggers for libc-bin (2.27-3ubuntu1.6) ...\n", 206 | "Processing triggers for man-db (2.8.3-2ubuntu0.1) ...\n" 207 | ] 208 | } 209 | ] 210 | }, 211 | { 212 | "cell_type": "markdown", 213 | "source": [ 214 | "# Import Data" 215 | ], 216 | "metadata": { 217 | "id": "MKiT0tlytgEZ" 218 | } 219 | }, 220 | { 221 | "cell_type": "code", 222 | "source": [ 223 | "# Import the Processed Decentralization Index for AAVE\n", 224 | "Aave_ent = pd.read_csv('https://raw.githubusercontent.com/sunshineluyao/portfolio/main/data/Processed_Data/Aave_Processed.csv',parse_dates=['date'],index_col=\"Unnamed: 0\")\n", 225 | "Aave_ent.head()" 226 | ], 227 | "metadata": { 228 | "colab": { 229 | "base_uri": "https://localhost:8080/", 230 | "height": 206 231 | }, 232 | "id": "hNL80aRfto7m", 233 | "outputId": "90953dde-7e9e-44da-8b99-c750a1455423" 234 | }, 235 | "execution_count": 4, 236 | "outputs": [ 237 | { 238 | "output_type": "execute_result", 239 | "data": { 240 | "text/plain": [ 241 | " val date n SMA30 SMA60 SMA90 SMA180 \\\n", 242 | "0 2.509188 2020-10-02 1 2.509188 2.509188 2.509188 2.509188 \n", 243 | "1 190.326283 2020-10-03 2 96.417735 96.417735 96.417735 96.417735 \n", 244 | "2 43.323227 2020-10-04 3 78.719566 78.719566 78.719566 78.719566 \n", 245 | "3 7.090763 2020-10-05 4 60.812365 60.812365 60.812365 60.812365 \n", 246 | "4 16.404632 2020-10-06 5 51.930819 51.930819 51.930819 51.930819 \n", 247 | "\n", 248 | " EMA EMA0.3 \n", 249 | "0 2.509188 2.509188 \n", 250 | "1 21.290898 58.854316 \n", 251 | "2 23.494130 54.194990 \n", 252 | "3 21.853794 40.063721 \n", 253 | "4 21.308878 32.965995 " 254 | ], 255 | "text/html": [ 256 | "\n", 257 | "
\n", 258 | "
\n", 259 | "
\n", 260 | "\n", 273 | "\n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | "
valdatenSMA30SMA60SMA90SMA180EMAEMA0.3
02.5091882020-10-0212.5091882.5091882.5091882.5091882.5091882.509188
1190.3262832020-10-03296.41773596.41773596.41773596.41773521.29089858.854316
243.3232272020-10-04378.71956678.71956678.71956678.71956623.49413054.194990
37.0907632020-10-05460.81236560.81236560.81236560.81236521.85379440.063721
416.4046322020-10-06551.93081951.93081951.93081951.93081921.30887832.965995
\n", 351 | "
\n", 352 | " \n", 362 | " \n", 363 | " \n", 400 | "\n", 401 | " \n", 425 | "
\n", 426 | "
\n", 427 | " " 428 | ] 429 | }, 430 | "metadata": {}, 431 | "execution_count": 4 432 | } 433 | ] 434 | }, 435 | { 436 | "cell_type": "markdown", 437 | "source": [ 438 | "# Visualization" 439 | ], 440 | "metadata": { 441 | "id": "3cpcJ9R2t0ap" 442 | } 443 | }, 444 | { 445 | "cell_type": "code", 446 | "source": [ 447 | "fig1 = make_subplots()\n", 448 | "fig1.add_trace(go.Scatter(x=Aave_ent['n'], y=Aave_ent['SMA30'],\n", 449 | " mode='lines', name='AAVE'))\n", 450 | "### homework: add comp and aave to the code\n", 451 | "fig1.update_layout(title='Top Lending Decentralization Index Each Starting From Day 1' ,autosize=True,)\n", 452 | "py.iplot(fig1)" 453 | ], 454 | "metadata": { 455 | "colab": { 456 | "base_uri": "https://localhost:8080/", 457 | "height": 542 458 | }, 459 | "id": "-2ETqUNdtxRf", 460 | "outputId": "271fde91-53f4-4bda-f85e-aa55b2beb713" 461 | }, 462 | "execution_count": 5, 463 | "outputs": [ 464 | { 465 | "output_type": "display_data", 466 | "data": { 467 | "text/html": [ 468 | "\n", 469 | "\n", 470 | "\n", 471 | "
\n", 472 | "
\n", 497 | "\n", 498 | "" 499 | ] 500 | }, 501 | "metadata": {} 502 | } 503 | ] 504 | }, 505 | { 506 | "cell_type": "code", 507 | "source": [ 508 | "fig1 = make_subplots()\n", 509 | "fig1.add_trace(go.Scatter(x=Aave_ent['n'], y=Aave_ent['SMA30'],\n", 510 | " mode='lines', name='AAVE SMA30'))\n", 511 | "fig1.add_trace(go.Scatter(x=Aave_ent['n'], y=Aave_ent['SMA60'],\n", 512 | " mode='lines', name='AAVE SMA60'))\n", 513 | "### homework: add SMA90, EMA, EMA3.0\n", 514 | "fig1.update_layout(title='Top Decentralization Index of AAVE Starting From Day 1' ,autosize=True,)\n", 515 | "py.iplot(fig1)" 516 | ], 517 | "metadata": { 518 | "colab": { 519 | "base_uri": "https://localhost:8080/", 520 | "height": 542 521 | }, 522 | "id": "a_Jwoa3EuB1Z", 523 | "outputId": "3d4c7bee-7df0-45c6-d6c0-8ed0faf62f77" 524 | }, 525 | "execution_count": 7, 526 | "outputs": [ 527 | { 528 | "output_type": "display_data", 529 | "data": { 530 | "text/html": [ 531 | "\n", 532 | "\n", 533 | "\n", 534 | "
\n", 535 | "
\n", 560 | "\n", 561 | "" 562 | ] 563 | }, 564 | "metadata": {} 565 | } 566 | ] 567 | }, 568 | { 569 | "cell_type": "code", 570 | "source": [], 571 | "metadata": { 572 | "id": "ZyRDVpp0uUD7" 573 | }, 574 | "execution_count": null, 575 | "outputs": [] 576 | } 577 | ] 578 | } --------------------------------------------------------------------------------