Signaturekd.to_unix_seconds(value, name="value")
Convert any supported time argument to Unix seconds.
This is the conversion every client method applies to its time arguments (start, end, min_close, …). Times without a timezone are treated as UTC.
Parameters
value:str, datetime, date, pandas.Timestamp, int, float or None- The time to convert. See Time arguments for the accepted forms.
name:str, default 'value'- Name of the argument, used in error messages.
Returns
- int
- Unix seconds.
- None
- If
value is None.
Raises
ValueError- If
value looks like milliseconds (e.g. 1793577600000). Kalshi expects seconds, so this is rejected rather than silently asking for the wrong date.
Examples
#from stakepd import kalshi_data as kd
A date string (UTC):
kd.to_unix_seconds("2026-11-01")
Output:
1793491200
With a timezone offset:
kd.to_unix_seconds("2026-11-01T14:30:00-05:00")
Output:
1793561400
None passes through (returns None):
This method is also covered, alongside the rest of the module, in the overview guide.