Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataframe 에서 특정연도의 data만 가져오기 #119

Open
ino0821 opened this issue Jul 6, 2023 · 0 comments
Open

dataframe 에서 특정연도의 data만 가져오기 #119

ino0821 opened this issue Jul 6, 2023 · 0 comments

Comments

@ino0821
Copy link

ino0821 commented Jul 6, 2023

import pybithumb
import numpy as np
import pandas as pd

df = pybithumb.get_ohlcv("BTC")
df = df['2018']

df['range'] = (df['high']-df['low']) * 0.5
df['target'] = df['open'] + df['range'].shift(1)

df['ror'] = np.where(df['high']> df['target'], df['close'] / df['target'], 1)
df.to_excel("btc.xlsx")

ror = df['ror'].cumprod()[0]
print(ror)

책에서 2018년도의 data만 가져오려면 5번째 줄처럼 코딩하면 된다고 안내해주셨는데, keyerror라고 뜨면서 진행이 되지 않습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant