To run the experiments and generate all Tables and Figures in the paper, follow these setup instructions based on your operating system:
- Set Up Stata Path: Ensure your local Stata path is correctly set up in
conf/config.yaml
. For Windows, it should look like this (uncomment this line and comment out the Mac path):# Stata path for windows stata_path: "C:/Program Files/Stata17/StataMP-64.exe"
- Run the Experiment: Use the executable file
run_experiment.bat
to execute all code in order. This script generates all Tables and Figures.
- Set Up Stata Path: Update your local Stata path in
conf/config.yaml
. For macOS, uncomment the relevant line and comment out the Windows path. Adjust the path based on your Stata version (e.g., StataSE, StataMP):# Stata path for mac # You may need to change from StataSE to StataMP depending on your version stata_path: "/Applications/Stata/StataSE.app/Contents/MacOS/StataSE"
- Make the Script Executable (if needed): Before running the script for the first time, make it executable by running:
chmod +x ./run_experiment.sh
- Run the Experiment: Execute the script
run_experiment.sh
using:This script will execute all code in order and generate all Tables and Figures../run_experiment.sh
Note: Ensure that the paths specified in config.yaml
correctly match the location of your Stata installation.
- All required raw data is in the
raw_data_dump
folder. You can safely empty the following folders before running the code:data_processed
,data_prolific
,figures
, andtables
.
code/select_sample.py
: Takes the raw Heroku data (which includes all development tests) in theraw_data_dump
folder and selects the relevant experimental sessions.- Run with parameter
0
to extract data for main sample and with parameter1
for the University of Toronto sample used in Online Appendix G. - Running the code with parameter
0
populates 3 data files in thedata_prolific
folder:pretrade_data.csv
,trader_actions.csv
, andtrader_metadata.csv
. - Running the code with parameter
1
populates 3 other data files in thedata_prolific
folder:pretrade_data_uoft.csv
,trader_actions_uoft.csv
, andtrader_metadata_uoft.csv
. - Saves Figure 4 in the main paper as
figures/main_figure_4.png
. - Saves Table 2 in the main paper as
tables/main_table_2.tex
.
- Run with parameter
code/figure_price_path
: Renders Figure 3 with a sample price path and saves it asfigures/main_figure_3.png
.code/optimal_trades_theory.py
: Uses the price paths inprice_paths
folder to compute the optimal strategy of a Bayesian trader in any given round. Saves two files:data_prolific/optimal_trade_flags.csv
, for price paths featuring momentum in Sessions I-IIIdata_prolific/markov_trade_flags.csv
, for martingale price paths in Session IV.
code/self_reflection.py
: Uses post-experimental data to encode preference dummies.- Run with parameter
0
for main sample, saves panel as/data_processed/self_reflection.csv
- Run with parameter
1
for University of Toronto sample, saves panel as/data_processed/self_reflection_uoft.csv
.
- Run with parameter
code/build_main_panels.py
takes the raw data from fromdata_prolific
and generates three panels for regression analysis:data_processed/panel_trader_round.csv
: a panel with participant-round observation (aggregate measures)data_processed/panel_tick_data.csv
: a panel with tick-by-tick actions of participants (including idle ticks)data_processed/panel_trades.csv
: a panel with all participant trades.code/generate_figures.py
: Generate figures in the main paper. Run with parameter0
for main experiment and parameter1
for University of Toronto data. List of figures, all saved infigures
subfolder:- Figures 5 and G1: Preferences for gamification and financial literacy
- Figures 6 and G2: Trading activity and preferences for gamification
- Figures 7 and G3: and Distribution of $\pi_t$ by trading activity
- Figure 8: Tick-by-tick trading decisions and notifications
- Figures 9 and G4: Trading decision on notification ticks
code/jackknife_financialquiz.py
: Builds a jack-knife samples measure of financial quiz score (dropping questions one by one):- Saves resulting panel of quiz scores as
data_processed/jackknife_finquiz.csv
. - Saves Figure H.1 in the
figures
subfolder.
- Saves resulting panel of quiz scores as
regressions/execute_stata.py
:- Run with argument
regression_trader_round.do
to generate trader-round tables intables
folder: Tables 4, 5, and 7 in the main paper; Tables F1, F2, F3, F4, F5, F6 in the Online Appendix. - Run with argument
regression_trader_panel.do
to generate trader panel tables: Table 3 in the main paper and Table H1 in the Online Appendix. - Run with argument
regression_tick_data.do
to generate tick-level panel tables: Table 6 in the main paper and Table F7 in the Online Appendix. - Run with argument
regression_robustness_H2_H6.do
to generate robustness Tables H2 through H6 in the Online Appendix. - Run with argument
regression_quiz_jackknife.do
to generate Table H.7 with jack-knife measure of the financial quiz score.
- Run with argument