Skip to content

Instantly share code, notes, and snippets.

@alphazwest
Created November 29, 2021 23:16
Show Gist options
  • Save alphazwest/34b5fab3e9356bc44ce625c2cf907a30 to your computer and use it in GitHub Desktop.
Save alphazwest/34b5fab3e9356bc44ce625c2cf907a30 to your computer and use it in GitHub Desktop.
# 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