Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
143 views

AlgoBulls - Python Developer - Strategy - Coding Assignment 1

This document outlines a coding assignment to design a simple algorithmic trading strategy. The requirements include: 1. Creating a ScriptData class to fetch and format intraday stock data from Alpha Vantage. 2. Defining an indicator1 function to calculate a moving average technical indicator. 3. Building a Strategy class to generate buy/sell signals by comparing the close price and moving average values and output these signals to a DataFrame. 4. Optionally plotting the price and indicator data. The assignment should be completed within 3 days by submitting a Jupyter notebook, requirements file, and documentation to a GitHub repo for review.

Uploaded by

Palak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views

AlgoBulls - Python Developer - Strategy - Coding Assignment 1

This document outlines a coding assignment to design a simple algorithmic trading strategy. The requirements include: 1. Creating a ScriptData class to fetch and format intraday stock data from Alpha Vantage. 2. Defining an indicator1 function to calculate a moving average technical indicator. 3. Building a Strategy class to generate buy/sell signals by comparing the close price and moving average values and output these signals to a DataFrame. 4. Optionally plotting the price and indicator data. The assignment should be completed within 3 days by submitting a Jupyter notebook, requirements file, and documentation to a GitHub repo for review.

Uploaded by

Palak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

AlgoBulls Python Developer

Coding Assignment
December 2022

Project: Design a simple Algorithmic Trading Strategy

Description: You need to code a simple trading strategy in a Jupyter Notebook as per the
given requirements:

1. Define a Class ScriptData which can fetch US Stock data using Alpha Vantage.
[Use this link to get your FREE API Key].
The class should implement the following methods:
a. fetch_intraday_data: (method arguments: script)
Fetches intraday data for given “script” (Example for script: “GOOGL”,
“AAPL”) and stores as it is.
b. convert_intraday_data: (method arguments: script)
Converts fetched intraday data (in point a.) as a pandas DataFrame
(hereafter referred as “df”) with the following columns:
i. timestamp (data type: pandas.Timestamp)
ii. open (data type: float)
iii. high (data type: float)
iv. low(data type: float)
v. close (data type: float)
vi. volume (data type: int)
c. Additional methods for overloading the following operations:
i. getitem
ii. setitem
iii. contains

Sample code showing how the above class will be used:


(The output data may differ for you based on which date you run this code, but the format should be the same)

(The output data may differ for you based on which date you run this code, but the format should be the same)
2. Define a function called indicator1. It should take “df” and ‘timeperiod’ (integer) as
inputs and give another pandas DataFrame as an output with two columns:
a. timestamp: Same as ‘timestamp’ column in ‘df’
b. indicator: Moving Average of the ‘close’ column in ‘df’. The number of
elements to be taken for a moving average is defined by ‘timeperiod’. For
example, if ‘timeperiod’ is 5, then each row in this column will be an average
of total 5 previous values (including current value) of the ‘close’ column.

Some sample code has been given below which shows how the above function will be used:
3. Define a class Strategy, which can do the following, given a script name:
a. Fetch intraday historical day (‘df’) using ScriptData class.
We’ll refer to the ‘close’ column of ‘df’ as close_data.
b. Compute indicator data on ‘close’ of ‘df’ using indicator1 function.
We’ll refer to the ‘indicator’ column of this data as indicator_data.
c. Generate a pandas DataFrame called ‘signals’ with 2 columns:
i. ‘timestamp’: Same as ‘timestamp’ column in ‘df’
ii. ‘signal’: This column can have the following values:
1. BUY (When: If indicator_data cuts close_data upwards)
2. SELL (When: If indicator_data cuts close_data downwards)
3. NO_SIGNAL (When: If indicator_data and close_data don’t cut
each other)

Example of ‘Cut Upwards’, ‘Cut Downwards’, ‘Do not cut each


other’:
As an example, for the below graph, if the RED line is
close_data and GREY line is indicator_data, then:
1. The BLUE points represent the instances when
indicator_data has cut close_data ‘downwards’
2. The PINK points represent the instances when
indicator_data has cut close_data ‘upwards
3. The YELLOW points represent when indicator_data
and close_data don’t cut each other.
So, there will be SELL signal for BLUE timestamps, ‘BUY’
signal for PINK timestamp and ‘NO_SIGNAL’ for yellow
timestamps.
d. Print the ‘signals’ DataFrame with only those rows where the signal is either
‘BUY’ or ‘SELL’.

Sample code showing how the above class will be used:


4. [OPTIONAL] Plot a candlestick chart of ‘df and ‘indicator’. You can use
‘pyalgotrading’ to do so. The chart will look like this.

Technology to be used for creating this application:

1. Python 3.8+
2. Jupyter Notebook (latest)
3. 3rd party Python modules:
a. alpha_vantage
b. pandas
c. numpy
d. [OPTIONAL] pyalgotrading

Objective:
1. Please come up with a git repo containing a Jupyter Notebook that can
accommodate all the requirements.
2. The Jupyter Notebook should run seamlessly. Just calling the Kernel -> Restart &
Run All option to do all that is necessary. There should be no errors and no
unnecessary code in the notebook.
3. The dependent Python packages must be captured in a requirements.txt file which
can be installed inside a virtualenv easily. The Jupyter Notebook should also be run
after sourcing the virtualenv.

Duration:
The ideal time is 3 days. If you need extra time, please request the same with appropriate
reasoning.

How to submit:
1. Please upload your code on a private GitHub repo and share it with our GitHub
user-id - algobulls-dev, hruturaj-nikam-algobulls. Include the Postman Collection
as well in the repo.
2. Make sure your code is cleaned up as per PEP8 standards, before you do the final
submission. It is ok to keep pushing any number of intermediate code commits.
3. Add sufficient comments for complex logic, before you do the final submission.
4. Include a README that includes basic documentation on how to run the code.
5. Once done, please send a mail to developers@algobulls.com &
hruturaj.nikam@algobulls.com, mentioning your name and GitHub ID, requesting a
review. Attach this coding assignment pdf to the mail as well. We may request you to
set up a screen sharing session for discussion purposes.

Asking for clarification/hints:


Please send an email to developers@algobulls.com & hruturaj.nikam@algobulls.com with
your query and we will get back to you.

You might also like