def get_search_result():
    config = get_config()
    es = Elasticsearch(config.get("ES_PRODUCT"))
    bodies = construct_query_body()
    index_table = ["recomm-jyanalysereports-2018", "recomm-jymarketnews-2018"]
    query_result_doc_time = []
    for body in bodies:
        for info_source in index_table:
            query_result_doc_time += ([
                item.get("_source").get("doc_index_time") for item in
                es.search(index=info_source, body=body).get("hits").get("hits")
            ])
    time_to_dt = [
        datetime.datetime.strptime(t.split('.')[0], "%Y-%m-%dT%H:%M:%S")
        for t in query_result_doc_time
    ]
    current_time = datetime.datetime.now()
    start_time = current_time - datetime.timedelta(days=1)

    count = len([t for t in time_to_dt if t > start_time])
    d_check_result = {
        "create_time": datetime.datetime.now(),
        "24h_updated_amount": count
    }
    write_log_into_mongodb("fundamental_infos_monitor", d_check_result)
Exemple #2
0
def get_test_suit(conf_file):
    """
    :conf_file: Str
    :return: Str[]
        list of modules to run in config file on success
        None on fail
    """
    config = get_config(conf_file, ['test'])
    if config == None:
        print('failed to get config')
        return None

    if 'test' not in config.keys():
        print('invalid config file format [no test field]')
        return None

    if 'suite' not in config['test'].keys():
        print('invalid config file format [no suite field]')
        return None

    try:
        suit = ast.literal_eval(config['test']['suite'])
    except TypeError as e:
        print('failed to load suite')
        print('error message: {}'.format(e))
        return None

    return suit
Exemple #3
0
def read_config():
    """
    :return: dict
        None in fail
    """
    try:
        config = get_config(CONFIG_PATH, ['parameters'])
    except:
        print('failed to parse {}'.format(CONFIG_PATH))
        return None

    if config is None:
        print('failed to read {}'.format(CONFIG_PATH))
        return None
    return config
Exemple #4
0
def read_config():
    """
    :return: dict
        None in fail
    """
    section = ['test', 'timeouts', 'gw']

    slave_names = get_slave_names(CONFIG_PATH)
    if slave_names is None:
        print('failed to get slave names')
        return None
    section += slave_names

    config = get_config(CONFIG_PATH, section)
    if config is None:
        print('failed to read {}'.format(CONFIG_PATH))
        return None

    return config
Exemple #5
0
def get_top_tokens(top: int = 100):
    config = get_config()
    bc_mongodb = config.get("BC_MONGODB")
    port_mongodb = config.get("PORT_MONGODB")
    connection = MongoClient(bc_mongodb, port_mongodb)
    db_bcf = connection.bcf

    tokens = []
    sort_type = ("indicators.cmc_market_cap_usd", DESCENDING)
    for t in db_bcf.get_collection("token_indicator_slices").find().sort(
        [sort_type]).limit(top):
        code = t.get("code")
        name, abbr = re.match(r'(.*?)\s\((.*?)\)', t.get("name"))[0], re.match(
            r'(.*?)\s\((.*?)\)', t.get("name"))[1]
        tokens.append((code, name, abbr))

    with open("token_list.txt", "wt") as f:
        for token in tokens:
            f.write(",".join(token) + '\n')

    return tokens
Exemple #6
0
"""
This script is used to monitor the daily sequence data for top 10 coins.
The result is restored in mongo DataMonitor.seq_day_monitor .
The script is executed once a day.
"""
import datetime
import os
import sys
sys.path.append("..")
from pymongo import MongoClient, DESCENDING
from common.common import get_config, write_log_into_mongodb

config = get_config()
bc_mongodb = config.get("BC_MONGODB")
port_mongodb = config.get("PORT_MONGODB")
connection_bcf = MongoClient(bc_mongodb, port_mongodb)
db_bcf = connection_bcf.bcf

coins_with_chain_data = {
    "Bitcoin": "Bitcoin",
    "Ethereum": "Ethereum",
    "Ripple": "Ripple",
    "BitcoinCash": "BitcoinCash",
    "Stellar": "Stellar",
    "Litecoin": "Litecoin",
    "Cardano": "Cardano",
    "IOTA": "IOTA",
    "Dash": "Dash",
    "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b.neo":
    "NEO",
    "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0": "EOS"