File size: 1,144 Bytes
c99df4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pandas as pd
import numpy as np
import sys
import os

# Add project root to path
sys.path.append(os.getcwd())

from src.core.market_profile import MarketProfile

def test_market_profile():
    print("Testing MarketProfile...")
    mp = MarketProfile(multiplier=2.0)
    
    # Create dummy data
    # Price oscillates between 100 and 110
    dates = pd.date_range(start='2024-01-01 10:00', periods=100, freq='1min')
    bids = np.linspace(100, 110, 50)
    bids = np.concatenate((bids, np.linspace(110, 100, 50)))
    
    df = pd.DataFrame({
        'datetime': dates,
        'bid': bids,
        'ask': bids + 0.1
    })
    
    # Update profile
    mp.update(df)
    
    # Check counts
    print(f"Total ticks: {mp.total_ticks}")
    print(f"Counts keys: {len(mp.counts)}")
    
    # Check Levels
    vah, val, poc = mp.get_vah_val_poc()
    print(f"VAH: {vah}, VAL: {val}, POC: {poc}")
    
    if vah is None or val is None or poc is None:
        print("FAIL: Levels are None")
    else:
        print("PASS: Levels calculated")

if __name__ == "__main__":
    test_market_profile()