Datetime
Module for datetime utility functions.
OqDateTime
¶
This class provides methods to convert timestamps to strings and vice versa.
Source code in onequant/util/datetime.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
string_to_ms_timestamp(date_string)
staticmethod
¶
Converts a date and time string in the format 'YYYY-MM-DD HH:MM:SS' to a timestamp in milliseconds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date_string |
str
|
The date and time string to convert. |
required |
Returns:
Name | Type | Description |
---|---|---|
int | The timestamp in milliseconds. |
Source code in onequant/util/datetime.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
string_to_timestamp(date_string)
staticmethod
¶
Converts a date and time string in the format 'YYYY-MM-DD HH:MM:SS' to a timestamp.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date_string |
str
|
The date and time string to convert. |
required |
Returns:
Name | Type | Description |
---|---|---|
int | The timestamp. |
Source code in onequant/util/datetime.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
timestamp_to_string(timestamp)
staticmethod
¶
Converts a timestamp to a string in the format 'YYYY-MM-DD HH:MM:SS'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timestamp |
int
|
The timestamp to convert. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The formatted date and time string. |
Source code in onequant/util/datetime.py
9 10 11 12 13 14 15 16 17 18 19 |
|