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

kyj880423 님이 알려주신대로 yfinance의 download로 데이터를 받아보시기 바랍니다. #176

Open
chohangmin opened this issue Sep 6, 2023 · 1 comment

Comments

@chohangmin
Copy link

          kyj880423 님이 알려주신대로 yfinance의 download로 데이터를 받아보시기 바랍니다.

#91
제 PC에서는 backtrader 1.9.76.123 버전에서 정상적으로 동작하는 걸 확인했습니다.

import yfinance as yf
#data = bt.feeds.YahooFinanceData(dataname='036570.KS', fromdate=datetime(2017, 1, 1), todate=datetime(2019, 12, 1))
data = bt.feeds.PandasData(dataname=yf.download('036570.KS', '2017-01-01', '2019-12-01', auto_adjust=True))

Originally posted by @INVESTAR in #122 (comment)

image

다만 buy, sell, Trades - Net Profit/Loss(True) Positive 등등의 기호 출력이 교재와 같지 않은데 이 경우는 어떻게 해결해야할까요?

@space-cap
Copy link

space-cap commented Nov 6, 2024

# data = bt.feeds.PandasData(dataname=yf.download('036570.KS', '2017-01-01', '2019-12-01', auto_adjust=True)) df = yf.download("036570.KS", start="2024-01-01", end="2024-11-05") df = df.reset_index() # 인덱스를 초기화하여 'Date' 열을 열로 변환 df.columns = ['date', 'adj_close', 'close', 'high', 'low', 'open', 'volume'] # 컬럼 이름 변경 df['date'] = pd.to_datetime(df['date'],format='%Y-%m-%d %H:%M:%S', dayfirst=True) df.set_index('date', inplace=True) data = bt.feeds.PandasData(dataname=df)

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

2 participants