API Assignment

docx

School

Cumberland University *

*We aren’t endorsed by this school

Course

3268

Subject

Computer Science

Date

Nov 24, 2024

Type

docx

Pages

5

Uploaded by ngararichrisgmail.com

Report
1 Loading Data from API Name Institutional Affiliation Date
2 Introduction I selected the Intraday Stock Market Data for the purpose of this assignment. I selected this API since it meets all the requirements specified on the assignment. For example, the variables in the API dataset are ideal in enabling one to determine their differences in different requests. The table below provides an illustration of the dataset by indicating the variables in each column. Timestamp provides details such as the time and date the variables were added to the dataset Open – this variable provides information on the value of the stock. High – this variable provides details on the highest value of the stock. High – this variable provides details on the lowest value of the stock. Close – this variable indicates the price of the stock after the five minutes time frame. It is crucial the dataset has other variables such as the number of stocks traded. However, I focused on the variables above determining their differences between two requests. The following are some of the steps I followed to obtain the results below. Steps used in the Loading the Data I selected this API since it contained variables that change regularly. This API meet all the instructions and requirements in the assignment module since it has variables that change regularly, meaning it could be relatively easy to determine the differences between two downloads. The Alpha Vantage API provides up-to-date market data and stock market
3 information. However, it required one to signing in the website to acquire the authorization key. Once I acquired the authorization key, I was ready to request and retrieve the data from the API. I used PyCharm Community Edition IDE to create and run the python program that would enable me to extract the data from the API. I copied the API URL into the editor as shown below. The image also shows the use of the requests library to query the URL. It is crucial that the requested data would not have the desired format. The code below shows how the program formats the data into a CSV file. Some of the desired columns include time stamp, open, high low and close variables. The generated CSV file will have the five columns. The image below shows the code used to achieve this objective. The code above extracts the relevant variables and stores them in the variable r. the process is repeated two times, with one of the downloads being the updated dataset from the API. The panda’s library was crucial in enabling me to convert the dataset into the.csv format with all
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
4 the variables and the calculated differences. The screenshot below shows the code used to generate the time-series data and format it in the csv file.
5 References Alpha Vantage. (2023). API documentation . Free Stock APIs in JSON & Excel | Alpha Vantage. https://www.alphavantage.co/documentation/