diff --git a/README.md b/README.md index df43b4c..66c2de9 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ traders_copilot_mzza_25 provides functionalities for generating trading signals, - generate_signals: a function that identify buy/sell signals based on price trends. - plot_signals: function that visualizes the timestamp and input values. -- fetch_market_data: a function that fetches market data from the internet. +- simulate_market_data: a function that simulate stock market data. - buy_stock: a function that buy stock and update user account. - sell_stock: a function that sells stock and update user account. diff --git a/src/traders_copilot_mzza_25/buy_stock.py b/src/traders_copilot_mzza_25/buy_stock.py index e69de29..0c33ce6 100644 --- a/src/traders_copilot_mzza_25/buy_stock.py +++ b/src/traders_copilot_mzza_25/buy_stock.py @@ -0,0 +1,31 @@ +def buy_stock(account, quantity, price): + """Execute a stock purchase and update the user's account. + + This function processes the purchase of a specific quantity of a stock at a given price. + It updates the user's account balance and increases the number of shares held for + the specified stock. + + Parameters + ---------- + account : dict + A dictionary representing the user's account. Expected keys include: + - 'balance': float, the current cash balance in the account. + - 'stocks': int, the number of shares held. + quantity : int + The number of shares to buy. Must be a positive integer. + price : float + The price per share at which the stock is purchased. + + Returns + ------- + dict + The updated account dictionary reflecting the new balance and stock holdings. + + Raises + ------ + ValueError + If the account balance is insufficient to complete the purchase. + + Examples + -------- + """ diff --git a/src/traders_copilot_mzza_25/fetch_market_data.py b/src/traders_copilot_mzza_25/fetch_market_data.py deleted file mode 100644 index 1d685eb..0000000 --- a/src/traders_copilot_mzza_25/fetch_market_data.py +++ /dev/null @@ -1,13 +0,0 @@ -def fetch_market_data(url): - """Fetches market data from the internet. - - - Parameters: - ---------- - url: A link to the website that contains market dataset. - - Returns: - ---------- - pd.DataFrame - The dataframe that contains columns for market data. - """ \ No newline at end of file diff --git a/src/traders_copilot_mzza_25/sell_stock.py b/src/traders_copilot_mzza_25/sell_stock.py index 8cce148..cc71ad0 100644 --- a/src/traders_copilot_mzza_25/sell_stock.py +++ b/src/traders_copilot_mzza_25/sell_stock.py @@ -1,4 +1,4 @@ -def sell_stock(account, stock_symbol, quantity, price): +def sell_stock(account, quantity, price): """Execute a stock sale and update the user's account. This function processes the sale of a specific quantity of a stock at a given price. @@ -10,9 +10,7 @@ def sell_stock(account, stock_symbol, quantity, price): account : dict A dictionary representing the user's account. Expected keys include: - 'balance': float, the current cash balance in the account. - - 'stocks': dict, mapping stock symbols to the number of shares held. - stock_symbol : str - The symbol of the stock being sold (e.g., 'AAPL', 'GOOG'). + - 'stocks': int, the number of shares held. quantity : int The number of shares to sell. Must not exceed the number of shares currently held. price : float @@ -30,10 +28,4 @@ def sell_stock(account, stock_symbol, quantity, price): Examples -------- - >>> account = {'balance': 1000.0, 'stocks': {'AAPL': 10}} - >>> sell(account, 'AAPL', 5, 150.0) - {'balance': 1750.0, 'stocks': {'AAPL': 5}} - - >>> sell(account, 'AAPL', 10, 150.0) - ValueError: Not enough shares to sell. """ diff --git a/src/traders_copilot_mzza_25/simulate_market_data.py b/src/traders_copilot_mzza_25/simulate_market_data.py new file mode 100644 index 0000000..50e5537 --- /dev/null +++ b/src/traders_copilot_mzza_25/simulate_market_data.py @@ -0,0 +1,14 @@ +def simulate_market_data(start_date): + """Simulate stock market data that contains date and price columns + from start date until today. + + + Parameters: + ---------- + start_date: Start date of the simulation (YYYY-MM-DD). + + Returns: + ---------- + pd.DataFrame + The dataframe that contains columns for stock market data. + """ \ No newline at end of file