0

I am setting up a volume profile series over a stock data. I have implemented the market profile code from this github repo!

Here the author gets his final results by applying this code:

mp = MarketProfile(df, tick_size=1)
mp_slice = mp[df.index.max() - pd.Timedelta(13, 'H'):df.index.max()]

Here the function takes a slice of indexes from the whole dataframe and apply its function that slice and the author get his results through this code:

    mp_slice.initial_balance()
    mp_slice.open_range()
    mp_slice.poc_price
    mp_slice.profile_range
    mp_slice.value_area
    mp_slice.balanced_target

What I want is to make rolling(w) columns of results in the data frame from the starting date. i.e df['poc_price'], df['value_area']

I have tried the df.rolling() and .apply() method which throws me errors.

Ian Thompson
  • 2,914
  • 2
  • 18
  • 31
Scrappy Coco
  • 96
  • 3
  • 13
  • Please provide sample starting data, expected output, and your current *functioning* code that would consume said start data – Ian Thompson Oct 04 '19 at 13:53
  • Download the csv data file from this link : "https://github.com/bfolkens/py-market-profile/blob/master/tests/fixtures/google.csv" – Scrappy Coco Oct 08 '19 at 13:07
  • Please see [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) and [How to make good reproducible pandas examples](https://stackoverflow.com/a/20159305/6509519). They discuss how to present your code and data. Those trying to answer your question should not have to download data from an external source. – Ian Thompson Oct 08 '19 at 14:56
  • I don't think `df.rolling()` would be appropriate in this case. You'll probably want to slide the window (perhaps in a comprehension) explicitly, then create a new DataFrame or append to existing DataFrame with that data to get the output above. – Brad Folkens Apr 10 '20 at 20:34

0 Answers0