1
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.

PythonでFXチャートを表示してみる

Last updated at Posted at 2022-01-31

PythonでFXチャートを表示するのをGoogle Colabでやってみます。
https://colab.research.google.com

Google ColabでTA-libを使う方法
https://laid-back-scientist.com/talib

このページではyahoo_finance_api2で株価を取得していますが、アキシオリーのヒストリカルデータをダウンロードしてきます。
https://www.axiory.com/jp/how-to-install/historical-data

import talib
import pandas as pd
import mplfinance as mpf
from google.colab import drive

# Googleの株価を取得
# my_share = share.Share('GOOG')
# ohlcv = my_share.get_historical(
#     share.PERIOD_TYPE_YEAR, 1,
#    share.FREQUENCY_TYPE_DAY, 1)
#df = pd.DataFrame(ohlcv)
# unix時間をtimestampに変換
#df['timestamp'] = #pd.to_datetime(df['timestamp'].astype(int), unit='ms')

drive.mount('/content/drive')

df = pd.read_csv(filepath_or_buffer='drive/My Drive/USDJPY_2021_all.csv',
                 names = ['date','time','open','high','low','close','volume'])
df['timestamp'] = pd.to_datetime(df['date'] +" "+ df['time'], format='%Y.%m.%d %H:%M')
df.drop({'date','time'},axis = 1,inplace = True)

df.set_index("timestamp", inplace=True)
df

ヒストリカルデータをWebAPI化して使う方法もやってみました。
https://qiita.com/namikitakeo/items/208ebdcb61e6259dcc44

1
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
1
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?