NexusFi: Find Your Edge


Home Menu

 





pandas df.diff() func


Discussion in Platforms and Indicators

Updated
    1. trending_up 401 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

pandas df.diff() func

  #1 (permalink)
StickRustler
Melbourne, FL
 
Posts: 18 since Jul 2020
Thanks Given: 4
Thanks Received: 2

Not elite, so can't post to the 'Python, Pandas...' forum.

I'm attempting to translate the DonovanWall Range Filter (AKA Vumanchu Swing Free) from Python into Java for MotiveWave.

Have no experience in pandas (some in Python).

Here's the func I'm working on

 
Code
def range_size(df: pd.DataFrame, range_period: float, range_multiplier: int):
    wper = range_period * 2 - 1
    # last candle is last index, not 0
    average_range = ta.ema(df.diff().abs(), range_period)
    AC = ta.ema(average_range, wper) * range_multiplier
    return AC
I'm assuming the df.diff() func is taking a data series, calculating diff between each bar and it's previous bar (bar-1), then returning a transformed data series with the results.

Am I correct in this assumption? If so, in MW I'll have to write loops to cycle thru MW's series and preform these diff calculations manually, then create a new series with the results.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Futures True Range Report
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
Battlestations: Show us your trading desks!
26 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
The Program
17 thanks
  #2 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


StickRustler View Post
Not elite, so can't post to the 'Python, Pandas...' forum.

I'm attempting to translate the DonovanWall Range Filter (AKA Vumanchu Swing Free) from Python into Java for MotiveWave.

Have no experience in pandas (some in Python).

Here's the func I'm working on

 
Code
def range_size(df: pd.DataFrame, range_period: float, range_multiplier: int):
    wper = range_period * 2 - 1
    # last candle is last index, not 0
    average_range = ta.ema(df.diff().abs(), range_period)
    AC = ta.ema(average_range, wper) * range_multiplier
    return AC
I'm assuming the df.diff() func is taking a data series, calculating diff between each bar and it's previous bar (bar-1), then returning a transformed data series with the results.

Am I correct in this assumption? If so, in MW I'll have to write loops to cycle thru MW's series and preform these diff calculations manually, then create a new series with the results.

Correct, it basically adds a new column in your dataframe.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
StickRustler
Melbourne, FL
 
Posts: 18 since Jul 2020
Thanks Given: 4
Thanks Received: 2



sam028 View Post
Correct, it basically adds a new column in your dataframe.

Thx

Reply With Quote




Last Updated on July 7, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts