CODING
TOURNAMENT
Level 3
]\
DATA-Driven Trading Strategy
Mandatory steps to follow:
1. By the end of next friday, each student should upload on Moodle a
python file with the requested functions;
2. Python filename MUST be "ID_NUMBER.py", for example, [Link]
3. In your Python file don't write any comment or text. Just your solutions
(functions) to the questions below;
4. Don’t write any print or input/inputs in your code. All the testing
examples will be given by the instructor script;
5. IMPORTANT: Whenever you want to use an external library in your
conde or functions, is mandatory to import them! (Example:)
Import pandas as pd
Import numpy as np
6. Only files following this criteria will be graded.
1st Option: How to Create a Python file (With Python IDE)
1. Create an empty file;
2. save it as "ID_NUMBER.py";
3. Write your code to answer exercise questions;
4. save it as "ID_NUMBER.py";
1
]\
2nd Option: How to Create a Python file (With Notepad or
similar)
1. Create an empty file;
2. save it as "ID_NUMBER.py";
3. Write your code to answer exercise questions;
4. save it as "ID_NUMBER.py";
3rd Option: How to Create a Python file (With Google
Colab)
1. Create a Google Colab Notebook;
2. Rename it to "ID_NUMBER.ipynb";
3. Write your code to answer exercise questions;
4. Go to FILE -> Download -> Download .py
Coding Example
Write a function to check if a number is negative.
FUNCTION NAME: negativeChecker
NUMBER OF INPUTS: 1
NUMBER OF OUTPUTS: 1 (True/False)
What should be in your python file:
def negativeChecker(my_input):
if my_input < 0:
return True
else:
return False
2
]\
Exercise 1
Write the function in Python, called “engine”, that you have used in the
Berkshire Hathaway case study. Basically, a function that reads 3 pandas
DataFrames, and returns a single DataFrame or [Link] with the daily
returns of your trading strategy.
FUNCTION NAME: engine
NUMBER OF INPUTS: 3 (DataFrames)
NUMBER OF OUTPUTS: 1 (DataFrame or [Link])
Exercise 2
Write a Python function to check if the input is a list of integers with exactly
two occurrences of nineteen and at least three occurrences of five.
FUNCTION NAME: listChecker
NUMBER OF INPUTS: 1 (list)
NUMBER OF OUTPUTS: 1 (True or False)
Exercise 3
Write a Python function that accepts an integer, and tests whether the input
integer is greater than 4^4 and if the mod 34 is equal to 4.
3
]\
FUNCTION NAME: powerModule
NUMBER OF INPUTS: 1 (integer)
NUMBER OF OUTPUTS: 1 (True or False)
Exercise 4
Write a Python function to find the longest string of a given list of strings.
FUNCTION NAME: maxLength
NUMBER OF INPUTS: 1 (list)
NUMBER OF OUTPUTS: 1 (string)
Exercise 5
Write a Python function to determine the direction ('increasing' or
'decreasing') of monotonic sequence numbers.
Example:
Input: [1, 2, 3, 4, 5, 6] -> Output: Increasing
Input: [6, 5, 4, 3, 2, 1] -> Output: Decreasing
Input: [19, 19, 5, 5, 5, 5, 5] -> Output: Not Monotonic
FUNCTION NAME: monotonic
NUMBER OF INPUTS: 1 (list)
NUMBER OF OUTPUTS: 1 (string: “Increasing”, “Decreasing” or “Not
Monotonic”)