<jupyter_start><jupyter_text>Disclaimer  Define a universeQuantRocket relies heavily on the concept of universes, which are user-defined groupings of securities. Universes provide a convenient way to refer to and manipulate groups of securities when collecting historical data, running a trading strategy, etc. You can create universes based on exchanges, security types, sectors, liquidity, or any criteria you like. A universe could consist of one or two securities or thousands of securities.  Query securitiesTo create our first universe, we will query securities from the securities master database, optionally pare them down to a subset of securities, then upload the pared down securities to create our universe. Learn more about universes in the [usage guide](https:www.quantrocket.com/docs/master).Security listings for our sample stocks were automatically collected during historical data collection. We query the stock listings from the securities master database using the `get_securities` function, which loads them into a pandas DataFrame:<jupyter_code>from quantrocket.master import get_securities
# by specifying sec_types='STK', we exclude ETFs, which are present in the sample data 
securities = get_securities(vendors="usstock", sec_types="STK")
securities.head()<jupyter_output><empty_output><jupyter_text>Note the `Sid` index in the DataFrame: Sid is short for "security ID" and is the unique identifier for a particular security or contract. Sids are used throughout QuantRocket to refer to securities.  Create universeTo create a universe consisting of these securities, we simply upload the list of sids to the `create_universe` function. We'll name the universe "usstock-free":<jupyter_code>from quantrocket.master import create_universe
create_universe("usstock-free", sids=securities.index.tolist())<jupyter_output><empty_output><jupyter_text>The function output confirms the name and size of our new universe.  Filter securitiesAs a demonstration, we could also pare down the securities to create a universe from a subset of securities. For example, we might limit the universe to currently listed securities:<jupyter_code>filtered_securities = securities[securities.Delisted==False]
# also limit the number of columns for readability
filtered_securities = filtered_securities[["Symbol", "Exchange", "Name", "Delisted"]]
filtered_securities.head()<jupyter_output><empty_output><jupyter_text>Then we can create a universe from the filtered securities.<jupyter_code>create_universe("usstock-free-active", sids=filtered_securities.index.tolist())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.060361399461745485, 'fraction_numerical': 0.0, 'mean_word_length': 6.813813813813814, 'pattern_counts': {'":': 1, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '180612', 'license': 'Apache-2.0', 'n_tokens_mistral': 692, 'n_tokens_neox': 641, 'n_words': 292, 'path': 'intro_moonshot/Part2-Universe-Selection.ipynb', 'repo_name': 'quantrocket-codeload/moonshot-intro', 'size': '2601'}