Agent skill
vnstock-quote-best-practices
Best practices for using vnstock3 Quote class with VCI source. Use when fetching Vietnamese stock price data, implementing batch processing, caching, error handling, or data validation for vnstock Quote operations. Triggers on queries about vnstock performance optimization, resilient data fetching, or Quote API patterns.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/vnstock-best-practices
SKILL.md
VNStock Quote Best Practices
Quick Reference
from vnstock import Quote
# Basic usage - VCI source only
quote = Quote(symbol='VCI', source='VCI')
df = quote.history(start='2024-01-01', end='2024-12-31', interval='1D')
Parameters:
symbol: Stock ticker (e.g., 'VCI', 'ACB', 'FPT')source: Must be'VCI'for this skillinterval:'1D'(daily),'1W'(weekly),'1M'(monthly)
Output columns: time, open, high, low, close, volume
Patterns
Batch Processing
Reuse Quote instance, change symbol:
from vnstock import Quote
symbols = ['VCI', 'ACB', 'FPT']
quote = Quote(source='VCI', symbol='VCI')
results = {}
for symbol in symbols:
quote.symbol = symbol
results[symbol] = quote.history(start='2024-01-01', end='2024-12-31', interval='1D')
Caching
See references/caching.md for file-based cache implementation with TTL.
Retry Logic
from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type
import requests
@retry(
retry=retry_if_exception_type((requests.RequestException, TimeoutError)),
stop=stop_after_attempt(5),
wait=wait_exponential(multiplier=1, min=2, max=10)
)
def fetch_with_retry(quote, start, end):
return quote.history(start=start, end=end)
Source Fallback
def get_price_with_fallback(symbol, start, end):
sources = ['VCI', 'TCBS'] # VCI primary, TCBS backup
for source in sources:
try:
quote = Quote(source=source, symbol=symbol)
return quote.history(start=start, end=end)
except Exception:
continue
raise Exception("All sources failed")
Data Validation
def validate_ohlc(df):
issues = []
required = ['time', 'open', 'high', 'low', 'close', 'volume']
missing = [c for c in required if c not in df.columns]
if missing:
issues.append(f"Missing: {missing}")
if df.isnull().any().any():
issues.append(f"Nulls: {df.isnull().sum().sum()}")
if (df['high'] < df['low']).any():
issues.append("Invalid OHLC: high < low")
return issues
Outlier Detection
import numpy as np
def detect_outliers(df, column='close', threshold=3):
z = np.abs((df[column] - df[column].mean()) / df[column].std())
return df[z > threshold]
Error Handling
See references/error-handling.md for:
- Circuit breaker pattern
- Connection pooling
- Comprehensive logging setup
Key Rules
- Always use
source='VCI'- This skill targets VCI source only - Reuse Quote instances - Don't create new instances per symbol in loops
- Validate data after fetch - Check for nulls, OHLC logic, gaps
- Implement retries - Network requests can fail temporarily
- Cache when appropriate - Reduce API calls for historical data
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?