-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathuse_data.py
More file actions
53 lines (37 loc) · 1.89 KB
/
Copy pathuse_data.py
File metadata and controls
53 lines (37 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Example usage of the Data service (news, calendar, research)."""
from configparser import ConfigParser
from pprint import pprint
from ibc.client import InteractiveBrokersClient
config = ConfigParser()
config.read('config/config.ini')
account_number = config.get('interactive_brokers_paper', 'paper_account')
ibc_client = InteractiveBrokersClient(
account_number=account_number,
)
ibc_client.authentication.wait_for_login()
data_service = ibc_client.data_services
# ---------------------------------------------------------------------------
# Get a company summary by contract ID.
# ---------------------------------------------------------------------------
pprint(data_service.summary(contract_id='265598'))
# Output: {'265598': {'conid': 265598, 'company_name': 'APPLE INC', ...}}
# ---------------------------------------------------------------------------
# Get news articles related to your portfolio.
# ---------------------------------------------------------------------------
pprint(data_service.portfolio_news())
# Output: [{'article_id': '...', 'headline': '...', ...}]
# ---------------------------------------------------------------------------
# Get the top news articles.
# ---------------------------------------------------------------------------
pprint(data_service.top_news())
# Output: [{'article_id': '...', 'headline': '...', ...}]
# ---------------------------------------------------------------------------
# Get news briefings.
# ---------------------------------------------------------------------------
pprint(data_service.news_briefings())
# Output: [{'article_id': '...', 'headline': '...', ...}]
# ---------------------------------------------------------------------------
# Get available news sources.
# ---------------------------------------------------------------------------
pprint(data_service.news_sources())
# Output: [{'name': 'Dow Jones', 'code': 'DJNL'}, ...]