Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED IT IN PYTHON ASAP PLEASEEEEE Many investment management companies are switching from manual stock trading (done by humans) to automatic stock trading (done

I NEED IT IN PYTHON ASAP PLEASEEEEE

Many investment management companies are switching from manual stock trading (done by humans) to automatic stock trading (done by computers). You've been tasked to write a simple automatic stock trader function that determines whether to buy, sell, or do nothing (hold) shares of a stock for a particular account. It should follow the old saying "Buy low, sell high!"

This function must make the decision (to buy, sell, or hold) based on the following information.

1.Current number of shares of this stock in the account

2.Price (per share) paid for current stock in the account

3.Current market price (per share) of this stock

4.Maximum amount the client is willing to spend on a purchase

Additional information

Any transaction (buy or sell) costs $10. Be sure to account for this fee in your profitability calculations.

In order for a purchase (buy) to be considered profitable, the current market price (per share) must lower than the price (per share) paid for current stock in the account. Additionally, the amount the client is willing to spend on a purchase must allow us to buy enough shares so that the difference in value will cover the $10 transaction fee.

In order for a sale (sell) to be considered profitable, the current market price (per share) must be higher than the price (per share) paid for current stock in the account. Additionally, the value gained by selling the shares must also cover the $10 transaction fee.

If neither a buy nor a sell would be profitable, then we should simply hold the existing shares.

Part 2 - Implementation

Now that you have taken the time to analyze the problem and to sketch a design for a solution, it is time to begin implementing your design. Use the design that you created for Part 1 of this challenge and implement your design in the form of a function that also meets the following specifications.

1.This function will have 4 input parameters in the following order.

2. Current number of shares of this stock in the account (int)

3. Price (per share) paid for current stock in the account (float)

4. Current market price (per share) of this stock (float)

5. Maximum amount the client is willing to spend on a purchase (float)

The function will return a str with one of the following formats (where # is an integer representing the number of shares to buy or sell).

1.Buy # shares

2.Sell # shares

3. Hold shares

Things to think about

Look for opportunities to use variables as a way to name things, and to break larger more complex expressions down into simpler expressions.

Spend some time choosing your names carefully. Names should be descriptive.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago