Ejemplo n.º 1
0
 def __init__(self, config_file):
     self.config = configwrapper.ConfigWrapper(config_file=config_file)
     collections = self.build_collections()
     self.collections = collections
     self.cq = commonqueries.CommonQueries(
         port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
         host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
         username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
         password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
         dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'),
         collections=collections)
     return
Ejemplo n.º 2
0
    def __init__(self, config_file='finance_cfg.cfg'):
        self.config = configwrapper.ConfigWrapper(config_file=config_file)
        collections = self.build_collections()
        self.collections = collections

        self.cq = commonqueries.CommonQueries(
            port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
            host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
            username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
            password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
            dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'),
            collections=collections)
        self.q = quantvaluedata.quantvaluedata(self.cq.get_all_tags())

        self.last_valid_day = pd.to_datetime(
            self.cq.get_last_complete_market_day())
        self.valid_figis = [
            x['figi'] for x in list(self.cq.mongo.db[
                collections['intrinio_prices']].find({
                    'figi': {
                        '$exists': True
                    },
                    'date': {
                        "$gte": self.last_valid_day.date().strftime("%Y-%m-%d")
                    }
                }))
        ]
        self.spyprices = self.cq.get_intrinio_prices(
            value='BBG000BDTBL9', key='figi'
        )  #because sometimes the index does not update in time...
        if pd.to_datetime(self.spyprices['date'].max()) != self.last_valid_day:
            logging.error('our SPY prices are not up to date')
            exit()

        companies = self.cq.get_companies()
        self.companies = companies
        self.companies = self.companies[
            pd.to_datetime(self.companies['latest_filing_date']).dt.date >=
            datetime.now().date() - relativedelta(months=6)]
        self.companies = self.companies[self.companies['standardized_active']
                                        == True]
        self.companies = self.companies[self.companies['ticker'].isin(
            self.get_valid_instrument_symbols())]
        self.companies['figi'] = self.companies['ticker'].apply(
            self.cq.ticker2figi)
        self.companies = self.companies[self.companies['figi'].isin(
            self.valid_figis)]

        self.total_market_cap = self.get_total_market_cap()

        return
Ejemplo n.º 3
0
 def __init__(self, config_file=None):
     self.config = configwrapper.ConfigWrapper(config_file=config_file)
     data_collections = self.build_collections('FINANCIALDATA_COLLECTIONS')
     user_collections = self.build_collections('USERS_COLLECTIONS')
     self.data_collections = data_collections
     self.user_collections = user_collections
     self.data_cq = commonqueries.CommonQueries(
         port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
         host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
         username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
         password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
         dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'),
         collections=data_collections)
     self.user_cq = commonqueries.CommonQueries(
         port=self.config.get_int('USERS_MONGO', 'port'),
         host=self.config.get_string('USERS_MONGO', 'host'),
         username=self.config.get_string('USERS_MONGO', 'username'),
         password=self.config.get_string('USERS_MONGO', 'password'),
         dbname=self.config.get_string('USERS_MONGO', 'dbname'),
         collections=user_collections)
     self.key_file = self.config.get_string(
         'GOOGLE_CLOUD', 'service_file')  #get the google key file
     return
    def __init__(self,
                 config_file,
                 proxies=None,
                 timeout=300,
                 max_retries=20,
                 error_codes=range(500, 600),
                 internal_error_codes=range(400, 500),
                 host='localhost',
                 port=27017,
                 username=None,
                 password=None,
                 dbname='finance',
                 collections=None):
        self.config = configwrapper.ConfigWrapper(config_file=config_file)
        collections = self.build_collections()
        self.collections = collections
        if proxies is None:
            proxies = {}
        if collections is None:
            collections = {}
        self.av = alphavantagewrapper.AlphaVantage(
            api_key=self.config.get_string('ALPHAVANTAGE', 'api_key'),
            proxies=proxies,
            timeout=timeout,
            max_retries=max_retries,
            error_codes=error_codes,
            internal_error_codes=internal_error_codes)
        self.mongo = mongomanager.MongoManager(
            port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
            host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
            username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
            password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
            dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'))
        self.cq = commonqueries.CommonQueries(
            port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
            host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
            username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
            password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
            dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'),
            collections=collections)

        return
Ejemplo n.º 5
0
 def __init__(self, config_file):
     self.config = configwrapper.ConfigWrapper(config_file=config_file)
     collections = self.build_collections()
     self.collections = collections
     if collections is None:
         collections = {}
     self.mongo = mongomanager.MongoManager(
         port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
         host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
         username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
         password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
         dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'))
     self.cq = commonqueries.CommonQueries(
         port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
         host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
         username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
         password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
         dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'),
         collections=collections)
     self.collections = collections
     self.n = nasdaqwrapper.NasdaqWrapper()
     self.mongo.create_collections(self.collections.values())
     return
 def __init__(self,
              config_file,
              proxies=None,
              timeout=300,
              max_retries=50,
              error_codes=[500, 503],
              internal_error_codes=[401, 403, 404, 429]):
     self.config = configwrapper.ConfigWrapper(config_file=config_file)
     collections = self.build_collections()
     self.collections = collections
     auth = (self.config.get_string('INTRINIO', 'username'),
             self.config.get_string('INTRINIO', 'password'))
     if auth is None:
         auth = ()
     if proxies is None:
         proxies = {}
     if collections is None:
         collections = {}
     self.mongo = mongomanager.MongoManager(
         port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
         host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
         username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
         password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
         dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'))
     self.cq = commonqueries.CommonQueries(
         port=self.config.get_int('FINANCIALDATA_MONGO', 'port'),
         host=self.config.get_string('FINANCIALDATA_MONGO', 'host'),
         username=self.config.get_string('FINANCIALDATA_MONGO', 'username'),
         password=self.config.get_string('FINANCIALDATA_MONGO', 'password'),
         dbname=self.config.get_string('FINANCIALDATA_MONGO', 'dbname'),
         collections=collections)
     self.intrinio = intriniowrapper.IntrinioWrapper(
         auth, proxies, timeout, max_retries, error_codes,
         internal_error_codes)
     self.last_trade_day = pd.to_datetime(
         self.cq.get_last_complete_market_day())
     return