to_unix_timestamp#

API documentation for tradingstrategy.utils.time.to_unix_timestamp Python function.

to_unix_timestamp(dt)[source]#

Convert Python UTC datetime to UNIX seconds since epoch.

Example:

import datetime
from eth_defi.utils import to_unix_timestamp

dt = datetime.datetime(1970, 1, 1)
unix_time = to_unix_timestamp(dt)
assert unix_time == 0
Parameters:

dt (datetime) – Python datetime to convert

Returns:

Datetime as seconds since 1970-1-1

Return type:

float