☰
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
14.4K
All Categories
0
Incidents
167
Node JS client
47
Go client
815
.Net API client
393
Kite Publisher
539
.Net / VBA / Excel (3rd party)
474
Algorithms and Strategies
1K
Java client
1.1K
API clients
408
PHP client
4.1K
Python client
355
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.5K
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