代写 algorithm 7. EX4

7. EX4

I have a customer who trades stocks and would like to create a model which gives him information on the optimal buying and selling points for a stock. For this exercise, well assume that we are just collecting and processing the data to determine the best model. Also, for this exercise, well assume that the data is from a single day of trading.

Please write a program which examines the data provided and provides the best or best solutions to maximize profit. Use the data provided below in the table:

Date
Time
Start
Oct 01 2018
9:30:00 AM
227.95
Oct 01 2018
9:40:00 AM
224.79
Oct 01 2018
9:50:00 AM
223.82
Oct 01 2018
10:00:00 AM
221
Oct 01 2018
10:10:00 AM
219.75
Oct 01 2018
10:20:00 AM
216.82
Oct 01 2018
10:30:00 AM
220.78
Oct 01 2018
10:40:00 AM
220.24
Oct 01 2018
10:50:00 AM
218.5
Oct 01 2018
11:00:00 AM
217.79
Oct 01 2018
11:10:00 AM
222.15
Oct 01 2018
11:20:00 AM
225.75
Oct 01 2018
11:30:00 AM
223.52
Oct 01 2018
11:40:00 AM
224.94
Oct 01 2018
11:50:00 AM
218.01
Oct 01 2018
12:00:00 PM
220.95
Oct 01 2018
12:10:00 PM
221.85
Oct 01 2018
12:20:00 PM
226.23
Oct 01 2018
12:30:00 PM
228.99
Oct 01 2018
12:40:00 PM
228.41
Oct 01 2018
12:50:00 PM
226.51
Oct 01 2018
1:00:00 PM
226.51
Oct 01 2018
1:10:00 PM
223.25
Oct 01 2018
1:20:00 PM
220.15
Oct 01 2018
1:30:00 PM
219.01
Oct 01 2018
1:40:00 PM
217.15
Oct 01 2018
1:50:00 PM
216.6
Oct 01 2018
2:00:00 PM
214.65
Oct 01 2018
2:10:00 PM
214.1
Oct 01 2018
2:20:00 PM
216.8
Oct 01 2018
2:30:00 PM
218.1
Oct 01 2018
2:40:00 PM
213.44
Oct 01 2018
2:50:00 PM
211.75
Oct 01 2018
3:00:00 PM
209.22
Oct 01 2018
3:10:00 PM
210.155
Oct 01 2018
3:20:00 PM
207.7
Oct 01 2018
3:30:00 PM
207.36
Oct 01 2018
3:40:00 PM
207.28
Oct 01 2018
3:50:00 PM
206.05
Oct 01 2018
4:00:00 PM
209.32

9. EX. 6
We have a process where we receive data in a file which are required to process manually. We would like to automate this through the use of a program that will automatically read the data and process it, and then display the results to us in a report. Please provide the output from the execution of the code.

The format of the input file and the sample data to use is shown below.

14
2 2 1
2 3
4 5
2 2 2
3 11
11 3
4 2 3
4 4
5 5
6 6
55 99
3 3 4
3 5 a
4 7 a
3 4 b
3 2 5
3 3
4 5 c a
3 5 b
3 3 6
4 2 d
3 4 a
3 3 b
3 3 7
4 2 a
3 3 a
4
4 2 8
2 2
3 3
4 4
2 3 9
1 2 a
3 3 b
4 2 10
0 0
1 1
1 1
1111111 222222
3 3 11
2 3 12
3 6 13
3 005 a
4 .007 a
3 4 b
7 2 e
8 4 ffffff
1 1 aaaaaaa
2 2 14
a 0
b 01

The data is structured as follows.
The first record in the file will indicate the number of data samples to read.
The subsequent records will provide the specific data to process
The first record must contain two items that identify the data group to follow this can be considered the control record the items are separated by spaces
The first character of the control record must be a
The first number indicates the number of data records in the data group
The second number indicates the number of elements in the data group
The next set of records will be the actual data that needs to be processed and will contain any number of elements separated by spaces. You only need to use the applicable values.
If there is a discrepancy in the data counts, the entire set of data is to be rejected and an error message printed indicated which data group the error is in.
If there is any error, generate an error message and reject the entire data group.
Blank lines should not be processed

You are to process the data as follows:

If the data contains two parameters, perform the following calculations

Calculate the average of the two values and display with the following label AVG
Calculate the results of the following formula and display with the following label FORM

Result pi pi first value psi 2.44 second value32 3

Calculate the average of the Result calculated above from all the data points
The results must be displayed to 3 significant digits nnnn.000
Display the total number of records reads

If the data contains three parameters
Calculate the average of the three values and display with the following label AVG 33
Calculate the results of the following formula and display with the following label FORM 33

Result pi pi first value pi psi 2.44 second value32 3 zeta lookup using the following mapping second value loglookup using the following mapping from third parameter of input data

a 3.21
b 4.1
c 6,8

If a translation is not found, then use a as the default.
Calculate the average of the Result calculated above from all the data points
The results must be displayed to 3 significant digits nnnn.000
Display the total number of records reads

The constants pi,psi, and zeta are defined as follows:

Pi 3.14
Psi 6.84845
Zeta 4.26

You are more than welcome to add additional data to validate other error and test conditions. All code and output should be sent back so it can be reviewed and verified. If there are any questions, please feel free to contact us.
In this table you have the price of a stock at that time. For this model, lets only use the price at 10 minute intervals.

Develop an algorithm and print the best times to buy the stock and sell it to maximize the profit. Quantity is not a concern, only when to buy and when to sell.

The output expected should be similar to the following but feel free to provide alternatives:

Buy stock at 10:20 at 216.82 and Sell at 10:30 at 220.78
Buy stock at 11:00 at 217.79 and Sell at 11:20 at 225.75

You must have stock in hand to sell so no short selling.

Please provide the code and the output from the execution of the code