Skip to content

Commit

Permalink
Standardize pandas Timestamp inits
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Jan 2, 2024
1 parent 418ce47 commit d1f2ec5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions nautilus_trader/test_kit/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ def btcusdt_future_binance(
"""
if activation is None:
activation = pd.Timestamp(2021, 12, 25, tz=pytz.utc)
activation = pd.Timestamp("2021-12-25", tz=pytz.utc)
if expiration is None:
expiration = pd.Timestamp(2022, 3, 25, tz=pytz.utc)
expiration = pd.Timestamp("2022-3-25", tz=pytz.utc)
return CryptoFuture(
instrument_id=InstrumentId(
symbol=Symbol(f"BTCUSDT_{expiration.strftime('%y%m%d')}"),
Expand Down Expand Up @@ -533,8 +533,8 @@ def aapl_option() -> OptionsContract:
underlying="AAPL",
kind=OptionKind.CALL,
strike_price=Price.from_str("149.00"),
activation_ns=pd.Timestamp(2021, 9, 17, tz=pytz.utc).value,
expiration_ns=pd.Timestamp(2021, 12, 17, tz=pytz.utc).value,
activation_ns=pd.Timestamp("2021-9-17", tz=pytz.utc).value,
expiration_ns=pd.Timestamp("2021-12-17", tz=pytz.utc).value,
ts_event=0,
ts_init=0,
)
Expand Down
13 changes: 6 additions & 7 deletions nautilus_trader/test_kit/rust/instruments_pyo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
# -------------------------------------------------------------------------------------------------

from datetime import datetime

import pandas as pd
import pytz
Expand Down Expand Up @@ -65,9 +64,9 @@ def btcusdt_future_binance(
expiration: pd.Timestamp | None = None,
) -> CryptoFuture:
if activation is None:
activation = pd.Timestamp(2021, 12, 25, tz=pytz.utc)
activation = pd.Timestamp("2021-12-25", tz=pytz.utc)
if expiration is None:
expiration = pd.Timestamp(2022, 3, 25, tz=pytz.utc)
expiration = pd.Timestamp("2022-3-25", tz=pytz.utc)

instrument_id_str = f"BTCUSDT_{expiration.strftime('%y%m%d')}.BINANCE"
return CryptoFuture(
Expand Down Expand Up @@ -119,9 +118,9 @@ def appl_option(
expiration: pd.Timestamp | None = None,
) -> OptionsContract:
if activation is None:
activation = pd.Timestamp(datetime(2021, 9, 17), tz=pytz.UTC)
activation = pd.Timestamp("2021-9-17", tz=pytz.utc)
if expiration is None:
expiration = pd.Timestamp(datetime(2021, 12, 17), tz=pytz.UTC)
expiration = pd.Timestamp("2021-12-17", tz=pytz.utc)
return OptionsContract(
id=InstrumentId.from_str("AAPL211217C00150000.OPRA"),
raw_symbol=Symbol("AAPL211217C00150000"),
Expand Down Expand Up @@ -167,9 +166,9 @@ def futures_contract_es(
expiration: pd.Timestamp | None = None,
) -> FuturesContract:
if activation is None:
activation = pd.Timestamp(2021, 9, 17, tz=pytz.utc)
activation = pd.Timestamp("2021-9-17", tz=pytz.utc)
if expiration is None:
expiration = pd.Timestamp(2021, 12, 17, tz=pytz.utc)
expiration = pd.Timestamp("2021-12-17", tz=pytz.utc)
return FuturesContract(
id=InstrumentId.from_str("ESZ21.CME"),
raw_symbol=Symbol("ESZ21"),
Expand Down

0 comments on commit d1f2ec5

Please sign in to comment.