yfinance-exporter 1.0.4__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,27 +88,43 @@ 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)
|
94
109
|
DAEMON.labels(status="item-count", **labels).set(len(conf.stocks))
|
95
110
|
|
96
111
|
labels["section"] = "exec"
|
112
|
+
in_loop_interval = int(conf.loop.interval / (len(conf.stocks) + 1)) or 1
|
113
|
+
states = {}
|
97
114
|
while True:
|
98
115
|
start = datetime.now()
|
99
116
|
DAEMON.labels(status="items-ok", **labels).set(0)
|
100
117
|
DAEMON.labels(status="items-ko", **labels).set(0)
|
101
118
|
|
102
119
|
for stock in conf.stocks:
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
DAEMON.labels(status="items-ko", **labels).inc()
|
120
|
+
result = collect(stock)
|
121
|
+
update_state(result, stock.isin, states, labels)
|
122
|
+
time.sleep(in_loop_interval)
|
107
123
|
|
108
124
|
exec_interval = (datetime.now() - start).total_seconds()
|
109
125
|
DAEMON.labels(status="exec-time", **labels).set(exec_interval)
|
110
126
|
DAEMON.labels(status="loop-count", **labels).inc()
|
111
|
-
interval = conf.loop.interval - exec_interval
|
127
|
+
interval = int(conf.loop.interval - exec_interval)
|
112
128
|
if interval > 0:
|
113
129
|
time.sleep(interval)
|
114
130
|
|
@@ -1,4 +0,0 @@
|
|
1
|
-
yfinance_exporter.py,sha256=1v2IUqGt6oUqmWnjdIVNNCAM2vUSiWCBuEJfuxUCEIM,3446
|
2
|
-
yfinance_exporter-1.0.4.dist-info/METADATA,sha256=oEdcowZDRoHxxTukkYDr1wAlrQvaCK60cShM0TlhIQ4,1525
|
3
|
-
yfinance_exporter-1.0.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
4
|
-
yfinance_exporter-1.0.4.dist-info/RECORD,,
|
File without changes
|