|
59 | 59 | if res.status_code == 200: |
60 | 60 | print('get_crypto_history_bar:', res.json()) |
61 | 61 |
|
| 62 | + # Crypto historical bars within a time range using start_time and end_time (timestamps in milliseconds). |
| 63 | + res = data_client.crypto_market_data.get_crypto_history_bar( |
| 64 | + "BTCUSD", Category.US_CRYPTO.name, Timespan.M1.name, |
| 65 | + start_time=1711262998500, end_time=1711349398500) |
| 66 | + if res.status_code == 200: |
| 67 | + print('get_crypto_history_bar with time range:', res.json()) |
| 68 | + |
62 | 69 | res = data_client.market_data.get_snapshot('AAPL', Category.US_STOCK.name, extend_hour_required=True, overnight_required=True) |
63 | 70 | if res.status_code == 200: |
64 | 71 | print('get_snapshot:', res.json()) |
|
94 | 101 | if res.status_code == 200: |
95 | 102 | print('get_futures_history_bars:', res.json()) |
96 | 103 |
|
| 104 | + # Futures historical bars within a time range using start_time and end_time (timestamps in milliseconds). |
| 105 | + res = data_client.futures_market_data.get_futures_history_bars( |
| 106 | + 'SILZ5,6BM6', Category.US_FUTURES.name, Timespan.M1.name, |
| 107 | + start_time=1711262998500, end_time=1711349398500) |
| 108 | + if res.status_code == 200: |
| 109 | + print('get_futures_history_bars with time range:', res.json()) |
| 110 | + |
97 | 111 | res = data_client.futures_market_data.get_futures_tick("SILZ5", Category.US_FUTURES.name, count=10) |
98 | 112 | if res.status_code == 200: |
99 | 113 | print('get_futures_tick:', res.json()) |
|
156 | 170 | if res.status_code == 200: |
157 | 171 | print('get_option_history_bars:', res.json()) |
158 | 172 |
|
| 173 | + # Option historical bars within a time range using start_time and end_time (timestamps in milliseconds). |
| 174 | + res = data_client.option_market_data.get_option_history_bars( |
| 175 | + 'AAPL260522C00300000', Category.US_OPTION.name, Timespan.M1.name, |
| 176 | + start_time=1711262998500, end_time=1711349398500) |
| 177 | + if res.status_code == 200: |
| 178 | + print('get_option_history_bars with time range:', res.json()) |
| 179 | + |
159 | 180 | # Option market data - Tick |
160 | 181 | # Rate limit: 60 requests per minute |
161 | 182 | res = data_client.option_market_data.get_option_tick("AAPL260522C00300000", Category.US_OPTION.name, count=30) |
|
292 | 313 | res = data_client.screener.get_52whl(Category.US_STOCK.name, rank_type="NEW_HIGH") |
293 | 314 | if res.status_code == 200: |
294 | 315 | print('get_52whl:', res.json()) |
| 316 | + |
| 317 | + # ==================== Screeners ==================== |
| 318 | + # Market sentiment (fear & greed) index |
| 319 | + sentiment_res = data_client.screener.get_fear_and_greed_index(Category.US_STOCK.name) |
| 320 | + if sentiment_res.status_code == 200: |
| 321 | + print('get_fear_and_greed_index:', sentiment_res.json()) |
| 322 | + |
| 323 | + # Stock unusual activities |
| 324 | + unusual_res = data_client.screener.get_stock_unusual_activities("NVDA", Category.US_STOCK.name, count=10) |
| 325 | + if unusual_res.status_code == 200: |
| 326 | + print('get_stock_unusual_activities:', unusual_res.json()) |
| 327 | + |
| 328 | + # ==================== Fundamentals ==================== |
| 329 | + # Macro economic calendar |
| 330 | + calendar_res = data_client.fundamentals.get_economic_calendars("US", "2026-09-01", "2026-09-08") |
| 331 | + if calendar_res.status_code == 200: |
| 332 | + print('get_economic_calendars:', calendar_res.json()) |
| 333 | + |
| 334 | + # Institution search -> 13F holdings -> holding changes |
| 335 | + institutions_res = data_client.fundamentals.get_institution_search("Bridgewater") |
| 336 | + if institutions_res.status_code == 200: |
| 337 | + print('get_institution_search:', institutions_res.json()) |
| 338 | + |
| 339 | + holdings_res = data_client.fundamentals.get_institution_holdings("0001738828") |
| 340 | + if holdings_res.status_code == 200: |
| 341 | + print('get_institution_holdings:', holdings_res.json()) |
| 342 | + |
| 343 | + holding_changes_res = data_client.fundamentals.get_institution_holding_changes("0001738828", "OPEN", count=10) |
| 344 | + if holding_changes_res.status_code == 200: |
| 345 | + print('get_institution_holding_changes:', holding_changes_res.json()) |
| 346 | + |
| 347 | + # Insider transactions and holdings overview |
| 348 | + insider_tx_res = data_client.fundamentals.get_insider_transactions("NVDA", Category.US_STOCK.name) |
| 349 | + if insider_tx_res.status_code == 200: |
| 350 | + print('get_insider_transactions:', insider_tx_res.json()) |
| 351 | + |
| 352 | + insider_overview_res = data_client.fundamentals.get_insider_holdings( |
| 353 | + "NVDA", Category.US_STOCK.name, compare_months=1) |
| 354 | + if insider_overview_res.status_code == 200: |
| 355 | + print('get_insider_holdings:', insider_overview_res.json()) |
| 356 | + |
| 357 | + # ==================== News ==================== |
| 358 | + # Search news by keyword |
| 359 | + search_news_res = data_client.news.get_news_search("Starlink") |
| 360 | + if search_news_res.status_code == 200: |
| 361 | + print('get_news_search:', search_news_res.json()) |
| 362 | + |
| 363 | + # Stock news list |
| 364 | + stock_news_res = data_client.news.get_stock_news("TSLA", Category.US_STOCK.name) |
| 365 | + if stock_news_res.status_code == 200: |
| 366 | + print('get_stock_news:', stock_news_res.json()) |
| 367 | + |
| 368 | + # News detail (use a news_id returned by the list/search APIs) |
| 369 | + news_items = (stock_news_res.json().get('data') or []) if stock_news_res.status_code == 200 else [] |
| 370 | + if news_items: |
| 371 | + news_detail_res = data_client.news.get_news_detail(news_items[0].get('news_id')) |
| 372 | + if news_detail_res.status_code == 200: |
| 373 | + print('get_news_detail:', news_detail_res.json()) |
0 commit comments