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

adds user input for initial porfolio #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
46 changes: 41 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,47 @@ def create_workflow(selected_analysts=None):
else:
start_date = args.start_date

# Initialize portfolio with multiple tickers
portfolio = {
"cash": 100000.0, # $100,000 initial cash
"positions": {ticker: 0 for ticker in tickers}, # No initial stock positions
}
#Ask if to use default values
value_choice = questionary.select(
"What do you want to do?",
choices=[
"Run with default values",
"Run with cusom values",],
).ask()

if value_choice == "Run with default values":
portfolio = {
"cash": 100000.0, # $100,000 initial cash
"positions": {ticker: 0 for ticker in tickers},
}

else:
#Ask initial cash
cash = float(questionary.text(
"How much initial capital? ($)",
#Validate input
validate=lambda l: l.replace('.', '', 1).isdigit() or l == ""
).ask())
if cash == "":
cash = 0

#Ask positions
positions = {}
for ticker in tickers:
position_value = int(questionary.text(
f"How many shares of {ticker} in the portfolio?",
#Validate input
validate=lambda l: l.isdigit() or l == ""
).ask())
if position_value == "":
position_value = 0
positions[ticker] = position_value

#Init portfolio
portfolio = {
"cash": cash,
"positions": positions,
}

# Run the hedge fund
result = run_hedge_fund(
Expand Down