@@ -423,108 +423,3 @@ def get_dividends(
423
423
return pd .DataFrame (data , columns = columns )
424
424
else :
425
425
return response
426
-
427
-
428
- # Usage examples
429
-
430
- if __name__ == "__main__" :
431
- # Toggle example cases
432
- run_apple_eod_example = False
433
- run_microsoft_quotes_example = False
434
- run_google_ohlc_example = False
435
- run_tesla_trades_example = False
436
- run_amazon_trade_quote_example = True
437
- run_nvidia_splits_example = True
438
- run_intel_dividends_example = True
439
-
440
- historical_data = ThetaDataStocksHistorical (enable_logging = True , use_df = True )
441
-
442
- # Example 1: Get EOD report for AAPL
443
- if run_apple_eod_example :
444
- apple_eod = historical_data .get_eod_report ("AAPL" , "20240101" , "20240131" )
445
- if apple_eod is None :
446
- historical_data .logger .warning ("Failed to get Apple EOD Report" )
447
- elif apple_eod .empty :
448
- historical_data .logger .warning ("Apple EOD Report is empty" )
449
- else :
450
- historical_data .logger .info ("Apple EOD Report received" )
451
- print ("Apple EOD Report:" )
452
- print (apple_eod )
453
-
454
- # Example 2: Get quotes for MSFT
455
- if run_microsoft_quotes_example :
456
- microsoft_quotes = historical_data .get_quotes (
457
- "MSFT" , "20240101" , "20240131" , interval = "3600000"
458
- )
459
- if microsoft_quotes is None :
460
- historical_data .logger .warning ("Failed to get Microsoft Quotes" )
461
- elif microsoft_quotes .empty :
462
- historical_data .logger .warning ("Microsoft Quotes data is empty" )
463
- else :
464
- historical_data .logger .info ("Microsoft Quotes received" )
465
- print ("\n Microsoft Quotes:" )
466
- print (microsoft_quotes )
467
-
468
- # Example 3: Get OHLC for GOOGL
469
- if run_google_ohlc_example :
470
- google_ohlc = historical_data .get_ohlc (
471
- "GOOGL" , "20240101" , "20240131" , interval = "3600000"
472
- )
473
- if google_ohlc is None :
474
- historical_data .logger .warning ("Failed to get Google OHLC data" )
475
- elif google_ohlc .empty :
476
- historical_data .logger .warning ("Google OHLC data is empty" )
477
- else :
478
- historical_data .logger .info ("Google OHLC data received" )
479
- print ("\n Google OHLC data:" )
480
- print (google_ohlc )
481
-
482
- # Example 4: Get trades for TSLA
483
- if run_tesla_trades_example :
484
- tesla_trades = historical_data .get_trades ("TSLA" , "20240101" , "20240102" )
485
- if tesla_trades is None :
486
- historical_data .logger .warning ("Failed to get Tesla Trades data" )
487
- elif tesla_trades .empty :
488
- historical_data .logger .warning ("Tesla Trades data is empty" )
489
- else :
490
- historical_data .logger .info ("Tesla Trades data received" )
491
- print ("\n Tesla Trades data:" )
492
- print (tesla_trades )
493
-
494
- # Example 5: Get trade quotes for AMZN
495
- if run_amazon_trade_quote_example :
496
- amazon_trade_quotes = historical_data .get_trade_quote (
497
- "AMZN" , "20240101" , "20240102"
498
- )
499
- if amazon_trade_quotes is None :
500
- historical_data .logger .warning ("Failed to get Amazon Trade Quotes data" )
501
- elif amazon_trade_quotes .empty :
502
- historical_data .logger .warning ("Amazon Trade Quotes data is empty" )
503
- else :
504
- historical_data .logger .info ("Amazon Trade Quotes data received" )
505
- print ("\n Amazon Trade Quotes data:" )
506
- print (amazon_trade_quotes )
507
-
508
- # Example 6: Get splits for NVDA
509
- if run_nvidia_splits_example :
510
- nvidia_splits = historical_data .get_splits ("NVDA" , "20230101" , "20240131" )
511
- if nvidia_splits is None :
512
- historical_data .logger .warning ("Failed to get NVIDIA Splits data" )
513
- elif nvidia_splits .empty :
514
- historical_data .logger .warning ("NVIDIA Splits data is empty" )
515
- else :
516
- historical_data .logger .info ("NVIDIA Splits data received" )
517
- print ("\n NVIDIA Splits data:" )
518
- print (nvidia_splits )
519
-
520
- # Example 7: Get dividends for INTC
521
- if run_intel_dividends_example :
522
- intel_dividends = historical_data .get_dividends ("INTC" , "20230101" , "20240131" )
523
- if intel_dividends is None :
524
- historical_data .logger .warning ("Failed to get Intel Dividends data" )
525
- elif intel_dividends .empty :
526
- historical_data .logger .warning ("Intel Dividends data is empty" )
527
- else :
528
- historical_data .logger .info ("Intel Dividends data received" )
529
- print ("\n Intel Dividends data:" )
530
- print (intel_dividends )
0 commit comments