☰
Login
Signup
Home
›
Python client
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
13.2K
All Categories
0
Incidents
127
Node JS client
36
Go client
765
.Net API client
360
Kite Publisher
532
.Net / VBA / Excel (3rd party)
433
Algorithms and Strategies
964
Java client
1K
API clients
400
PHP client
3.8K
Python client
331
Mobile and Desktop apps
1.3K
Market data (WebSockets)
3.1K
General
In this Discussion
November 2020
ganeshv02
Formula to smoothen the stochastics study that is shown in the Kite HTML interface
RajeshSivadasan
November 2018
in
Python client
What is the formula to smooth the stochastics study that is shown in the Kite HTML interface? My calculation of %K is not matching with the values that are shown in the Kite interface. Any help highly appreciated.
Tagged:
python
kite
Stochastics
ganeshv02
November 2020
You can use below to pass a pandas dataframe and get back updated result.
def calculate_stochastics(df, period=14, smooth_k_period=3, d_period=3):
highest_high = df["high"].rolling(center=False, window=period).max()
lowest_low = df["low"].rolling(center=False, window=period).min()
df['%_k'] = pd.Series(round(((df["close"] - lowest_low) / (highest_high - lowest_low) * 100), 2))
df['k_line'] = round((df["%_k"].rolling(center=False, window=smooth_k_period).mean()), 2)
df['d_line'] = round((df["k_line"].rolling(center=False, window=d_period).mean()), 2)
return df
Sign In
or
Register
to comment.
def calculate_stochastics(df, period=14, smooth_k_period=3, d_period=3):
highest_high = df["high"].rolling(center=False, window=period).max()
lowest_low = df["low"].rolling(center=False, window=period).min()
df['%_k'] = pd.Series(round(((df["close"] - lowest_low) / (highest_high - lowest_low) * 100), 2))
df['k_line'] = round((df["%_k"].rolling(center=False, window=smooth_k_period).mean()), 2)
df['d_line'] = round((df["k_line"].rolling(center=False, window=d_period).mean()), 2)
return df