Ejemplo n.º 1
0
def  make_pipeline():

    base_universe = QTradableStocksUS()

    sentiment_score = SimpleMovingAverage(
        inputs=[stocktwits.bull_minus_bear],
        window_length=3,
    )

    # Create filter for top 350 and bottom 350
    # assets based on their sentiment scores
    top_bottom_scores = (
        sentiment_score.top(350) | sentiment_score.bottom(350)
    )

    return Pipeline(
        columns={
            'sentiment_score': sentiment_score,
        },
        # Set screen as the intersection between our filter
        # and trading universe
        screen=(
            base_universe
            & top_bottom_scores
        )
    )
Ejemplo n.º 2
0
def make_pipeline():
    
    base_universe = QTradableStocksUS()
    
    sentiment_score = SimpleMovingAverage(
        inputs = [stocktwits.bull_minus_bear],
        window_length = 3)
        
    top_bottom_scores = (
        sentiment_score.top(350)|sentiment_score.bottom(350))
    
    return Pipeline(
        columns = {'sentiment_score': sentiment_score}, 
        screen=(base_universe & top_bottom_scores))
Ejemplo n.º 3
0
def  make_pipeline():

    base_universe = QTradableStocksUS()


# STEP TWO, CREATE A FILTER
# sentiment_score is a simple moving average ... 
# where the inputs come from stocktwits.bull_minus_bear ...
# ... there's a bit of magic here with how this data works
# but not that it comes from pipeline.data.psychsignal import stocktwits 
# so it's obviously a data set that comes from a "psychsignal" library

    sentiment_score = SimpleMovingAverage(
        inputs=[stocktwits.bull_minus_bear],
        window_length=3,
    )

# Create filter for top 350 and bottom 350
# assets based on their sentiment scores
# NOTE: The "|" operator here is "OR" and creates a UNION. 
# The .top(350) and .bottom(350) is so powerful, wow.

    top_bottom_scores = (
        sentiment_score.top(350) | sentiment_score.bottom(350)
    )
    
# STEP THREE, return PIPELINE, AKA CREATE DATAFRAME AND SPECIFY SCREENING UNIVERSE.
# In place of "return Pipeline" maybe it's clearer to think... 
# return pandas dataframe ...
# What is Pipeline( ... ) doing? It's just defining columns of a pandas dataframe 
# and it's also inputing our specific SCREEN, that we've DEFINED 
# DEFINED as in... both base_universe and top_bottom_scores (that union we defined earlier)
# so Pipeline(...) is really taking these partial abstractions and running this targeted analysis. 
    
    return Pipeline(
        columns={
            'sentiment_score': sentiment_score,
        },
        # Set screen as the intersection between our filter
        # and trading universe
        screen=(
            base_universe
            & top_bottom_scores
        )
    )