Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions data_collector/data_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from query_manager import QueryManager
import pandas as pd
from datetime import datetime
import time

class DataCollector(QueryManager):

Expand Down Expand Up @@ -45,6 +46,7 @@ def get_price_table(self):
except Exception as e:
print(f'{e} : {code}')


def get_finance_table(self, path1):
self.create_finance_table()
total = len(self.codes)
Expand All @@ -54,6 +56,7 @@ def get_finance_table(self, path1):
cnt = self.replace_finance_table(code, at, total, cnt, path1)
at+=1


def get_raw_price_info(self):
self.create_raw_price_info_table()
raw_price_info_df = marcap_data('1995-05-02', '2021-12-31')
Expand All @@ -63,6 +66,7 @@ def get_raw_price_info(self):
self.replace_raw_price_info_table(r, at, total)
at+=1


def add_main_sector_tocompany(self, path):
total = len(self.codes)
at = 0
Expand All @@ -73,6 +77,7 @@ def add_main_sector_tocompany(self, path):
except Exception as e:
print(e, code)


def get_price_average_info(self):
self.create_price_average_table()
total = len(self.codes)
Expand All @@ -86,12 +91,13 @@ def get_price_average_info(self):
at_code+=1
at+=1


def get_price_monthly_info(self):
self.create_price_monthly_info_table()
data = self.bring_additional_data()
total = len(self.codes)
error_list = []
at = 0;
at = 0
for code in self.codes.itertuples():
try:
np_adjclose = self.get_adjclose(code.Symbol)
Expand All @@ -104,10 +110,12 @@ def get_price_monthly_info(self):
self.replace_price_monthly_table(code, x, y, at, total, at_code, total_code)
at_code+=1
at+=1


except Exception as e:
error_list.append([e, code])
print(f'{e} : {code}')
pass

print(error_list)

Expand All @@ -118,7 +126,22 @@ def get_market_open_info(self):
at = 0
for r in df_open.itertuples():
self.replace_market_open_info_table(r, at, total)
at+=1
at += 1


def get_new_price_info(self, code, start, end):
"""
start, end 에서는 2021-00-00 형태로 보내주면 된다.
Open, High, Low, Close, Volume, Change
"""
df = fdr.DataReader(f'{code}', int(start[:4]))
df = df.reset_index()
df = df[df["Date"] >= datetime(int(start[:4]), int(start[5:7]), int(start[8:10]))]
df = df[df["Date"] <= datetime(int(end[:4]), int(end[5:7]), int(end[8:10]))]
df_np = df.to_numpy()
return (df_np)




if __name__ == "__main__":
Expand Down