Hello community, I have a self-serve data that I want to use in my algo. Below is the top of the data:
date ticker score
12/3/15 MTSC 0.538719768
12/4/15 WAFD -0.501787895
12/9/15 HZO 0.501683899
I made a pipeline to pass the latest data (current day) in before_trading_start function and assign that to context.output, and I have a print statement in my rebalance function which happens every day.
Start from 12/3/15, it's supposed to be 1 record, 1 record, and 0 record until 12/9/15. However, what I got from the print is as following:
2015-12-03 09:35 PRINT score
Equity(5107 [MTSC]) 0.53872
2015-12-04 09:35 PRINT score
Equity(5107 [MTSC]) 0.538720
Equity(8162 [WAFD]) -0.501788
2015-12-07 09:35 PRINT score
Equity(5107 [MTSC]) 0.538720
Equity(8162 [WAFD]) -0.501788
2015-12-08 09:35 PRINT score
Equity(5107 [MTSC]) 0.538720
Equity(8162 [WAFD]) -0.501788
2015-12-09 09:35 PRINT score
Equity(5107 [MTSC]) 0.538720
Equity(8162 [WAFD]) -0.501788
Equity(18917 [HZO]) 0.501684
Looks like the pipeline output is a cumulated instead of what I described above. Did I do something wrong?
This is the code that I used:
import quantopian.algorithm as algo
import pandas as pd
import numpy as np
from quantopian.pipeline import Pipeline
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.pipeline.filters import QTradableStocksUS
from quantopian.pipeline.data import placeholder as sample
def initialize(context):
schedule_function(my_rebalance,
date_rules.every_day(),
time_rules.market_open(hours = 0, minutes = 5))
algo.attach_pipeline(make_pipeline(), 'my_pipeline')
def make_pipeline():
base_universe = QTradableStocksUS()
pipe = Pipeline(
columns = {
'score': sample.score.latest
},
screen = (base_universe & sample.score.latest.notnull())
)
return pipe
def before_trading_start(context, data):
context.output = algo.pipeline_output('my_pipeline')
def my_rebalance(context, data):
# Get current date data
df = context.output.copy()
print(df)