Reddy786 commited on
Commit
3b97b2f
·
verified ·
1 Parent(s): f92ef57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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
- volume_profile = pd.DataFrame(index=bin_edges[:-1], columns=['Total Volume'])
36
- volume_profile['Total Volume'] = 0
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
- volume_profile.iloc[bin_indices[0]:bin_indices[1] + 1, volume_profile.columns.get_loc('Total Volume')] += row['Volume']
 
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