ahudock commited on
Commit
bd1afaf
·
1 Parent(s): 92fdd4b

Add yf_selected_expiration

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -63,6 +63,24 @@ def yf_underlying_price(ticker: str, dte: int = 0) -> float:
63
  underlying_price, _, _, _, _ = _get_atm_option_data(ticker, dte)
64
  return underlying_price
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  @tool
67
  def yf_atm_strike(ticker: str, dte: int = 0) -> float:
68
  """
@@ -155,7 +173,6 @@ def yf_atm_straddle_price(ticker: str, dte: int = 0) -> float:
155
  put_price = float(put_row.get("lastPrice", 0.0))
156
  return call_price + put_price
157
 
158
-
159
  ddgs = DuckDuckGoSearchTool();
160
 
161
  final_answer = FinalAnswerTool()
@@ -170,7 +187,6 @@ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may
170
  custom_role_conversions=None,
171
  )
172
 
173
-
174
  # Import tool from Hub
175
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
176
 
@@ -189,5 +205,4 @@ agent = CodeAgent(
189
  prompt_templates=prompt_templates
190
  )
191
 
192
-
193
  GradioUI(agent).launch()
 
63
  underlying_price, _, _, _, _ = _get_atm_option_data(ticker, dte)
64
  return underlying_price
65
 
66
+ @tool
67
+ def yf_selected_expiration(ticker: str, dte: int = 0) -> str:
68
+ """
69
+ Return the option expiration date selected for the given stock ticker and
70
+ desired days-to-expiration (DTE). The expiration chosen is the one whose
71
+ days-to-expiration is closest to the requested DTE.
72
+
73
+ Args:
74
+ ticker (str): The stock ticker symbol, e.g., AAPL.
75
+ dte (int): Desired days-to-expiration. A value of 0 selects the nearest
76
+ available expiration. Defaults to 0.
77
+
78
+ Returns:
79
+ str: The selected expiration date in YYYY-MM-DD format.
80
+ """
81
+ _, expiration, _, _, _ = _get_atm_option_data(ticker, dte)
82
+ return expiration
83
+
84
  @tool
85
  def yf_atm_strike(ticker: str, dte: int = 0) -> float:
86
  """
 
173
  put_price = float(put_row.get("lastPrice", 0.0))
174
  return call_price + put_price
175
 
 
176
  ddgs = DuckDuckGoSearchTool();
177
 
178
  final_answer = FinalAnswerTool()
 
187
  custom_role_conversions=None,
188
  )
189
 
 
190
  # Import tool from Hub
191
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
192
 
 
205
  prompt_templates=prompt_templates
206
  )
207
 
 
208
  GradioUI(agent).launch()