Current temperature, feels-like temperature, humidity, rain and wind in New York City from Open-Meteo, in Fahrenheit.
No keys needed.
api.open-meteo.com
Use in Studio adds this version to your Data Feeds and opens a Strategy chat with it. It runs on your own Runner when you test it or deploy a Strategy that reads it, in Paper and Live, not in Backtests. Your copy is yours to edit, and later changes to this example don't change it.
# /// turbine-edge-source
# { "contract": 1, "name": "nyc_weather", "mode": "hosted", "refresh": "5m", "max_age": "30m",
# "fields": {
# "temperature_f": { "type": "number" },
# "feels_like_f": { "type": "number" },
# "humidity_pct": { "type": "number" },
# "precipitation_in": { "type": "number" },
# "wind_mph": { "type": "number" },
# "is_raining": { "type": "bool" }
# } }
# ///
# Current conditions in New York City (Central Park) from Open-Meteo, in
# Fahrenheit, inches and miles per hour. Open-Meteo updates them every 15
# minutes. No key needed.
import json
import urllib.request
URL = (
"https://api.open-meteo.com/v1/forecast?latitude=40.7829&longitude=-73.9654"
"¤t=temperature_2m,apparent_temperature,relative_humidity_2m,precipitation,rain,showers,wind_speed_10m"
"&temperature_unit=fahrenheit&wind_speed_unit=mph&precipitation_unit=inch&timeformat=unixtime&timezone=GMT"
)
def fetch():
req = urllib.request.Request(URL, headers={"User-Agent": "Turbine Data Feed", "Accept": "application/json"})
with urllib.request.urlopen(req, timeout=8) as resp:
current = json.load(resp)["current"]
rain = float(current.get("rain") or 0) + float(current.get("showers") or 0)
return {
"time": float(current["time"]),
"values": {
"temperature_f": float(current["temperature_2m"]),
"feels_like_f": float(current["apparent_temperature"]),
"humidity_pct": float(current["relative_humidity_2m"]),
"precipitation_in": float(current["precipitation"]),
"wind_mph": float(current["wind_speed_10m"]),
"is_raining": rain > 0,
},
}