<jupyter_start><jupyter_text>运行<jupyter_code>from zipline.pipeline import Pipeline, STOCK_DB, Fundamentals

from zipline.pipeline.data import USEquityPricing
from zipline.pipeline.filters import StaticSids
from zipline.research.run import run_pipeline
from zipline.pipeline.builtin import NDays,IsStock
def make_pipeline():
    ndays = NDays()
    time_to_market = Fundamentals.time_to_market.latest
    return Pipeline(
        columns = {
            '上市天数':ndays,
            'time_to_market':time_to_market
        },
        screen = IsStock()
    )
df = run_pipeline(make_pipeline(), '2017-11-29','2017-11-30')
df.head()
import numpy as np
import pandas as pd<jupyter_output><empty_output><jupyter_text>验证<jupyter_code>todays = df.index.get_level_values(0)
days = (todays.tz_localize(None) - pd.to_datetime(df['time_to_market'].values)).days
assert all(days == df['上市天数'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11233480176211454, 'fraction_numerical': 0.018722466960352423, 'mean_word_length': 4.902597402597403, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '400036', 'license': 'Apache-2.0', 'n_tokens_mistral': 349, 'n_tokens_neox': 332, 'n_words': 54, 'path': 'docs/memo/pipeline/Factors/test_ndays.ipynb', 'repo_name': 'hebpmo/zipline', 'size': '908'}