mirror of
				https://github.com/bspeice/metrik
				synced 2025-11-04 02:10:43 -05:00 
			
		
		
		
	Add fetching options quotes (daily data from Tradeking)
This commit is contained in:
		@ -6,7 +6,7 @@ import pytest
 | 
			
		||||
from six.moves import map
 | 
			
		||||
from pytz import utc
 | 
			
		||||
 | 
			
		||||
from metrik.tasks.tradeking import Tradeking1mTimesales, TradekingOptionsQuotes, TradekingApi
 | 
			
		||||
from metrik.tasks.tradeking import Tradeking1mTimesales, TradekingOptionsQuotes, TradekingApi, batch
 | 
			
		||||
from metrik.trading_days import TradingDay
 | 
			
		||||
from metrik.targets.mongo import MongoTarget
 | 
			
		||||
from test.mongo_test import MongoTest
 | 
			
		||||
@ -40,6 +40,7 @@ def test_returns_verifiable(ticker):
 | 
			
		||||
 | 
			
		||||
    assert_allclose(tradeking_ohlc, yahoo_ohlc, rtol=1e-3)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.mark.parametrize('ticker', [
 | 
			
		||||
    'AAPL', 'GOOG', 'SPY', 'REGN', 'SWHC', 'BAC', 'NVCR', 'ARGT'
 | 
			
		||||
])
 | 
			
		||||
@ -49,8 +50,20 @@ def test_chain_returns(ticker):
 | 
			
		||||
 | 
			
		||||
    assert len(chain) > 20
 | 
			
		||||
 | 
			
		||||
class TradekingTest(MongoTest):
 | 
			
		||||
 | 
			
		||||
@pytest.mark.parametrize('ticker', [
 | 
			
		||||
    'AAPL', 'GOOG', 'SPY'
 | 
			
		||||
])
 | 
			
		||||
def test_options_quote(ticker):
 | 
			
		||||
    demo_length = 25
 | 
			
		||||
    api = TradekingApi()
 | 
			
		||||
    chain = TradekingOptionsQuotes.retrieve_chain_syms(api, ticker)[:demo_length]
 | 
			
		||||
    quotes = TradekingOptionsQuotes.retrieve_quotes(api, chain)
 | 
			
		||||
 | 
			
		||||
    assert len(quotes) == demo_length
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TradekingTest(MongoTest):
 | 
			
		||||
    def test_record_is_saveable(self):
 | 
			
		||||
        # Had an issue previously where the `date` type would cause saving
 | 
			
		||||
        # to fail. Make sure that doesn't continue
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user