コード例 #1
0
ファイル: analyze.py プロジェクト: hahnicity/discerner
def get_pre_and_post_returns(args, day, prices):
    """
    Append pre and post return data
    """
    try:
        pre_start = cruncher.get_end_index(
            prices, day, index=-1 * args.interval
        )
        pre_end = cruncher.get_end_index(
            prices, pre_start, index=args.interval - 1
        )
        post_start = cruncher.get_start_index(prices, day, index=1)
        post_end = cruncher.get_end_index(
            prices, post_start, index=args.interval - 1
        )
    except SkipEvaluationError:
        logger.debug(
            "The day {} does not support being evaluated".format(day)
        )
    else:
        logger.debug("Appending to returns")
        pre_rets.append(
            (prices[pre_end] - prices[pre_start]) / prices[pre_start]
        )
        post_rets.append(
            (prices[post_end] - prices[post_start]) / prices[post_start]
        )
コード例 #2
0
ファイル: cruncher.py プロジェクト: hahnicity/discerner
def get_pages(args):
    """
    Return a dictionary of {symbol1: wikipage1, symbol2: ..., }
    """
    logger.debug("Getting all pages used")
    try:
        args.pages.__name__
    except AttributeError:
        logger.debug("Returning a custom set of pages")
        return {pair.split(":")[0]: pair.split(":")[1] for pair in args.pages}
    else:
        logger.debug("Returning pages for {}".format(args.pages.__name__))
        return args.pages()