Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
suminb committed Jan 10, 2018
1 parent 7f9112c commit 407be7b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions finance/providers/yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def get_url(self, symbol):
"""
return 'https://query1.finance.yahoo.com/v8/finance/chart/{0}'

def as_timestamp(self, datetime):
return int(datetime.timestamp())

def asset_values(self, symbol, start_time, end_time,
granularity=Granularity.day):
mappings = {
Expand All @@ -40,8 +43,8 @@ def fetch_daily_data(self, symbol, start_time, end_time):

params = {
'symbol': symbol,
'period1': int(start_time.timestamp()),
'period2': int(end_time.timestamp()),
'period1': self.as_timestamp(start_time),
'period2': self.as_timestamp(end_time),
'interval': '1d',
'includePrePost': 'true',
'events': 'div%7Csplit%7Cearn',
Expand All @@ -57,8 +60,8 @@ def fetch_data_by_minutes(self, symbol, start_time, end_time):

params = {
'symbol': symbol,
'period1': int(start_time.timestamp()),
'period2': int(end_time.timestamp()),
'period1': self.as_timestamp(start_time),
'period2': self.as_timestamp(end_time),
'interval': '1m',
'includePrePost': 'true',
'events': 'div%7Csplit%7Cearn',
Expand Down

0 comments on commit 407be7b

Please sign in to comment.