The instruction of running the project: How to run the project
This Code Assessment simulates the scenario of building an index model based on a given guideline. The rules provided below describe a simple stock index and for this assessment the objective is to build a model that can calculate such index values.
The idea is not only that you can show us what you've got, but also that you can get a first impression of what it means to build an index model.
The required input prices can be found at data_sources\stock_prices.csv.
You can also find the correct (rounded) index level at data_sources\index_level_results_rounded.csv.
Please note these values cannot be used as an input but solely act as a reference for you to verify
your model. For the evaluation of your model we will use the high precision index values your model
calculates.
- The index is a stock index made up of imaginary stocks.
- There are no further corporate actions to consider here
- The index doesn't resemble any real existing index.
- The model should be able to calculate the index levels based on the rules below.
- All provided prices are total return.
- All companies got the same amount of shares outstanding.
- The index is a total return index.
- The index universe consists of all stocks from "Stock_A" to including "Stock_J".
- Every first business day of a month the index selects from the universe the top three stocks based on their market capitalization, based on the close of business values as of the last business day of the immediately preceding month.
- The selected stock with the highest market capitalization gets assigned a 50% weight, while the second and third each get assigned 25%.
- The selection becomes effective close of business on the first business date of each month.
- The index starts with a level of 100.
- The index start date is January 1st 2020.
- The index business days are Monday to Friday.
- There are no additional holidays.
We've already provided a __main__.py for this project and there should be no need for you to modify it.
As you will see the main file expects an index model which can be found at index_model/index.py.
This is the model we expect you to build. It should then ultimately be able to export the
calculated values to a csv file.
If you want to use additional packages feel free to do so. The actual business logic must be part of your repo, but we actively encourage you to use packages that you're already familiar with. Please make sure to update the requirements.txt file accordingly.
Run the following commands from the repository root.
Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade pipmacOS/Linux:
python3 -m venv .venv
./.venv/bin/python -m pip install --upgrade pipWindows PowerShell:
.\.venv\Scripts\python.exe -m pip install -r requirements.txtmacOS/Linux:
./.venv/bin/python -m pip install -r requirements.txtWindows PowerShell:
.\.venv\Scripts\python.exe __main__.pymacOS/Linux:
./.venv/bin/python __main__.pyThe model reads prices from data_sources/stock_prices.csv and exports the
calculated index levels to:
exported_data/export.csv
The rounded reference values in
data_sources/index_level_results_rounded.csv can be used to verify the
calculated output, but must not be used as model input.
- Parameter of the model are stored as variables at the beginning of
index_model/index.py. Modify it when introducing new index rules. - The input parameter
start_dateofIndexModel.calc_index_levelin the code is treated as the Start Date of the index as I assume the model is used for backtest based on the variable names in the pre-written__main__.py. In current__main__.py, the start date is January 1st 2020. Therefore, if a customstart_dateis being used, it needs to be the first business day of a month.