forked from ig-python/trading-ig
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_all_nodes.py
More file actions
98 lines (83 loc) · 2.91 KB
/
example_all_nodes.py
File metadata and controls
98 lines (83 loc) · 2.91 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from trading_ig.IGService import IGService
from trading_ig.config import config
def display_top_level_nodes():
ig_service = get_session()
response = ig_service.fetch_top_level_navigation_nodes()
for node in response['nodes']:
print(node)
# print(f"{node['name']} [{node['id']}]")
def display_all_epics():
ig_service = get_session()
response = ig_service.fetch_top_level_navigation_nodes()
for node in response['nodes']:
print(f"{node['name']} [{node['id']}]")
display_epics_for_node(node['id'], space=' ', ig_service=ig_service)
def display_epics_for_node(node_id=0, space='', ig_service=None):
if ig_service is None:
ig_service = get_session()
sub_nodes = ig_service.fetch_sub_nodes_by_node(node_id)
if sub_nodes['nodes']:
for node in sub_nodes['nodes']:
print(f"{space}{node['name']} [{node['id']}]")
display_epics_for_node(node['id'], space=space + ' ', ig_service=ig_service)
if sub_nodes['markets']:
for node in sub_nodes['markets']:
print(f"{space}{node['instrumentName']} ({node['expiry']}): {node['epic']}")
def get_session():
ig_service = IGService(config)
ig_service.create_session(version='3')
return ig_service
if __name__ == "__main__":
# display_top_level_nodes()
display_all_epics()
"""
Weekend Markets [191926749]
Indices [97601]
Forex [195235]
Commodities Metals Energies [101515]
Cryptocurrency [668394]
Bonds and Moneymarket [108092]
ETFs, ETCs & Trackers [184730]
Shares - UK [180500]
Shares - UK International (IOB) [97695]
Shares - US (All Sessions) [298158]
Shares - US [97477]
Shares - Austria [114058]
Shares - Belgium [114036]
Shares - Canada [103185]
Shares - Denmark [419769]
Shares - Finland [99514]
Shares - France [113659]
Shares - LSE (UK) [172904]
Shares - Germany [97466]
Shares - Greece [100437]
Shares - Hong Kong [105775]
Shares - Ireland (LSE) [421257]
Shares - Ireland (Euronext Dublin) [99578822]
Shares - Netherlands [105509]
Shares - New Zealand [127489792]
Shares - Norway [99808]
Shares - Portugal [99787]
Shares - Singapore [105781]
Shares - South Africa [100066]
Shares - Sweden [113681]
Shares - Switzerland [99814]
IPOs [324080]
Options (Australia 200) [77976799]
Options (Eu Stocks 50) [245938]
Options (France 40) [188760]
Options (FTSE) [122250]
Options (Germany) [97612]
Options (HS 50) [92462573]
Options (Japan 225) [111915265]
Options (Netherlands 25) [236490]
Options (Sweden 30) [319963]
Options (Taiwan Index) [157168018]
Options (US 500) [267039]
Options (US Tech 100) [89291253]
Options (Wall St) [122505]
Options on FX Majors [255072]
Options (Volatility Index) [56719751]
Options on Metals, Energies [195913]
"""
#display_epics_for_node(195913)