コード例 #1
0
ファイル: smart_beta.py プロジェクト: zyx910/MLForTrading
def load_data():
    df = pd.read_csv('eod-quotemedia.csv')

    percent_top_dollar = 0.2
    high_volume_symbols = project_helper.large_dollar_volume_stocks(
        df, 'adj_close', 'adj_volume', percent_top_dollar)
    df = df[df['ticker'].isin(high_volume_symbols)]

    close = df.reset_index().pivot(index='date',
                                   columns='ticker',
                                   values='adj_close')
    volume = df.reset_index().pivot(index='date',
                                    columns='ticker',
                                    values='adj_volume')
    dividends = df.reset_index().pivot(index='date',
                                       columns='ticker',
                                       values='dividends')
    return close, volume, dividends
コード例 #2
0
import project_helper
import project_tests


# ## Market Data
# ### Load Data
# For this universe of stocks, we'll be selecting large dollar volume stocks. We're using this universe, since it is highly liquid.

# In[ ]:


df = pd.read_csv("../../data/project_3/eod-quotemedia.csv")

percent_top_dollar = 0.2
high_volume_symbols = project_helper.large_dollar_volume_stocks(
    df, "adj_close", "adj_volume", percent_top_dollar
)
df = df[df["ticker"].isin(high_volume_symbols)]

close = df.reset_index().pivot(index="date", columns="ticker", values="adj_close")
volume = df.reset_index().pivot(index="date", columns="ticker", values="adj_volume")
dividends = df.reset_index().pivot(index="date", columns="ticker", values="dividends")


# ### View Data
# To see what one of these 2-d matrices looks like, let's take a look at the closing prices matrix.

# In[ ]:


project_helper.print_dataframe(close)