bfolkens / py-market-profile

A library to calculate Market Profile (aka Volume Profile) for financial data from a Pandas DataFrame.
Other
353 stars 122 forks source link

POC is not aligning with my market profile tool #10

Closed baluinfo86 closed 2 years ago

baluinfo86 commented 4 years ago

For certain days POC & VA are not aligning with my market profile tool. I am testing this for Indian market - Bank Nifty futures.

Bank Nifty trading @ 21000 - 22000 Avg Daily range - 500 tick size used = 14 mode: tpo

As per code getting VPOC as 21770, but as per my tool its 21670.

Observed same behavior for most of the days. Also VA are not off by some marigin.

If its roughly matching, am good, but could see huge variance, let me know if am doing anything wrong in terms of setting up parameters?

bfolkens commented 4 years ago

Do you have access to the raw data that the market profile tool uses? Some market profile tools "cheat" in that they don't actually use tick level data. The other possibility is that there's an exclusive/inclusive boundary issue, etc. Which tool are you using?

Laurensvdm commented 3 years ago

Saw this thread yesterday and this is what i'm facing also right now so i place my post in here :) l like what you made , I always trade with volume profile to add extra confluence to zones etc. I started recently with python and my goal is to make a dashboard for trading.

Now for testing,i’m using BTC/USDT data from coinbase ( but I extract it via tradingview ) 15min data

When running it in python I get : mp_slice.poc_price : 12908.95 In tradingview I see : https://www.tradingview.com/x/9kATOGZR/ = different

Now when using 1min data its getting much closer

POC = 13014 on Tradingview = 13010

Basically I want to display all the centers off the high value nodes. Does this mean I should get constant 1min data ? I think TV calculates it trough tick data however an approximation should be enough for me.

I will need a datastream from 15min data however, but using 1min data will slow it all very hard i think. Any idea's how i should work further ?

Thanks in advance!

bfolkens commented 3 years ago

Hi @Laurensvdm - that's correct. A good example of this that I usually use for comparison are the footprint and market profile charts on Cignals.io. The best kind of data to use with market profile is as granular of a resolution as possible. Ideally, you would use tick-level data, but unfortunately that's not always possible with the data feeds that are available.

Laurensvdm commented 3 years ago

Well ive found the 1min data to play with 👍

What i'm aiming to do now iis to display all the hvn's like this : https://www.tradingview.com/x/uLDLQSEd/

In your code , a hvn is a place where alot of volume has been traded. ( but there are alot of them when printing them out) I want to find the exact tops of each clusters. Any idea to accomplish this ?:)

ethanopp commented 2 years ago

Hey @bfolkens thanks for writing this lib! I think I'm having some similar issues as to what is mentioned above, just not sure on what the recommendation here is? I am trying to build a strategy that runs off 30m candles, but getting very different results on TV compared to the script. Could you please let me know if I am doing something wrong? Thanks image Output

Profile
Close
190.60    133.57433
190.80     93.85817
191.75     91.74555
192.65    115.69072
192.80    105.55979
193.15     65.79506
193.55     38.00174
196.15    400.69860
Name: Volume, dtype: float64

Value Area
(191.75, 196.15)

POC
196.15

LVN
Close
191.75    91.74555
193.55    38.00174
Name: Volume, dtype: float64

HVN
Close
192.65    115.69072
Name: Volume, dtype: float64
from market_profile import MarketProfile
import pandas as pd

data = pd.read_json(r"/COMP_USD-30m.json", orient='values')
data.columns = ['Date', 'Open', 'High', 'Low', 'Close', 'Volume']
data.set_index(pd.to_datetime(data['Date']), inplace=True)

# Create the market profile
mp = MarketProfile(data)

mp_slice = mp[data.index.min():data.index.max()]

print('Profile')
print(mp_slice.profile)
print()
print('Value Area')
print(mp_slice.value_area)
print()
print('POC')
print(mp_slice.poc_price)
print()
print('LVN')
print(mp_slice.low_value_nodes)
print()
print('HVN')
print(mp_slice.high_value_nodes)

Raw Data [[1639225800000,192.75,193.49,192.64,192.64,115.69072],[1639227600000,192.63,192.94,190.66,190.76,93.85817],[1639229400000,192.12,192.93,190.58,190.58,133.57433],[1639231200000,191.64,192.51,190.65,191.71,91.74555],[1639233000000,192.02,193.12,191.69,193.12,65.79506],[1639234800000,193.18,193.26,192.58,192.79,105.55979],[1639236600000,193.08,193.54,192.96,193.54,38.00174],[1639238400000,193.31,196.44,193.3,196.14,400.6986]]

bfolkens commented 2 years ago

@ethanopp it looks like you're retrieving 30m intervals on the OHLCV data. I would use something far less than this to get accurate output (as low as possible, like 1m data). In reality, tick-level data should be used, but unfortunately none of that is usually publicly available for tradfi (though much easier to obtain with crypto exchanges).