nitishkarvekar commited on
Commit
733b93b
·
verified ·
1 Parent(s): ca70a5c

Create volume_profile_agent.py

Browse files
Files changed (1) hide show
  1. volume_profile_agent.py +20 -0
volume_profile_agent.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ def volume_profile_signal(df):
4
+
5
+ prices = df["Close"].values
6
+ volume = df["Volume"].values
7
+
8
+ bins = np.linspace(prices.min(), prices.max(), 20)
9
+
10
+ hist, edges = np.histogram(prices, bins=bins, weights=volume)
11
+
12
+ poc_index = np.argmax(hist)
13
+ poc_price = (edges[poc_index] + edges[poc_index+1]) / 2
14
+
15
+ current_price = prices[-1]
16
+
17
+ if current_price > poc_price:
18
+ return 1
19
+ else:
20
+ return -1