Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -30,16 +30,17 @@ def calculate_volume_profile(data, row_layout):
|
|
30 |
price_max = data['High'].max()
|
31 |
|
32 |
bins = row_layout
|
33 |
-
bin_edges = np.linspace(price_min, price_max, bins)
|
34 |
|
35 |
-
|
36 |
-
volume_profile['Total Volume']
|
37 |
|
38 |
for index, row in data.iterrows():
|
39 |
bin_indices = np.digitize([row['Low'], row['High']], bin_edges) - 1
|
40 |
bin_indices = [max(0, min(bins-2, b)) for b in bin_indices]
|
41 |
|
42 |
-
|
|
|
43 |
|
44 |
return volume_profile
|
45 |
|
|
|
30 |
price_max = data['High'].max()
|
31 |
|
32 |
bins = row_layout
|
33 |
+
bin_edges = np.linspace(price_min, price_max, bins).flatten()
|
34 |
|
35 |
+
# Create a DataFrame for volume profile
|
36 |
+
volume_profile = pd.DataFrame(0, index=bin_edges[:-1], columns=['Total Volume'])
|
37 |
|
38 |
for index, row in data.iterrows():
|
39 |
bin_indices = np.digitize([row['Low'], row['High']], bin_edges) - 1
|
40 |
bin_indices = [max(0, min(bins-2, b)) for b in bin_indices]
|
41 |
|
42 |
+
# Update the volume for the respective bin ranges
|
43 |
+
volume_profile.iloc[bin_indices[0]:bin_indices[1] + 1, 0] += row['Volume']
|
44 |
|
45 |
return volume_profile
|
46 |
|