mirror of
https://github.com/bspeice/metrik
synced 2024-11-23 07:38:09 -05:00
Add a flow for options quotes
This commit is contained in:
parent
6fc85653cb
commit
a8871af4e7
@ -1,2 +1,2 @@
|
||||
__version__ = '0.4.2'
|
||||
__version__ = '0.5.0'
|
||||
__release__ = __version__
|
23
metrik/flows/options_flow.py
Normal file
23
metrik/flows/options_flow.py
Normal file
@ -0,0 +1,23 @@
|
||||
from metrik.flows.base import Flow, MarketClose
|
||||
from metrik.conf import get_config
|
||||
from metrik.tasks.cboe import CboeOptionableList
|
||||
from metrik.tasks.tradeking import TradekingOptionsQuotes
|
||||
|
||||
class EquitiesFlow(Flow):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EquitiesFlow, self).__init__(*args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def get_schedule():
|
||||
return MarketClose()
|
||||
|
||||
def _run(self):
|
||||
optionable = CboeOptionableList(current_datetime=self.present,
|
||||
live=self.live)
|
||||
yield optionable
|
||||
|
||||
options_quotes = [TradekingOptionsQuotes(symbol=s,
|
||||
current_datetime=self.present,
|
||||
live=self.live)
|
||||
for s in optionable.output().retrieve()['companies']]
|
||||
yield options_quotes
|
@ -134,7 +134,6 @@ class TradekingOptionsQuotes(MongoNoBackCreateTask):
|
||||
if not chain_acquire:
|
||||
return {}
|
||||
|
||||
|
||||
chain = TradekingOptionsQuotes.retrieve_chain_syms(api, symbol)
|
||||
results = []
|
||||
for b in batch(chain, TradekingOptionsQuotes.batch_size):
|
||||
@ -147,4 +146,4 @@ class TradekingOptionsQuotes(MongoNoBackCreateTask):
|
||||
batch_results = TradekingOptionsQuotes.retrieve_quotes(api, b)
|
||||
results += batch_results
|
||||
|
||||
return results
|
||||
return {'symbol': symbol, 'chain': results}
|
||||
|
Loading…
Reference in New Issue
Block a user