-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from UBC-MDS/functions
Functions
- Loading branch information
Showing
5 changed files
with
48 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
-------- | ||
""" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
""" |