Colorado State University Logo | CS 150B - Culture and Coding: Python (AUCC 3B/GT-AH3) Colorado State University Logo | CS 150B - Culture and Coding: Python (AUCC 3B/GT-AH3)
CS 150B - Culture and Coding: Python (AUCC 3B/GT-AH3)
Computer Science

Lab 10 - BTC Price Analysis Lab

Introduction

For this lab, you are going to work with exchange data for the cryptocurrency bitcoin. You will extract meaningful and interesting information from this data using various skills you have learned.

Step 0 - Read the code

Before you attempt to write any of the required functions, take some time to read through the main function. Try to figure out what each of the functions takes as input, is doing, and what it returns.

Step 1 - Write read()

The goal of this function to return a list of lists, where each line is data from a Bitcoin exchange on a given day. The file you will be working with looks like this:

Unix Timestamp,Date,Symbol,Open,High,Low,Close,Volume
1615176000000,2021-03-08,BTCUSD,50591.21,52596.05,49300.01,52095.96,1498.707276435

Sample return value:

[['Unix Timestamp', 'Date', 'Symbol', 'Open', 'High', 'Low', 'Close', 'Volume'], 
 ['1615176000000', '2021-03-08', 'BTCUSD', '50591.21', '52596.05', '49300.01', '52095.96', '1498.707276435'], 
 ['1615089600000', '2021-03-07', 'BTCUSD', '49610.32', '51832.15', '49135.73', '50591.21', '1157.0422112639'],
 ...
]

Step 2 - Write all_time_high()

This function takes the data that we read in from the csv file and finds the line that has the maximum closing price. Both the date of that day and the price are returned.

The date needs to be the first value returned and the price second.

Step 3 - Write all_time_low()

This function works very similarly to the previous one. However, now you are looking for the day with the lowest closing price. Again, the date and the price are returned.

Step 4 - Write percent_change()

This function takes the data, a start date, and an end date as input. It should find the open price on the start date and the close price on the end date. Then you should calculate the percent change using the following equation:

percent change = ((end close price - start open price) / start open price) * 100

Return the percent change that you calculated.

Step 5 - Write largest_intraday_percentage_change() (CHALLENGE - Not graded)

The goal of this function is to find the day that bitcoin had the most growth or loss. To do this, you will need to calculate the percent change for each day and find the largest absolute change (-25% would be a larger change than 20%).

Return the date of the largest change and the percent that the price changed.

Testing

Each time you complete one of these functions, you should test them individually in the run_tests() function. Give an input that you know the output for and make sure that is what you are actually getting. Waiting until you completed every to test will make finding where you went wrong very difficult.

Turning in

Make sure to turn when you are done (did you remember to click through canvas again to update the connection?)

Computer Science Department

279 Computer Science Building
1100 Centre Avenue
Fort Collins, CO 80523
Phone: (970) 491-5792
Fax: (970) 491-2466

CS 150B - Culture and Coding: Python (AUCC 3B/GT-AH3)

Survey of computer science, formal logic, and computational thinking. Explores the historical, gender, and cultural perspectives on the role of technology in society. Includes learning a basic programming language. Students will be expected to write small programs, and construct written arguments on ways in which technology influences our modern culture. Previous computer science experience not necessary.