0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

移動平均を用いた仮想通貨のランキング作成

Last updated at Posted at 2022-10-21

目的

価格データの移動平均を用いて仮想通貨のランキングを作成します
作成したランキングを投資戦略の提案に利用することが今後の目標です

実施事項 [!]

  1. 移動平均を用いた仮想通貨のランキング作成
  2. 次のトークンに対して投資シミュレーション
    a. ランキング上位の仮想通貨
    b. ランキング下位の仮想通貨も含めた全仮想通貨
  3. a で得た ROI(投資利益率)が b より大きい場合にランキングが妥当であると判定

プログラムの実行は Kaggle Notebook で行いました

使用データ

仮想通貨の過去(2020/10/01 ~ 2022/04/01)の価格データ(from Daily prices for 2700 cryptocurrencies | Kaggle 異なるデータセットを用いていた可能性があるので確認中)

▼ データセットから Pandas DataFrame を作成するコード

import pandas as pd
fn = "../input/daily-prices-for-2700-cryptocurrencies/crypto_prices.csv"
df = pd.read_csv(fn)[["ticker", "Date", "Close"]]
nan_dates = [
    "No data is available now", 
    'Loading data...'
]
df["Date"] = df["Date"].replace(nan_dates, np.nan) # 日付でない値を欠損値とみなす
df["Date"] = pd.to_datetime(df["Date"], format = '%b %d, %Y') # 文字列を日付型に変換
first_date, last_date = "2020-10-01", "2022-04-01"
df = df.pivot_table(index='Date', columns='ticker', values='Close').loc[first_date:last_date]

▼ 作成した Pandas DataFrame:df
作成した Pandas DataFrame

収録トークン

メジャーなトークン(BTC, ETH, XRP, SOL etc.)からマイナーなトークンまで,約 2000 個以上を収録しています
ランキングの作成に十分なトークン数だと思われます

実験

ランキングを次の手続きで作成します

  1. $m$日移動平均の算出($m = 30$ とする)
  2. 各日の移動平均をランキング
  3. 上位$n$%にランクインした回数をヒストグラムにプロット($n = 12.5$ とする)

手続きの具体例

###

結果

移動平均によるランキング作成

▼ 30日移動平均が上位 12.5% である仮想通貨
移動平均上位12.5%の仮想通貨

ROI による妥当性の判定

ランキング上位 12.5% の仮想通貨を用いることで ROI が 10%~30% 増加 しました
移動平均による仮想通貨ランキングの作成は妥当だと言えます

▼ 上位 12.5% 仮想通貨と全仮想通貨の ROI 差分
投資シミュレーション結果の差分

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?