# RoboAdvisor oTree Experiment An oTree-based experimental platform for studying human decision-making in investment scenarios with robo-advisor assistance. ## Features - **Lottery Task**: Participants allocate tokens between risky and safe options - **Investment Game**: 30 rounds of investment decisions with real-time feedback - **Robo-Advisor Treatments**: Different levels of automated financial advice - **Questionnaires**: Demographics, financial literacy, and trust measures - **Responsive Design**: Auto-scaling interface that works on different screen sizes - **Bilingual Support**: English and French language options ## Prerequisites - **Python**: 3.9 or higher - **pip**: Python package installer (usually comes with Python) - **Git**: For version control (optional but recommended) ## Installation ### For Windows 1. **Clone the repository** ```bash git clone https://github.com/navid-nb/RoboAdvisor_OTree.git cd RoboAdvisor_OTree ``` 2. **Create a virtual environment** ```bash python -m venv otree_env ``` 3. **Activate the virtual environment** ```bash otree_env\Scripts\activate ``` 4. **Install dependencies** ```bash pip install -r requirements.txt ``` ### For Mac/Linux 1. **Clone the repository** ```bash git clone https://github.com/navid-nb/RoboAdvisor_OTree.git cd RoboAdvisor_OTree ``` 2. **Create a virtual environment** ```bash python3 -m venv otree_env ``` 3. **Activate the virtual environment** ```bash source otree_env/bin/activate ``` 4. **Install dependencies** ```bash pip install -r requirements.txt ``` ## Running the Application ### Start the Development Server **Windows:** ```bash otree_env\Scripts\activate otree devserver ``` **Mac/Linux:** ```bash source otree_env/bin/activate otree devserver ``` The server will start on `http://localhost:8000/` Open your web browser and navigate to: - **Demo Mode**: `http://localhost:8000/demo` - **Session Creation**: `http://localhost:8000/sessions` ### Running in Production For production deployment: ```bash otree prodserver 80 ``` ## Database Management ### Reset the Database To clear all participant data and start fresh: **Windows:** ```bash del db.sqlite3 otree resetdb ``` **Mac/Linux:** ```bash rm db.sqlite3 otree resetdb ``` When prompted, type `yes` to confirm. ### Create Initial Database If running for the first time or after reset: ```bash otree resetdb ``` ## Project Structure ``` RoboAdvisor_OTree/ ├── _static/ # Static files (CSS, JavaScript) │ └── global/ │ ├── footer-layout.css # Main layout and footer styles │ ├── mgslider.js # Custom slider component │ └── basic_slider.css # Slider styling ├── _templates/ # Global templates │ └── global/ │ ├── Page.html # Base page template with footer │ └── (no modal templates) ├── instructions/ # Instructions pages ├── lottery_example/ # Practice lottery task ├── lottery_real/ # Real lottery task ├── investment_decisions_example/ # Practice investment rounds ├── investment_decisions_real/ # Real investment rounds ├── questionnaire/ # Post-experiment questionnaires ├── settings.py # oTree settings and configuration ├── requirements.txt # Python dependencies └── db.sqlite3 # SQLite database (created on first run) ``` ## Experiment Flow 1. **Language Selection**: Participants choose English or French 2. **Instructions**: Detailed explanation of tasks 3. **Lottery Example**: Practice lottery decision 4. **Lottery Real**: Real lottery decision (affects payoff) 5. **Investment Example**: Practice investment round 6. **Investment Rounds**: 30 rounds of investment decisions 7. **Questionnaires**: Demographics, financial literacy, trust measures 8. **Payoff Display**: Final payment calculation ## Key Features ### Fixed Footer Design - Instructions button on the left - Error messages in the center (red text) - Next/Submit button on the right - Always visible at the bottom of the screen ### Auto-Scaling Content - Content automatically scales to fit different screen sizes - No scrolling on investment/lottery pages - Scrollable content for instructions and questionnaires - Responsive design works on screens from 12" to 27" ### Treatments 1. **Control**: No advice 2. **Allocation Only**: Recommended investment allocation 3. **Forecast Only**: Predicted return forecast 4. **Both**: Allocation + Forecast 5. **Autonomous**: Fully automated decision-making ## Configuration ### Modify Experiment Settings Edit `settings.py` to change: - Number of rounds - Endowment amounts - Treatment conditions - Language settings - Payment parameters Example: ```python SESSION_CONFIGS = [ dict( name='robo_advisor', display_name='RoboAdvisor Experiment', num_demo_participants=1, app_sequence=['instructions', 'lottery_example', ...], # Add custom parameters here ), ] ``` ## Troubleshooting ### Virtual Environment Issues If you can't activate the virtual environment: - **Windows**: Ensure PowerShell execution policy allows scripts: ```bash Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser ``` - **Mac/Linux**: Ensure the activate script has execute permissions: ```bash chmod +x otree_env/bin/activate ``` ### Port Already in Use If port 8000 is already in use: ```bash otree devserver 8001 ``` ### Database Locked Error If you get a database locked error: 1. Close all browser tabs with the experiment 2. Stop the oTree server (Ctrl+C) 3. Restart the server ### Missing Dependencies If you get import errors: ```bash pip install --upgrade -r requirements.txt ``` ## Development ### Adding New Pages 1. Create a new app folder with `__init__.py` 2. Add templates in `templates/app_name/` 3. Update `settings.py` to include the app in `SESSION_CONFIGS` ### Modifying Styles Edit `_static/global/footer-layout.css` for: - Layout changes - Footer styling - Responsive behavior - Scrolling preferences ## Data Collection Participant data is stored in `db.sqlite3`. To export data: ```bash otree export ``` This creates CSV files in the current directory. ## Support For issues or questions: 1. Check the [oTree documentation](https://otree.readthedocs.io/) 2. Review the troubleshooting section above 3. Open an issue on GitHub ## License This project is intended for academic research purposes. ## Acknowledgments Built with [oTree](https://www.otree.org/) - a framework for behavioral experiments.