Skip to content

Commit

Permalink
v1.2 testing6
Browse files Browse the repository at this point in the history
  • Loading branch information
JECSand committed Aug 29, 2018
1 parent c72375b commit 28d2bda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test/test_yahoofinancials.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def test_yf_fundamentals(self):
# Historical Price Test
def test_yf_historical_price(self):
single_stock_prices = self.test_yf_stock_single.get_historical_price_data('2015-01-15', '2017-10-15', 'weekly')
expect_dict = {'high': 48.2400016784668, 'volume': 81106400, 'formatted_date': '2015-01-12',
expect_dict = {'high': 49.099998474121094, 'volume': 125737200, 'formatted_date': '2015-01-12',
'low': 46.599998474121094, 'adjclose': 45.669029235839844, 'date': 1421038800,
'close': 47.61000061035156, 'open': 48.060001373291016}
'close': 47.61000061035156, 'open': 48.959999084472656}
self.assertDictEqual(single_stock_prices['C']['prices'][0], expect_dict)

# Extra Module Methods Test
Expand Down
8 changes: 5 additions & 3 deletions yahoofinancials/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"""

import sys
import calendar
import re
from json import loads
import time
Expand Down Expand Up @@ -109,10 +110,11 @@ def format_date(in_date):
if isinstance(in_date, str):
year, month, day = in_date.split()[0].split('-')
d = date(int(year), int(month), int(day))
form_date = int(time.mktime(d.timetuple()))
#form_date = int(time.mktime(d.timetuple()))
form_date = int(calendar.timegm(time.strptime(in_date, '%Y-%m-%d')))
else:
form_date = str((datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=in_date)).date())
print(in_date)
print(form_date)
return form_date

# Private Static Method to Convert Eastern Time to UTC
Expand Down Expand Up @@ -292,7 +294,7 @@ def _build_api_url(hist_obj, up_ticker):
str(hist_obj['end']) + '&interval=' + hist_obj['interval']
api_url += '&events=div|split|earn&lang=en-US&region=US'
print(api_url)
return "https://query1.finance.yahoo.com/v8/finance/chart/C?symbol= C&period1=1421301600&period2=1508043600&interval=1wk&events=div|split|earn&lang=en-US&region=US"
return api_url

# Private Static Method to get financial data via API Call
@staticmethod
Expand Down

0 comments on commit 28d2bda

Please sign in to comment.