Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Dec 11, 2024
1 parent 07523ba commit 1f83a64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
29 changes: 12 additions & 17 deletions autohedge/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import os
import uuid
from datetime import datetime
Expand Down Expand Up @@ -60,8 +59,8 @@ class AutoHedgeOutput(BaseModel):
decision: str = None
timestamp: str = datetime.now().isoformat()
current_stock: str


class AutoHedgeOutputMain(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
Expand All @@ -70,9 +69,6 @@ class AutoHedgeOutputMain(BaseModel):
task: Optional[str] = None
timestamp: str = datetime.now().isoformat()
logs: List[AutoHedgeOutput] = None





# Risk Assessment Agent
Expand Down Expand Up @@ -223,6 +219,7 @@ def __init__(
verbose=True,
context_length=16000,
)

def generate_thesis(
self,
task: str = "Generate a thesis for the stock",
Expand All @@ -238,7 +235,7 @@ def generate_thesis(
TradingThesis: Generated thesis
"""
logger.info(f"Generating thesis for {stock}")

self.tickr = TickrAgent(
stocks=[stock],
max_loops=1,
Expand Down Expand Up @@ -339,6 +336,7 @@ def analyze(self, stock: str, thesis: str) -> str:
)
raise


class AutoFund:
"""
Main trading system that coordinates all agents and manages the trading cycle.
Expand Down Expand Up @@ -384,9 +382,9 @@ def __init__(
self.logs = AutoHedgeOutputMain(
name=self.name,
description=self.description,
stocks = stocks,
task = "",
logs = [],
stocks=stocks,
task="",
logs=[],
)

def run(self, task: str, *args, **kwargs):
Expand All @@ -402,7 +400,6 @@ def run(self, task: str, *args, **kwargs):
List: List of logs for each stock.
"""
logger.info("Starting trading cycle")
logs = []

try:
for stock in self.stocks:
Expand All @@ -425,13 +422,11 @@ def run(self, task: str, *args, **kwargs):
order = self.execution.generate_order(
stock, thesis, risk_assessment
)

order = str(order)

# Final decision
decision = self.director.make_decision(
order, thesis
)
decision = self.director.make_decision(order, thesis)

log = AutoHedgeOutput(
thesis=thesis,
Expand All @@ -448,9 +443,9 @@ def run(self, task: str, *args, **kwargs):
create_file_in_folder(
self.output_dir,
f"analysis-{uuid.uuid4().hex}.json",
self.logs.model_dump_json(indent=4)
self.logs.model_dump_json(indent=4),
)

return self.logs.model_dump_json(indent=4)

except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "autohedge"
version = "0.0.5"
version = "0.0.6"
description = "autohedge - TGSC"
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand Down

0 comments on commit 1f83a64

Please sign in to comment.