Switch to candlestick charts with 30-day daily data
- Replace line charts with candlestick charts for better visualization - Green candles for up days, red for down days - Daily resolution (30 days) - free tier compatible - Auto-detect intraday vs daily data for proper time/date formatting - Note: 5-min intraday requires paid Polygon tier ($199/month) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,9 +45,22 @@ class ChartGenerator:
|
||||
# Fill area under the line
|
||||
ax.fill_between(dates, closes, alpha=0.3, color='#00d4ff')
|
||||
|
||||
# Format x-axis
|
||||
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m/%d'))
|
||||
ax.xaxis.set_major_locator(mdates.AutoDateLocator())
|
||||
# Format x-axis (detect if intraday or multi-day)
|
||||
if len(dates) > 0:
|
||||
# Check if all data is from the same day
|
||||
first_date = dates[0].date()
|
||||
last_date = dates[-1].date()
|
||||
is_intraday = first_date == last_date
|
||||
|
||||
if is_intraday:
|
||||
# Show time for intraday data
|
||||
ax.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
|
||||
ax.xaxis.set_major_locator(mdates.HourLocator(interval=1))
|
||||
else:
|
||||
# Show date for multi-day data
|
||||
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m/%d'))
|
||||
ax.xaxis.set_major_locator(mdates.AutoDateLocator())
|
||||
|
||||
plt.xticks(rotation=45, ha='right')
|
||||
|
||||
# Grid styling
|
||||
@@ -125,9 +138,22 @@ class ChartGenerator:
|
||||
bottom = min(opens[i], closes[i])
|
||||
ax.bar(dates[i], height, width, bottom=bottom, color=color, alpha=0.8)
|
||||
|
||||
# Format x-axis
|
||||
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m/%d'))
|
||||
ax.xaxis.set_major_locator(mdates.AutoDateLocator())
|
||||
# Format x-axis (detect if intraday or multi-day)
|
||||
if len(dates) > 0:
|
||||
# Check if all data is from the same day
|
||||
first_date = dates[0].date()
|
||||
last_date = dates[-1].date()
|
||||
is_intraday = first_date == last_date
|
||||
|
||||
if is_intraday:
|
||||
# Show time for intraday data
|
||||
ax.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
|
||||
ax.xaxis.set_major_locator(mdates.HourLocator(interval=1))
|
||||
else:
|
||||
# Show date for multi-day data
|
||||
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m/%d'))
|
||||
ax.xaxis.set_major_locator(mdates.AutoDateLocator())
|
||||
|
||||
plt.xticks(rotation=45, ha='right')
|
||||
|
||||
# Grid styling
|
||||
|
||||
Reference in New Issue
Block a user