1
0
mirror of https://github.com/bspeice/metrik synced 2025-09-03 21:34:46 -04:00

Get command-line tools up and running

I now have something that actually gets stuff done.
This commit is contained in:
Bradlee Speice
2016-08-22 21:34:54 -04:00
parent 96c503a106
commit f2390ba34f
12 changed files with 173 additions and 31 deletions

View File

@ -11,7 +11,8 @@ class TestICE(TestCase):
def test_correct_libor_Aug8_2016(self):
# Validate with:
# https://www.theice.com/marketdata/reports/icebenchmarkadmin/ICELiborHistoricalRates.shtml?excelExport=&criteria.reportDate=8%2F8%2F16&criteria.currencyCode=USD
aug8_libor = LiborRateTask.retrieve_data(datetime(2016, 8, 8), 'USD')
aug8_libor = LiborRateTask.retrieve_historical_libor(
datetime(2016, 8, 8), 'USD')
assert aug8_libor['overnight'] == .4189
assert aug8_libor['one_week'] == .4431
@ -23,13 +24,15 @@ class TestICE(TestCase):
london_tz = pytz.timezone('Europe/London')
actual = london_tz.localize(datetime(2016, 8, 8, 11, 45, 6))
logging.info('Publication date in London time: {}'.format(aug8_libor['publication'].astimezone(london_tz)))
logging.info('Publication date in London time: {}'.format(
aug8_libor['publication'].astimezone(london_tz)))
assert aug8_libor['publication'] == actual
def test_correct_libor_Aug9_2010(self):
# Validate with:
# https://www.theice.com/marketdata/reports/icebenchmarkadmin/ICELiborHistoricalRates.shtml?excelExport=&criteria.reportDate=8%2F9%2F10&criteria.currencyCode=USD
aug9_libor = LiborRateTask.retrieve_data(datetime(2010, 8, 9), 'USD')
aug9_libor = LiborRateTask.retrieve_historical_libor(
datetime(2010, 8, 9), 'USD')
assert aug9_libor['overnight'] == .23656
assert aug9_libor['one_week'] == .27725
@ -41,7 +44,8 @@ class TestICE(TestCase):
london_tz = pytz.timezone('Europe/London')
actual = london_tz.localize(datetime(2010, 8, 9, 15, 49, 12))
logging.info('Publication date in London time: {}'.format(aug9_libor['publication'].astimezone(london_tz)))
logging.info('Publication date in London time: {}'.format(
aug9_libor['publication'].astimezone(london_tz)))
assert aug9_libor['publication'] == actual
def test_correct_date_reasoning(self):

View File

@ -1,11 +1,10 @@
from unittest import TestCase
from datetime import datetime
from metrik.trading_days import TradingDay
from metrik.trading_days import TradingDay, is_trading_day
class TradingDayTest(TestCase):
def test_skip_july4(self):
start = datetime(2016, 7, 1) # Friday
end = start + TradingDay(1)
@ -14,4 +13,12 @@ class TradingDayTest(TestCase):
def test_skip_july4_backwards(self):
end = datetime(2016, 7, 5)
start = end - TradingDay(1)
assert start == datetime(2016, 7, 1)
assert start == datetime(2016, 7, 1)
def test_not_bday(self):
for year in range(2000, 2016):
date = datetime(year, 7, 4)
assert not is_trading_day(date)
def test_is_bday(self):
assert is_trading_day(datetime(2016, 8, 23))