@@ -11,15 +11,26 @@ A modern Python wrapper for the Alpaca Trading API, providing easy access to tra
1111
1212## ✨ Features
1313
14+ ### Core Features
1415- ** 🔐 Complete Alpaca API Coverage** : Trading, market data, account management, and more
1516- ** 📊 Stock Market Analysis** : Built-in screeners for gainers/losers, historical data analysis
1617- ** 🚀 Batch Operations** : Efficient multi-symbol data fetching with automatic batching (200+ symbols)
1718- ** 🤖 ML-Powered Predictions** : Stock price predictions using Facebook Prophet
1819- ** 📰 Financial News Integration** : Real-time news from Yahoo Finance and Benzinga
1920- ** 📈 Technical Analysis** : Stock recommendations and sentiment analysis
2021- ** 🎯 Type Safety** : Full type annotations with mypy strict mode
21- - ** 🧪 Battle-Tested** : 100+ tests with comprehensive coverage
22- - ** ⚡ Modern Python** : Async-ready, Python 3.10+ with latest best practices
22+ - ** 🧪 Battle-Tested** : 300+ tests with comprehensive coverage
23+ - ** ⚡ Modern Python** : Python 3.10+ with latest best practices
24+
25+ ### New in v3.0.0
26+ - ** 📸 Market Snapshots** : Get complete market snapshots with latest trade, quote, and bar data
27+ - ** ⚙️ Account Configuration** : Manage PDT settings, trade confirmations, and margin configurations
28+ - ** 📋 Market Metadata** : Access condition codes, exchange information, and trading metadata
29+ - ** 🔄 Enhanced Orders** : Replace orders, client order IDs, and advanced order management
30+ - ** 🎯 Smart Feed Management** : Automatic feed selection and fallback (SIP → IEX → OTC)
31+ - ** 💾 Intelligent Caching** : Built-in caching system with configurable TTLs for optimal performance
32+ - ** 🏢 Corporate Actions** : Track dividends, splits, mergers, and other corporate events
33+ - ** 📊 Trade Data API** : Access historical and real-time trade data with pagination
2334
2435## 📦 Installation
2536
@@ -306,6 +317,162 @@ sip_trades = api.stock.trades.get_trades(
306317)
307318```
308319
320+ ### Market Snapshots
321+
322+ ``` python
323+ # Get snapshot for a single symbol
324+ snapshot = api.stock.snapshots.get_snapshot(" AAPL" )
325+ print (f " Latest trade: $ { snapshot.latest_trade.price} " )
326+ print (f " Latest quote: Bid $ { snapshot.latest_quote.bid} / Ask $ { snapshot.latest_quote.ask} " )
327+ print (f " Daily bar: Open $ { snapshot.daily_bar.open} / Close $ { snapshot.daily_bar.close} " )
328+ print (f " Previous daily: Open $ { snapshot.prev_daily_bar.open} / Close $ { snapshot.prev_daily_bar.close} " )
329+
330+ # Get snapshots for multiple symbols (efficient batch operation)
331+ symbols = [" AAPL" , " GOOGL" , " MSFT" , " TSLA" , " NVDA" ]
332+ snapshots = api.stock.snapshots.get_snapshots(symbols)
333+ for symbol, snapshot in snapshots.items():
334+ print (f " { symbol} : $ { snapshot.latest_trade.price} ( { snapshot.daily_bar.volume:, } volume) " )
335+
336+ # Get snapshots with specific feed
337+ snapshots = api.stock.snapshots.get_snapshots(
338+ symbols = [" SPY" , " QQQ" ],
339+ feed = " iex" # or "sip", "otc"
340+ )
341+ ```
342+
343+ ### Account Configuration
344+
345+ ``` python
346+ # Get current account configuration
347+ config = api.trading.account.get_configuration()
348+ print (f " PDT Check: { config.pdt_check} " )
349+ print (f " Trade Confirm Email: { config.trade_confirm_email} " )
350+ print (f " Suspend Trade: { config.suspend_trade} " )
351+ print (f " No Shorting: { config.no_shorting} " )
352+
353+ # Update account configuration
354+ updated_config = api.trading.account.update_configuration(
355+ trade_confirm_email = True ,
356+ suspend_trade = False ,
357+ pdt_check = " both" , # "both", "entry", or "exit"
358+ no_shorting = False
359+ )
360+ print (" Account configuration updated successfully" )
361+ ```
362+
363+ ### Market Metadata
364+
365+ ``` python
366+ # Get condition codes for trades
367+ condition_codes = api.stock.metadata.get_condition_codes(tape = " A" )
368+ for code in condition_codes:
369+ print (f " Code { code.code} : { code.description} " )
370+
371+ # Get exchange codes
372+ exchanges = api.stock.metadata.get_exchange_codes()
373+ for exchange in exchanges:
374+ print (f " { exchange.code} : { exchange.name} ( { exchange.type} ) " )
375+
376+ # Get all condition codes at once (cached for performance)
377+ all_codes = api.stock.metadata.get_all_condition_codes()
378+ print (f " Loaded { len (all_codes)} condition codes " )
379+
380+ # Lookup specific codes
381+ code_info = api.stock.metadata.lookup_condition_code(" R" )
382+ print (f " Code R means: { code_info.description} " )
383+ ```
384+
385+ ### Enhanced Order Management
386+
387+ ``` python
388+ # Place order with client order ID for tracking
389+ order = api.trading.orders.market(
390+ symbol = " AAPL" ,
391+ qty = 1 ,
392+ side = " buy" ,
393+ client_order_id = " my-app-order-123"
394+ )
395+
396+ # Replace an existing order (modify price, quantity, etc.)
397+ replaced_order = api.trading.orders.replace_order(
398+ order_id = order.id,
399+ qty = 2 , # Change quantity
400+ limit_price = 155.00 # Add/change limit price
401+ )
402+
403+ # Get order by client order ID (useful for tracking)
404+ orders = api.trading.orders.get_all(status = " open" )
405+ my_order = next ((o for o in orders if o.client_order_id == " my-app-order-123" ), None )
406+
407+ # Advanced OCO/OTO orders
408+ oco_order = api.trading.orders.limit(
409+ symbol = " TSLA" ,
410+ qty = 1 ,
411+ side = " buy" ,
412+ limit_price = 200.00 ,
413+ order_class = " oco" , # One-Cancels-Other
414+ take_profit = {" limit_price" : 250.00 },
415+ stop_loss = {" stop_price" : 180.00 }
416+ )
417+ ```
418+
419+ ### Smart Feed Management
420+
421+ ``` python
422+ # The library automatically manages feed selection based on your subscription
423+ # No configuration needed - it automatically detects and falls back as needed
424+
425+ # Manual feed configuration (optional)
426+ from py_alpaca_api.http.feed_manager import FeedManager, FeedConfig, FeedType
427+
428+ # Configure preferred feeds
429+ feed_config = FeedConfig(
430+ preferred_feed = FeedType.SIP , # Try SIP first
431+ fallback_feeds = [FeedType.IEX ], # Fall back to IEX if needed
432+ auto_fallback = True # Automatically handle permission errors
433+ )
434+
435+ # The feed manager automatically:
436+ # - Detects your subscription level (Basic/Unlimited/Business)
437+ # - Falls back to available feeds on permission errors
438+ # - Caches failed feeds to avoid repeated attempts
439+ # - Provides clear logging for debugging
440+ ```
441+
442+ ### Intelligent Caching System
443+
444+ ``` python
445+ # Caching is built-in and automatic for improved performance
446+ # Configure caching (optional - sensible defaults are provided)
447+ from py_alpaca_api.cache import CacheManager, CacheConfig
448+
449+ # Custom cache configuration
450+ cache_config = CacheConfig(
451+ max_size = 1000 , # Maximum items in cache
452+ default_ttl = 300 , # Default time-to-live in seconds
453+ data_ttls = {
454+ " market_hours" : 86400 , # 1 day
455+ " assets" : 3600 , # 1 hour
456+ " quotes" : 1 , # 1 second
457+ " positions" : 10 , # 10 seconds
458+ }
459+ )
460+
461+ # Cache manager automatically:
462+ # - Caches frequently accessed data
463+ # - Reduces API calls and improves response times
464+ # - Manages memory efficiently with LRU eviction
465+ # - Supports optional Redis backend for distributed caching
466+
467+ # Use the @cached decorator for custom caching
468+ cache_manager = CacheManager(cache_config)
469+
470+ @cache_manager.cached (" custom_data" , ttl = 600 )
471+ def expensive_calculation (symbol : str ):
472+ # This result will be cached for 10 minutes
473+ return complex_analysis(symbol)
474+ ```
475+
309476### Advanced Order Types
310477
311478``` python
@@ -405,27 +572,36 @@ make lint
405572```
406573py-alpaca-api/
407574├── src/py_alpaca_api/
408- │ ├── __init__.py # Main API client
409- │ ├── exceptions.py # Custom exceptions
410- │ ├── trading/ # Trading operations
411- │ │ ├── account.py # Account management
412- │ │ ├── orders.py # Order management
413- │ │ ├── positions.py # Position tracking
414- │ │ ├── watchlists.py # Watchlist operations
415- │ │ ├── market.py # Market data
416- │ │ ├── news.py # Financial news
417- │ │ └── recommendations.py # Stock analysis
418- │ ├── stock/ # Stock market data
419- │ │ ├── assets.py # Asset information
420- │ │ ├── history.py # Historical data
421- │ │ ├── screener.py # Stock screening
422- │ │ ├── predictor.py # ML predictions
423- │ │ └── latest_quote.py # Real-time quotes
424- │ ├── models/ # Data models
425- │ └── http/ # HTTP client
426- ├── tests/ # Test suite
427- ├── docs/ # Documentation
428- └── pyproject.toml # Project configuration
575+ │ ├── __init__.py # Main API client
576+ │ ├── exceptions.py # Custom exceptions
577+ │ ├── trading/ # Trading operations
578+ │ │ ├── account.py # Account management & configuration
579+ │ │ ├── orders.py # Order management (enhanced)
580+ │ │ ├── positions.py # Position tracking
581+ │ │ ├── watchlists.py # Watchlist operations
582+ │ │ ├── market.py # Market hours & calendar
583+ │ │ ├── news.py # Financial news
584+ │ │ ├── recommendations.py # Stock analysis
585+ │ │ └── corporate_actions.py # Corporate events (v3.0.0)
586+ │ ├── stock/ # Stock market data
587+ │ │ ├── assets.py # Asset information
588+ │ │ ├── history.py # Historical data (batch support)
589+ │ │ ├── screener.py # Stock screening
590+ │ │ ├── predictor.py # ML predictions
591+ │ │ ├── latest_quote.py # Real-time quotes (batch support)
592+ │ │ ├── trades.py # Trade data API (v3.0.0)
593+ │ │ ├── snapshots.py # Market snapshots (v3.0.0)
594+ │ │ └── metadata.py # Market metadata (v3.0.0)
595+ │ ├── models/ # Data models
596+ │ ├── cache/ # Caching system (v3.0.0)
597+ │ │ ├── cache_manager.py # Cache management
598+ │ │ └── cache_config.py # Cache configuration
599+ │ └── http/ # HTTP client
600+ │ ├── requests.py # Request handling
601+ │ └── feed_manager.py # Feed management (v3.0.0)
602+ ├── tests/ # Test suite (300+ tests)
603+ ├── docs/ # Documentation
604+ └── pyproject.toml # Project configuration
429605```
430606
431607## 📖 Documentation
@@ -484,13 +660,34 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
484660
485661## 🗺️ Roadmap
486662
663+ ### v3.0.0 (Current Release)
664+ - ✅ Complete Alpaca Stock API coverage
665+ - ✅ Market Snapshots API
666+ - ✅ Account Configuration API
667+ - ✅ Market Metadata API
668+ - ✅ Enhanced Order Management
669+ - ✅ Corporate Actions API
670+ - ✅ Trade Data API
671+ - ✅ Smart Feed Management System
672+ - ✅ Intelligent Caching System
673+ - ✅ Batch Operations for all data endpoints
674+
675+ ### v3.1.0 (Planned)
487676- [ ] WebSocket support for real-time data streaming
677+ - [ ] Live market data subscriptions
678+ - [ ] Real-time order and trade updates
679+
680+ ### v3.2.0 (Planned)
681+ - [ ] Full async/await support
682+ - [ ] Concurrent API operations
683+ - [ ] Async context managers
684+
685+ ### Future Releases
488686- [ ] Options trading support
489687- [ ] Crypto trading integration
490688- [ ] Advanced portfolio analytics
491689- [ ] Backtesting framework
492690- [ ] Strategy automation tools
493- - [ ] Mobile app integration
494691
495692## ⚠️ Disclaimer
496693
0 commit comments