示例#1
0
def create_symbol_lists():
    sp500 = sym.get_sp500_symbols()
    nyse = sym.get_nyse_symbols()
    amex = sym.get_amex_symbols()
    nasdaq = sym.get_nasdaq_symbols()

    Df_sp500 = pd.DataFrame(sp500)
    #    Df_nyse = pd.DataFrame(nyse)
    #    Df_amex = pd.DataFrame(amex)
    #    Df_nasdaq = pd.DataFrame(nasdaq)

    start = ""
    with open('/root/jTWSdump_707/requests/base.txt', 'r') as f:
        start = f.read()


#	start += "\n"
    f.close()
    s_sp500 = ""
    for symbol in Df_sp500.symbol:
        if "^" in symbol or "." in symbol:
            continue
        #s_sp500 += '"'+symbol.strip()+'" "STK" "SMART" "" "" "" "USD" "" "10 D" "1 min" "1" "TRADES" "10" ""'+'\n'
        s_sp500 += '"' + symbol.strip(
        ) + '" "STK" "SMART" "" "" "" "USD" "" "5 Y" "1 day" "1" "TRADES" "1" ""' + '\n'

    s_nyse = ""
    #    for symbol in Df_nyse.symbol:
    #        if "^" in symbol or "." in symbol:
    #            continue
    #       # s_nyse += '"'+symbol.strip()+'" "STK" "SMART/NYSE" "" "" "" "USD" "" "10 D" "1 min" "1" "TRADES" "10" ""'+'\n'
    #        s_nyse += '"'+symbol.strip()+'" "STK" "SMART/NYSE" "" "" "" "USD" "" "5 Y" "1 day" "1" "TRADES" "1" ""'+'\n'
    #
    s_amex = ""
    #    for symbol in Df_amex.symbol:
    #        if "^" in symbol or "." in symbol:
    #            continue
    #        #s_amex += '"'+symbol.strip()+'" "STK" "SMART" "" "" "" "USD" "" "10 D" "1 min" "1" "TRADES" "10" ""'+'\n'
    #        s_amex += '"'+symbol.strip()+'" "STK" "SMART" "" "" "" "USD" "" "5 Y" "1 day" "1" "TRADES" "1" ""'+'\n'
    #
    s_nasdaq = ""
    #
    #    for symbol in Df_nasdaq.symbol:
    #        if "^" in symbol or "." in symbol:
    #            continue
    #        #s_nasdaq += '"'+symbol.strip()+'" "STK" "SMART/NASDAQ" "" "" "" "USD" "" "10 D" "1 min" "1" "TRADES" "10" ""'+'\n'
    #        s_nasdaq += '"'+symbol.strip()+'" "STK" "SMART/NASDAQ" "" "" "" "USD" "" "5 Y" "1 day" "1" "TRADES" "1" ""'+'\n'

    with open('/root/jTWSdump_707/requests/zipline.txt', 'w+') as f:
        f.write(start)
        f.write(s_sp500)
        f.write(s_nyse)
        f.write(s_amex)
        f.write(s_nasdaq)

        f.close()
示例#2
0
    def getSymbols(self):
        idxs = self.cfg["general"]["idxs"].split(",")
        symbols_list = []
        sectors_map = {}

        if "sp500" in idxs:
            symbols_list += symbols.get_sp500_symbols()
        if "nyse" in idxs:
            symbols_list += symbols.get_nyse_symbols()
        if "nasdaq" in idxs:
            symbols_list += symbols.get_nasdaq_symbols()
        if "amex" in idxs:
            symbols_list += symbols.get_amex_symbols()

        for s in symbols_list:
            sectors_map[s["symbol"]] = s["sector"]

        with open(self.pwd + "cfg/tickers.json", "w") as f:
            json.dump(sectors_map, f)
# %% [markdown]
# # Load Financial Symbols

# %%
get_ipython().system('pip install finsymbols')

# %%
from finsymbols import symbols
import json
import pprint

#symbol_list = symbols.get_sp500_symbols()
#symbol_list.extend(symbols.get_amex_symbols())
#symbol_list.extend(symbols.get_nyse_symbols())
#symbol_list.extend(symbols.get_nasdaq_symbols())
symbol_list = symbols.get_nasdaq_symbols()

column_names = ['company', 'headquarters', 'industry', 'sector', 'symbol']
df = pd.DataFrame(symbol_list, columns=column_names)
my_symbols = df['symbol'].replace("\n", "", regex=True)

# %% [markdown]
# # Loops
# %% [markdown]
# ## Create expert Recordings

# %%
# Download List of NASDAQ Insturment
df = pd.read_csv('nasdaq_list.csv')
#df = df.iloc[17:]
df.head()
示例#4
0
 def test_nasdaq_not_null(self):
     nasdaq = symbols.get_nasdaq_symbols()
     assert len(nasdaq) != 0, 'NASDAQ list is of size 0'
示例#5
0
 def test_nasdaq_not_null(self):
     nasdaq = symbols.get_nasdaq_symbols()
     assert len(nasdaq) != 0, 'NASDAQ list is of size 0'
from pandas_datareader import data
from finsymbols import symbols

r"""
This script is used for downloading raw data of various stocks over the last ~15 years.
"""

all_stocks = symbols.get_nyse_symbols() + symbols.get_nasdaq_symbols()

for stock in all_stocks:
    try:
        symbol = stock['symbol']
        historical_data = data.DataReader(symbol, 'Google', '2002-08-01', '2017-08-01')
        if len(historical_data) > 252:
            historical_data.to_csv('Raw_Stock_Data/' + symbol + '_data')
    except:
        pass