yfinance-exporter 1.0.5__py3-none-any.whl → 1.0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
|
|
1
|
+
yfinance_exporter.py,sha256=TJrHG5ykq-UlkZv8B81dWmAMuZzvyASftKOFvgWZi7o,4038
|
2
|
+
yfinance_exporter-1.0.6.dist-info/METADATA,sha256=G96Au8wscW9S9gqLFIAHdkMutW0kqUjtvUWmD7af7NU,1525
|
3
|
+
yfinance_exporter-1.0.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
4
|
+
yfinance_exporter-1.0.6.dist-info/RECORD,,
|
yfinance_exporter.py
CHANGED
@@ -88,6 +88,21 @@ def collect(stock):
|
|
88
88
|
return True
|
89
89
|
|
90
90
|
|
91
|
+
def update_state(result: bool, key: str, states: dict, labels: dict):
|
92
|
+
previous = states.get(key)
|
93
|
+
states[key] = "ok" if result else "ko"
|
94
|
+
if previous == "ko" and not result or previous == "ok" and result:
|
95
|
+
return
|
96
|
+
if result:
|
97
|
+
DAEMON.labels(status="items-ok", **labels).inc()
|
98
|
+
if previous:
|
99
|
+
DAEMON.labels(status="items-ko", **labels).dec()
|
100
|
+
else:
|
101
|
+
DAEMON.labels(status="items-ko", **labels).inc()
|
102
|
+
if previous:
|
103
|
+
DAEMON.labels(status="items-ok", **labels).dec()
|
104
|
+
|
105
|
+
|
91
106
|
def main():
|
92
107
|
labels = {"name": conf.name, "section": "config"}
|
93
108
|
DAEMON.labels(status="loop-period", **labels).set(conf.loop.interval)
|
@@ -95,16 +110,15 @@ def main():
|
|
95
110
|
|
96
111
|
labels["section"] = "exec"
|
97
112
|
in_loop_interval = int(conf.loop.interval / (len(conf.stocks) + 1)) or 1
|
113
|
+
states = {}
|
98
114
|
while True:
|
99
115
|
start = datetime.now()
|
100
116
|
DAEMON.labels(status="items-ok", **labels).set(0)
|
101
117
|
DAEMON.labels(status="items-ko", **labels).set(0)
|
102
118
|
|
103
119
|
for stock in conf.stocks:
|
104
|
-
|
105
|
-
|
106
|
-
else:
|
107
|
-
DAEMON.labels(status="items-ko", **labels).inc()
|
120
|
+
result = collect(stock)
|
121
|
+
update_state(result, stock.isin, states, labels)
|
108
122
|
time.sleep(in_loop_interval)
|
109
123
|
|
110
124
|
exec_interval = (datetime.now() - start).total_seconds()
|
@@ -1,4 +0,0 @@
|
|
1
|
-
yfinance_exporter.py,sha256=PfVap2jhccZG5WW6kvyq-hnIBttIsQRhbh3D1NB0Q7Y,3569
|
2
|
-
yfinance_exporter-1.0.5.dist-info/METADATA,sha256=wXKHV5CgN65n99bWEwoY6CZLEsoIAA136Z7wu7PMxJc,1525
|
3
|
-
yfinance_exporter-1.0.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
4
|
-
yfinance_exporter-1.0.5.dist-info/RECORD,,
|
File without changes
|