LordXido commited on
Commit
3eddc20
·
verified ·
1 Parent(s): 7f90e26

Create web_ingest.py

Browse files
Files changed (1) hide show
  1. web_ingest.py +31 -0
web_ingest.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # web_ingest.py
2
+
3
+ import requests
4
+ from datetime import datetime
5
+
6
+ # Example public endpoints (replace or extend)
7
+ PUBLIC_SOURCES = {
8
+ "gold_price": "https://api.metals.live/v1/spot/gold",
9
+ "oil_price": "https://api.oilpriceapi.com/v1/prices/latest", # example
10
+ }
11
+
12
+ def fetch_public_signal(name: str):
13
+ try:
14
+ r = requests.get(PUBLIC_SOURCES[name], timeout=5)
15
+ r.raise_for_status()
16
+ return {
17
+ "source": name,
18
+ "timestamp": datetime.utcnow().isoformat(),
19
+ "data": r.json()
20
+ }
21
+ except Exception as e:
22
+ return {
23
+ "source": name,
24
+ "error": str(e)
25
+ }
26
+
27
+ def ingest_all():
28
+ signals = {}
29
+ for name in PUBLIC_SOURCES:
30
+ signals[name] = fetch_public_signal(name)
31
+ return signals