Programming Language/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
''' 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
''' 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
''' 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
''' 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
''' 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
''' 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
''' 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
''' 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
''' 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)