Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strategy universe created_at timestamp #1053

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tradeexecutor/strategy/pandas_trader/position_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,16 @@ def add_cash_to_credit_supply(
assert pair is not None, "The default credit supply position not configured correctly for the strategy universe"
assert cash > 0, f"Got cash: {cash}"

logger.info("Allocating cash for credit, cash %f, threshold %f", cash, min_usd_threshold)
# Live execution diagnostics logging
total_equity = self.state.portfolio.get_total_equity()
total_cash = self.state.portfolio.get_current_cash(),
logger.info(
"Allocating cash for credit, cash %f, threshold %f, total cash %f, total equity $f",
cash,
min_usd_threshold,
total_cash,
total_equity,
)

if cash < min_usd_threshold:
# No new deposit or only dust, don't generate extra trades
Expand Down
12 changes: 9 additions & 3 deletions tradeexecutor/strategy/trading_strategy_universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pickle
import textwrap
from abc import abstractmethod
from dataclasses import dataclass
from dataclasses import dataclass, field
import logging
from math import isnan
from pathlib import Path
Expand Down Expand Up @@ -181,13 +181,19 @@ class TradingStrategyUniverse(StrategyExecutionUniverse):
#:
price_data_delay_tolerance: datetime.timedelta | None = None

#: When this strategy object was created.
#:
#: Diagnostics info for caching issues.
#:
created_at: datetime.datetime = field(default_factory=datetime.datetime.utcnow)

def __repr__(self):
pair_count = self.data_universe.pairs.get_count()
if pair_count <= 3:
pair_tickers = [f"{p.base_token_symbol}-{p.quote_token_symbol}" for p in self.data_universe.pairs.iterate_pairs()]
return f"<TradingStrategyUniverse for {', '.join(pair_tickers)}>"
return f"<TradingStrategyUniverse for {', '.join(pair_tickers)}, created {self.created_at}>"
else:
return f"<TradingStrategyUniverse for {self.data_universe.pairs.get_count()} pairs>"
return f"<TradingStrategyUniverse for {self.data_universe.pairs.get_count()} pairs, created {self.created_at}>"

def __post_init__(self):
"""Check that we correctly constructed the instance."""
Expand Down
Loading