Created
November 29, 2021 23:16
-
-
Save alphazwest/34b5fab3e9356bc44ce625c2cf907a30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create list for Daily Range values | |
daily_ranges = [] | |
# Get High - Low (DR) for each period | |
for price in prices: | |
# Calculate DR | |
pct_daily_range = price["low"] / price["high"] | |
# Normalize | |
daily_ranges.append(100 * (pct_daily_range - 1)) | |
# Calculate Average Daily Range | |
average_daily_range = sum(daily_ranges) / len(daily_ranges) | |
# View output | |
print(average_daily_range) | |
>>> 3.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment