Created
May 16, 2021 08:15
-
-
Save mr-yoo/293ba0f578bfff5c5cba2ba6a4dc1798 to your computer and use it in GitHub Desktop.
예쁜 차트 백테스팅 (패턴 검색)
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 numpy as np | |
import pandas as pd | |
import pyupbit | |
import time | |
import plotly.graph_objects as go | |
pat = [ 100, 90, 80, 70, 90, 120, 140 ] | |
tickers = pyupbit.get_tickers(fiat="KRW") | |
dfs = [] | |
for ticker in tickers: | |
df = pyupbit.get_ohlcv(ticker, count=7) | |
dfs.append(df['close']) | |
time.sleep(0.2) | |
df = pd.concat(dfs, axis=1) | |
df.columns = tickers | |
df['target'] = pat | |
corr = df.corr() | |
print(corr.loc['target'].sort_values()) | |
# btc = pyupbit.get_ohlcv("KRW-BTC") | |
# ltc = pyupbit.get_ohlcv("KRW-LTC") | |
# df = pd.concat([btc.close, ltc.close], axis=1) | |
# df.columns = ["BTC", "LTC"] | |
# print(df.corr().iloc[0, 1]) | |
# val = np.corrcoef(btc['close'], ltc['close']) | |
# print(val[0, 1]) | |
# co = go.Scatter( | |
# x = btc['close'], | |
# y = ltc['close'], | |
# mode = "markers" | |
# ) | |
# fig = go.Figure([co]) | |
# fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment