alphavantage.symbology   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 66
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A format_ric_ticker() 0 9 2
1
"""
2
Mapping for Factset exchange codes to Reuter's RICs.
3
4
-- Yahoo Reference with exchange name and RIC suffixes
5
https://help.yahoo.com/kb/SLN2310.html
6
7
-- Reuters company lookup
8
https://www.reuters.com/finance/stocks/lookup
9
"""
10
11
12
# Factset exchange code to RIC suffix
13
FACTSET_EXCHANGE_TO_SUFFIX_MAP = {
14
    'AMS': 'AS',
15
    'ASX': 'AX',
16
    'ATH': 'AT',
17
    'BAR': 'BC',
18
    'BER': 'BE',
19
    'BKK': 'BK',
20
    'BOM': 'BO',
21
    'BRU': 'BR',
22
    'BSP': 'SA',
23
    'BUE': 'BA',
24
    'CAI': 'CA',
25
    'CAR': 'CR',
26
    'CSE': 'CO',
27
    'DSMD': 'QA',
28
    'DUB': 'IR',
29
    'DUS': 'DU',
30
    'ETR': 'DE',
31
    'FRA': 'F',
32
    'HAM': 'HM',
33
    'HEL': 'HE',
34
    'HKG': 'HK',
35
    'ICE': 'IC',
36
    'IST': 'IS',
37
    'JKT': 'JK',
38
    'JSE': 'JO',
39
    'KLS': 'KL',
40
    'KRX': 'KS',
41
    'LIS': 'LS',
42
    'LIT': 'VS',
43
    'LON': 'L',
44
    'MAD': 'MA',
45
    'MEX': 'MX',
46
    'MIC': 'ME',
47
    'MIL': 'MI',
48
    'MUN': 'MU',
49
    'NAS': None,
50
    'NSE': 'NS',
51
    'NYS': None,
52
    'NZE': 'NZ',
53
    'OME': 'ST',
54
    'OSL': 'OL',
55
    'OTC': None,
56
    'PAR': 'PA',
57
    'PRA': 'PR',
58
    'RIS': 'RG',
59
    'SAU': 'SAU',
60
    'SES': 'SI',
61
    'SGO': 'SN',
62
    'SHE': 'SZ',
63
    'SHG': 'SS',
64
    'STU': 'SG',
65
    'SWX': 'SW',
66
    'TAE': 'TA',
67
    'TAI': 'TW',
68
    'TAL': 'TL',
69
    'TKS': 'T',
70
    'TSE': 'TO',
71
    'TSX': 'V',
72
    'WBO': 'VI'
73
}
74
75
76
def format_ric_ticker(ticker, exchange_code):
77
    """Format RIC ticker from Factset exchange code."""
78
79
    suffix = FACTSET_EXCHANGE_TO_SUFFIX_MAP[exchange_code]
80
81
    if suffix:
82
        ticker = f'{ticker}.{suffix}'
0 ignored issues
show
introduced by
invalid syntax (<string>, line 82)
Loading history...
83
84
    return ticker
85