This repository has been archived by the owner on Aug 10, 2019. It is now read-only.
forked from fho/stockanalyser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyser.py
92 lines (70 loc) · 2.79 KB
/
analyser.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# !/usr/bin/env python3
import argparse
import logging
from stockanalyser import logger as colorlog
from stockanalyser.analysis.levermann import Levermann
colorlog.setup_logger()
logger = logging.getLogger(__name__)
def configure_argparse():
parser = argparse.ArgumentParser(description="Levermann Stock analyser")
parser.add_argument("-d", "--debug", action='store_true')
subparsers = parser.add_subparsers()
# show_parser = subparsers.add_parser("list")
# show_parser.add_argument("-v", "--verbose", action='store_true')
# show_parser.add_argument("-o", "--outdated",
# help="show list of stocks with outdated"
# " figure release date", action='store_true')
# show_parser.set_defaults(func=list)
#
# add_parser = subparsers.add_parser("add")
# add_parser.add_argument("ISIN", help="Stock ISIN")
# add_parser.set_defaults(func=add)
#
# update_parser = subparsers.add_parser("update")
# update_parser.add_argument("STOCK_SYMBOL", help="Stock Symbol", nargs="?")
# update_parser.add_argument("-f", "--force", help="enforce update",
# action="store_true")
# update_parser.set_defaults(func=update)
# set_parser = subparsers.add_parser("set")
# set_parser.add_argument("stock_symbol", help="Stock Symbol with"
# " country ending")
# set_parser.set_defaults(func=set)
args = vars(parser.parse_args())
configure_logger(args.debug)
if "func" not in args:
parser.print_help()
args.func(args)
# logger.debug("Argparse arguments: %s" % args)
# if args.add:
# add_stock()
# elif args.show:
# show(args.verbose)
# else:
def configure_logger(debug):
if debug:
level = logging.DEBUG
else:
level = logging.INFO
logging.getLogger().setLevel(level)
def show_outdated(levermann_objs):
outdated = []
for l in levermann_objs:
if l.stock._is_quarterly_figures_release_date_outdated():
outdated.append("%s (%s): %s" %
(l.stock.name, l.stock.symbol,
l.stock.last_quarterly_figures_release_date()))
print("For the following stocks the last figure release date is outdated:\n",
"\n".join(outdated))
print("-" * 80)
def main(isin):
if isinstance(isin, list):
for idx, stock in enumerate(isin, 1):
# print(idx, stock)
Levermann(isin=stock)
logger.info(
"Finished stock with ISIN: {}! {}/{} stock finished".format(stock, idx, len(isin)))
elif isinstance(isin, str):
print("str")
# Levermann(isin=isin)
if __name__ == "__main__":
main(isin=["DE0005313704", "DE000CBK1001"])