yfinance-exporter 1.0.13__py3-none-any.whl → 1.1.0__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.
@@ -1,15 +1,14 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.3
|
2
2
|
Name: yfinance-exporter
|
3
|
-
Version: 1.0
|
3
|
+
Version: 1.1.0
|
4
4
|
Summary:
|
5
|
-
|
6
|
-
Author-email: francois@schmidts.fr
|
7
|
-
Requires-Python: >=3.12,<4.0
|
5
|
+
Requires-Python: >=3.13
|
8
6
|
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.
|
10
|
-
Requires-Dist:
|
11
|
-
Requires-Dist:
|
12
|
-
Requires-Dist:
|
7
|
+
Classifier: Programming Language :: Python :: 3.13
|
8
|
+
Requires-Dist: daemon-metrics (>=1.0.0,<2.0.0)
|
9
|
+
Requires-Dist: prometheus-client (>=0.21.1)
|
10
|
+
Requires-Dist: the-conf (>=1.0.4)
|
11
|
+
Requires-Dist: yfinance (>=0.2.51)
|
13
12
|
Description-Content-Type: text/markdown
|
14
13
|
|
15
14
|
[](https://pypi.org/project/yfinance-exporter/) [](https://hub.docker.com/r/jaesivsm/yfinance-exporter/tags)
|
@@ -0,0 +1,4 @@
|
|
1
|
+
yfinance_exporter.py,sha256=kVgwiEI6M3JhqmLSJfTFmBbR3HwFEntujh0G_LE82Kk,3453
|
2
|
+
yfinance_exporter-1.1.0.dist-info/METADATA,sha256=h9EnsjJCoLrvCYG_9ykuYl_qStDPBddmoEitGo1BE7g,1483
|
3
|
+
yfinance_exporter-1.1.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
4
|
+
yfinance_exporter-1.1.0.dist-info/RECORD,,
|
yfinance_exporter.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
|
3
3
|
import logging
|
4
|
+
import time
|
4
5
|
|
6
|
+
import daemon_metrics
|
5
7
|
from prometheus_client import Gauge, start_http_server
|
6
|
-
from datetime import datetime
|
7
|
-
import time
|
8
8
|
from the_conf import TheConf
|
9
9
|
from yfinance import Ticker
|
10
10
|
|
@@ -45,7 +45,6 @@ except AttributeError as error:
|
|
45
45
|
"ERROR and FATAL are accepted"
|
46
46
|
) from error
|
47
47
|
|
48
|
-
DAEMON = Gauge("daemon", "", ["name", "section", "status"])
|
49
48
|
STOCK = Gauge(
|
50
49
|
"financial_positions",
|
51
50
|
"",
|
@@ -91,43 +90,24 @@ def collect(stock) -> bool:
|
|
91
90
|
return True
|
92
91
|
|
93
92
|
|
94
|
-
def update_state(result: bool, key: str, states: dict, labels: dict):
|
95
|
-
previous = states.get(key)
|
96
|
-
states[key] = result
|
97
|
-
if previous == result:
|
98
|
-
logger.debug("%s(%r => %r) UNCHANGED", key, previous, result)
|
99
|
-
return
|
100
|
-
inc_key, dec_key = "items-ok", "items-ko"
|
101
|
-
if not result:
|
102
|
-
inc_key, dec_key = "items-ko", "items-ok"
|
103
|
-
logger.debug("%s(%r => %r) %r +1", key, previous, result, inc_key)
|
104
|
-
DAEMON.labels(status=inc_key, **labels).inc()
|
105
|
-
if previous is not None:
|
106
|
-
logger.debug("%s(%r => %r) %r -1", key, previous, result, dec_key)
|
107
|
-
DAEMON.labels(status=dec_key, **labels).dec()
|
108
|
-
|
109
|
-
|
110
93
|
def main():
|
111
|
-
|
112
|
-
|
113
|
-
|
94
|
+
info = {
|
95
|
+
"loop-perid": conf.loop.interval,
|
96
|
+
"item-count": len(conf.stocks),
|
97
|
+
}
|
98
|
+
daemon_metrics.init(conf.name, info)
|
114
99
|
|
115
|
-
labels["section"] = "exec"
|
116
100
|
in_loop_interval = int(conf.loop.interval / (len(conf.stocks) + 1)) or 1
|
117
|
-
states = {}
|
118
101
|
while True:
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
102
|
+
loop_context = daemon_metrics.LoopContext(conf.name)
|
103
|
+
with loop_context:
|
104
|
+
for stock in conf.stocks:
|
105
|
+
result = collect(stock)
|
106
|
+
daemon_metrics.item_result(conf.name, result, stock.isin)
|
107
|
+
logger.debug("Wating computed interval %r", in_loop_interval)
|
108
|
+
time.sleep(in_loop_interval)
|
125
109
|
|
126
|
-
|
127
|
-
DAEMON.labels(status="exec-time", **labels).set(exec_interval)
|
128
|
-
DAEMON.labels(status="loop-count", **labels).inc()
|
129
|
-
interval = int(conf.loop.interval - exec_interval)
|
130
|
-
if interval > 0:
|
110
|
+
if (interval := conf.loop.interval - loop_context.exec_interval) > 0:
|
131
111
|
logger.debug("Waiting %d to complete the loop interval", interval)
|
132
112
|
time.sleep(interval)
|
133
113
|
|
@@ -1,4 +0,0 @@
|
|
1
|
-
yfinance_exporter.py,sha256=6whsA4pOho_xJBpJfgycqD-ddlkvwDbgU-1nwjMSdBQ,4374
|
2
|
-
yfinance_exporter-1.0.13.dist-info/METADATA,sha256=IJ_25EeeHqG9ZmgBx-3C0YJGMkX5T96XXvv5ly_Lmqc,1526
|
3
|
-
yfinance_exporter-1.0.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
4
|
-
yfinance_exporter-1.0.13.dist-info/RECORD,,
|