Programming Language

Programming Language/Python

[Python] 파이썬으로 반도체 관련 주식 가격 확인하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import pandas as pd import FinanceDataReader as fdr from datetime import datetime from dateutil.relativedelta import relativedelta def get_stock_code(name): '''이름을 입력하면 코드를 리턴''' df = fdr.StockListing('KRX') stock_code = df[df['Name'] == name]['Code'].to_string(index = False) return stock_code if __name__ == '__main__': before_one_w..

Programming Language/Python

[Python] 파이썬으로 주식과 환율 비교하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import pandas as pd import FinanceDataReader as fdr from datetime import datetime from dateutil.relativedelta import relativedelta def get_stock_code(name): '''이름을 입력하면 코드를 리턴''' df = fdr.StockListing('KRX') stock_code = df[df['Name'] == name]['Code'].to_string(index = False) return stock_code def get_kospi_dataframe(): '''코스피를 리턴''..

Programming Language/Python

[Python] 파이썬으로 코스피와 삼성전자 주식의 평균값을 비교하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import pandas as pd import FinanceDataReader as fdr from datetime import datetime from dateutil.relativedelta import relativedelta def get_stock_code(name): '''이름을 입력하면 코드를 리턴''' df = fdr.StockListing('KRX') stock_code = df[df['Name'] == name]['Code'].to_string(index = False) return stock_code def get_kospi_dataframe(): '''코스피를 리턴''..

Programming Language/Python

[Python] 파이썬으로 코스피, 코스닥 평균 보는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import FinanceDataReader as fdr from datetime import datetime from dateutil.relativedelta import relativedelta import pandas as pd if __name__ == '__main__': before_one_week = (datetime.now() - relativedelta(years = 3)).strftime('%Y-%m-%d') df_ks11 = fdr.DataReader(symbol = 'KS11', start = before_one_week)[['Close']] df_kq11 = fdr.D..

Programming Language/Python

[Python] 파이썬으로 코스닥 지수 평균 구하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import FinanceDataReader as fdr from datetime import datetime from dateutil.relativedelta import relativedelta import pandas as pd if __name__ == '__main__': before_one_week = (datetime.now() - relativedelta(years = 3)).strftime('%Y-%m-%d') df_ks11 = fdr.DataReader(symbol = 'KQ11', start = before_one_week) df_ks11_close = df_ks11[['..

Programming Language/Python

[Python] 파이썬으로 코스피 지수 평균 구하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import FinanceDataReader as fdr from datetime import datetime from dateutil.relativedelta import relativedelta import pandas as pd if __name__ == '__main__': before_one_week = (datetime.now() - relativedelta(years = 3)).strftime('%Y-%m-%d') df_ks11 = fdr.DataReader(symbol = 'KS11', start = before_one_week) df_ks11_close = df_ks11[['..

Programming Language/Python

[Python] 파이썬으로 오늘부터 일주일 전까지의 주가지수 구하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import FinanceDataReader as fdr from datetime import datetime, timedelta if __name__ == '__main__': now_datetime = datetime.now() before_one_week = (now_datetime - timedelta(weeks = 1)).strftime('%Y-%m-%d') df_ks11 = fdr.DataReader(symbol = 'KS11', start = before_one_week) print(df_ks11)

Programming Language/Python

[Python] 파이썬으로 주식 코스닥만 출력하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import FinanceDataReader as fdr def get_kosdaq_dataframe(): df = fdr.StockListing('KRX') df = df[df['Market'] == 'KOSDAQ'] return df if __name__ == '__main__': df_kosdaq = get_kosdaq_dataframe() print(df_kosdaq.head(20))

Programming Language/Python

[Python] 파이썬으로 주식 코스피만 출력하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import FinanceDataReader as fdr def get_kospi_dataframe(): df = fdr.StockListing('KRX') df = df[df['Market'] == 'KOSPI'] return df if __name__ == '__main__': df_kospi = get_kospi_dataframe() print(df_kospi.head(20))

Programming Language/Python

[Python] 파이썬으로 특정 종목의 주식가격 출력하는 방법

''' pip install pandas,beautifulsoup4,finance-datareader -y ''' import FinanceDataReader as fdr def search_code(name): df = fdr.StockListing('KRX') code = df[df['Name'] == name]['Code'].to_string(index = False) return code if __name__ == '__main__': code = search_code('LG에너지솔루션') df = fdr.DataReader(symbol = code, start = '2023-01-10', end = '2023-01-20') print(df)

박경태
'Programming Language' 카테고리의 글 목록 (7 Page)