☰
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.9K
All Categories
0
Incidents
156
Node JS client
40
Go client
793
.Net API client
380
Kite Publisher
537
.Net / VBA / Excel (3rd party)
458
Algorithms and Strategies
998
Java client
1.1K
API clients
404
PHP client
4K
Python client
347
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.3K
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