def smusingroute(*args, **kwargs): global sm sm = SymbolManager() funcres = func(*args, **kwargs) sm.finish() del sm return funcres
def __init__(self, ses, **kwargs): from trump import SymbolManager from trump.orm import ENGINE_STR if 'enginestr' in kwargs: engstr = kwargs['enginestr'] engstr = engstr or ENGINE_STR self.sm = SymbolManager(engstr)
def callback(ch, method, properties, body): sm = SymbolManager() print str(ch) print str(method) print str(properties) print str(body) sym = sm.get(body) sym.cache() print "****" sm.finish()
class Source(object): def __init__(self, ses, **kwargs): from trump import SymbolManager from trump.orm import ENGINE_STR if 'enginestr' in kwargs: engstr = kwargs['enginestr'] engstr = engstr or ENGINE_STR self.sm = SymbolManager(engstr) #Todo Check to understand if this session is kept open or not. def getseries(self, ses, **kwargs): #TODO Test to see if ses could be used here. Right now, this feels safer. sym = self.sm.get(kwargs['symbolname']) if 'cache_first' in kwargs: if kwargs['cache_first']: sym.cache() data = sym.df[kwargs['symbolname']] try: croptime = kwargs['croptime'] except: croptime = False if croptime: data.index = [t.to_datetime().date() for t in data.index] return data
from elasticsearch import Elasticsearch from elasticsearch.client import IndicesClient from trump import SymbolManager es = Elasticsearch([{'host': 'localhost', 'port':9200}]) ic = IndicesClient([{'host': 'localhost', 'port':9200}]) from equitable.db.psyw import SQLAeng sme = SQLAeng('Trump','PROD') sm = SymbolManager(sme) syms = sm.search() mapping = { 'properties': { 'name': {'type': 'string', 'index': 'not_analyzed' }, 'tags': {'type': 'string', 'index': 'not_analyzed' }, 'description': {'type': 'string'}, 'meta' : {'type' : 'nested'} } } if es.indices.exists(index='trump'): es.indices.delete(index='trump') es.indices.create(index='trump') es.indices.put_mapping(index='trump', doc_type='symbol', body=mapping)