3434 TradingSuite ,
3535 setup_logging ,
3636)
37+ from project_x_py .types .protocols import RealtimeDataManagerProtocol
3738
3839if TYPE_CHECKING :
3940 from project_x_py .realtime_data_manager import RealtimeDataManager
4041
4142
42- async def display_current_prices (data_manager : "RealtimeDataManager" ):
43+ async def display_current_prices (data_manager : "RealtimeDataManager" ) -> None :
4344 """Display current prices across all timeframes asynchronously."""
4445 print ("\n 📊 Current Prices:" )
4546
@@ -84,7 +85,7 @@ async def display_current_prices(data_manager: "RealtimeDataManager"):
8485 print (f" { timeframe :>6} : No data" )
8586
8687
87- async def display_memory_stats (data_manager ) :
88+ async def display_memory_stats (data_manager : "RealtimeDataManager" ) -> None :
8889 """Display memory usage statistics asynchronously."""
8990 try :
9091 # get_memory_stats is synchronous in async data manager
@@ -106,7 +107,7 @@ async def display_memory_stats(data_manager):
106107 print (f" ❌ Memory stats error: { e } " )
107108
108109
109- async def display_system_statistics (data_manager ) :
110+ async def display_system_statistics (data_manager : "RealtimeDataManager" ) -> None :
110111 """Display comprehensive system and validation statistics asynchronously."""
111112 try :
112113 # Use validation status instead of get_statistics (which doesn't exist)
@@ -138,7 +139,7 @@ async def display_system_statistics(data_manager):
138139 print (f" ❌ System stats error: { e } " )
139140
140141
141- async def demonstrate_historical_analysis (data_manager ) :
142+ async def demonstrate_historical_analysis (data_manager : "RealtimeDataManager" ) -> None :
142143 """Demonstrate historical data analysis asynchronously."""
143144 print ("\n 📈 Historical Data Analysis:" )
144145
@@ -158,7 +159,7 @@ async def demonstrate_historical_analysis(data_manager):
158159 if data is not None and not data .is_empty ():
159160 # Calculate basic statistics
160161 avg_price = data ["close" ].mean ()
161- price_range = data ["close" ].max () - data ["close" ].min ()
162+ price_range = float ( data ["close" ].max ()) - float ( data ["close" ].min () )
162163 total_volume = data ["volume" ].sum ()
163164
164165 print (f" { tf } Analysis (last 100 bars):" )
@@ -172,7 +173,7 @@ async def demonstrate_historical_analysis(data_manager):
172173 print (f" ❌ Analysis error: { e } " )
173174
174175
175- async def new_bar_callback (data ) :
176+ async def new_bar_callback (data : dict [ str , Any ]) -> None :
176177 """Handle new bar creation asynchronously."""
177178 timestamp = datetime .now ().strftime ("%H:%M:%S" )
178179 timeframe = data ["timeframe" ]
@@ -182,7 +183,7 @@ async def new_bar_callback(data):
182183 )
183184
184185
185- async def main ():
186+ async def main () -> bool :
186187 """Main async real-time data streaming demonstration."""
187188
188189 # Setup logging
@@ -248,7 +249,7 @@ async def main():
248249 print ("\n 🔔 Registering optional event handlers for demonstration..." )
249250 try :
250251 # Use the EventBus through TradingSuite
251- suite .on (EventType .NEW_BAR , new_bar_callback )
252+ await suite .on (EventType .NEW_BAR , new_bar_callback )
252253 print ("✅ Optional event handlers registered!" )
253254 except Exception as e :
254255 print (f"⚠️ Event handler registration error: { e } " )
@@ -266,19 +267,19 @@ async def main():
266267 print ("=" * 60 )
267268
268269 # Create concurrent monitoring tasks
269- async def monitor_prices ():
270+ async def monitor_prices () -> None :
270271 """Monitor and display prices periodically."""
271272 while True :
272273 await asyncio .sleep (10 ) # Update every 10 seconds
273274 await display_current_prices (data_manager )
274275
275- async def monitor_statistics ():
276+ async def monitor_statistics () -> None :
276277 """Monitor and display statistics periodically."""
277278 while True :
278279 await asyncio .sleep (30 ) # Update every 30 seconds
279280 await display_system_statistics (data_manager )
280281
281- async def monitor_memory ():
282+ async def monitor_memory () -> None :
282283 """Monitor and display memory usage periodically."""
283284 while True :
284285 await asyncio .sleep (60 ) # Update every minute
0 commit comments