-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
70 lines (52 loc) · 2.53 KB
/
main.py
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
import argparse
from datetime import datetime
import config
from calculate_realized_market_capitalization import calculate_realized_market_capitalization
from calculate_token_holder_stats import calculate_token_holder_stats
from calculate_top_token_holder import calculate_top_token_holder
from calculate_top_token_holder_normalized import calculate_top_token_holder_normalized
from exchange_rates import source_coin_gecko, source_nexustracker
from manage_balances import update_balances
from manage_transactions import update_token_transactions
from manage_realized_market_capitalization import update_realized_market_capitalization
from util import logging
log = logging.get_custom_logger(__name__, config.LOG_LEVEL)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--etherscan-api-token',
dest='etherscan_api_token',
required=True,
help='the api token with which the script will query the etherscan api')
args = parser.parse_args()
for token in config.TOKEN:
token_contracts = []
for address in token['token_contracts']:
token_contracts.append(address.lower())
token['token_contracts'] = token_contracts
lending_contracts = []
for address in token['lending_contracts']:
lending_contracts.append(address.lower())
token['lending_contracts'] = lending_contracts
team_accounts = []
for address in token['team_accounts']:
team_accounts.append(address.lower())
token['team_accounts'] = team_accounts
log.info('start analysis for token ' + token['symbol'])
update_token_transactions(args.etherscan_api_token, token['symbol'], token['address'])
if token['source_exchange_rates'] == 'coin_gecko':
source_coin_gecko.update_exchange_rates(token['symbol'])
elif token['source_exchange_rates'] == 'nexustracker':
source_nexustracker.update_exchange_rates(token['symbol'])
update_realized_market_capitalization(token)
update_balances(token)
#
# calculation of results
#
calculate_realized_market_capitalization(token)
calculate_token_holder_stats(token)
log.debug('--------')
# postphone calculation of top token holders to have the other data faster
for token in config.TOKEN:
calculate_top_token_holder(token)
if len(token['lending_contracts']) > 0:
calculate_top_token_holder_normalized(token)