☰
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
12.8K
All Categories
111
Node JS client
35
Go client
748
.Net API client
350
Kite Publisher
530
.Net / VBA / Excel (3rd party)
420
Algorithms and Strategies
940
Java client
979
API clients
392
PHP client
3.6K
Python client
325
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