Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yangguang authored and Yangguang committed Jun 30, 2018
1 parent 30ec739 commit 8156052
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cleanData.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
for i in stockIds:
path = get_event_path(i,'finance_report')
try:
if os.path.exists(path):
df = pd.read_csv(path)
df = index_df_with_time(df,index='reportDate')
except Exception as e:
print(path)
if os.path.exists(path):
os.remove(path)
2 changes: 1 addition & 1 deletion fooltrader/api/finance.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def get_balance_sheet_items(security_item, start_date=None, report_period=None,
if start_date:
if pd.Timestamp(reportDate[idx]) < pd.Timestamp(start_date):
continue

print(reportDate[idx])
reportEventDate = get_report_event_date(security_item, report_date=reportDate[idx])

if report_period and not is_same_date(report_period, reportDate[idx]):
Expand Down
3 changes: 3 additions & 0 deletions fooltrader/spiders/stock_finance_report_event_spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def yield_request(self, item):
def report_period_from_title(title, period_type, report_event_date):
try:
year = re.match('.*(\d{4}).*', title).group(1)
report_event_year = pd.Timestamp(report_event_date).date().year
if int(year)<int(report_event_year)-2 or int(year)>int(report_event_year):
raise Exception('wrong report year')
except Exception as e:
year = pd.Timestamp(report_event_date).date().year
if period_type == 'ndbg':
Expand Down

0 comments on commit 8156052

Please sign in to comment.