recent trades in list
This commit is contained in:
50
test_timestamps.py
Normal file
50
test_timestamps.py
Normal file
@ -0,0 +1,50 @@
|
||||
from datetime import datetime, timedelta
|
||||
from realtime import RealTimeChart
|
||||
|
||||
# Create a chart instance
|
||||
chart = RealTimeChart('BTC/USDT')
|
||||
|
||||
# Add a BUY position from yesterday
|
||||
yesterday = datetime.now() - timedelta(days=1)
|
||||
chart.add_trade(
|
||||
price=64950.25,
|
||||
timestamp=yesterday,
|
||||
amount=0.5,
|
||||
pnl=None,
|
||||
action='BUY'
|
||||
)
|
||||
print(f'Added BUY position from {yesterday}')
|
||||
|
||||
# Add a matching SELL position from yesterday (2 hours later)
|
||||
yesterday_plus_2h = yesterday + timedelta(hours=2)
|
||||
chart.add_trade(
|
||||
price=65100.75,
|
||||
timestamp=yesterday_plus_2h,
|
||||
amount=0.5,
|
||||
pnl=75.25,
|
||||
action='SELL'
|
||||
)
|
||||
print(f'Added matching SELL position from {yesterday_plus_2h}')
|
||||
|
||||
# Add a trade from 2 days ago
|
||||
two_days_ago = datetime.now() - timedelta(days=2)
|
||||
chart.add_trade(
|
||||
price=64800.50,
|
||||
timestamp=two_days_ago,
|
||||
amount=0.25,
|
||||
pnl=None,
|
||||
action='BUY'
|
||||
)
|
||||
print(f'Added BUY position from {two_days_ago}')
|
||||
|
||||
two_days_ago_plus_3h = two_days_ago + timedelta(hours=3)
|
||||
chart.add_trade(
|
||||
price=65000.75,
|
||||
timestamp=two_days_ago_plus_3h,
|
||||
amount=0.25,
|
||||
pnl=50.06,
|
||||
action='SELL'
|
||||
)
|
||||
print(f'Added matching SELL position from {two_days_ago_plus_3h}')
|
||||
|
||||
print('\nAll test trades added successfully!')
|
Reference in New Issue
Block a user