SlideShare una empresa de Scribd logo
1 de 15
JPMorgan Chase Software Engineering Virtual Experience
Task 1 - software engineering
task : code changes
Module 1 - Interface with a stock price data feed and
create tests for it
Setting up your dev environment for the program!
Disclaimer
● This guide is only for those who did the setup locally on their machines.
● For those using REPL, see the REPL guide in the Instructions file of your
REPL environment
Setting up your dev environment for the program!
Prerequisite
● Set up should have been done. This means,your server and client
applications should have been running with no problems without introducing
any changes to the code yet. You can verify this if you get a similar result to
any of the following slides that include a picture of the server and client app
running together
Setting up your dev environment for the program!
Prerequisite
Mac OS (left side server, right side client)
Setting up your dev environment for the program!
Prerequisite
Windows OS (left side server, right side client)
Setting up your dev environment for the program!
Prerequisite
Linux OS (left side server, right side client)
Setting up your dev environment for the program!
Objectives
● If you closely inspect the output of the client applications in the previous
slides, there are two incorrect things…
○ (1) Ratio is always 1
○ (2) The price of each stock is always the same as its bid_price.
● These are obviously wrong so you job is to fix those things…
● Don’t worry we’ll walk you through how to get these things done
Setting up your dev environment for the program!
How to make changes to code
● You’ll be making changes to the code in the some of the files within the
repository you cloned or downloaded to achieve the objectives the task.
● To do this, you can use any text editor your machine has and just open the
files in the repository that must be changed (the guide will instruct you in the
following slides which files these will be)
● Our recommendation of editors you can use would be VSCode or
SublimeText as these are the most commonly used code editors out there.
Setting up your dev environment for the program!
Making changes in `client.py` (client3.py for python3)
● All the changes you have make to get the right output will be in the client.py
file inside the repository (client3.py if you’re in python3 REPL)
● The changes you need to make will be in the following methods of the file
○ getDataPoint
○ getRatio
○ Main
● The changes for each method will be dissected for each method on the next
slide
Setting up your dev environment for the program!
Making changes in `client.py` (client3.py for python3)
getDataPoint
getDataPoint. In this method, you'll have to make the modifications to compute
for the right stock price. This means you have to change how `price` is computed
for. The formula is (bid_price+ask_price) / 2.
YOU DO NOT NEED TO CHANGE the return value as that is representational of
the entire data point. You should end up with something like:
Setting up your dev environment for the program!
Making changes in `client.py` (client3.py for python3)
getRatio
getRatio. In the original case, this method just returns 1 all the time. To correct
this, you must change the return value to the ratio of stock price_a to stock
price_b
note: that we’ve also added the condition of the case where in price_b could be zero, i.e. division by zero,
in the rare chance that it might happen...
Setting up your dev environment for the program!
Making changes in `client.py` (client3.py for python3)
main
main method. Now that you've fixed the two other methods, it's just a matter of
printing the correct values. For every iteration in the main method, you need to
store the datapoints you get from getDataPoint method so that you can properly
call getRatio and print the right ratio out. (the below image is for python 2.7.x version)
Setting up your dev environment for the program!
Making changes in `client.py` (client3.py for python3)
main
main method. (the image here is now for python 3.x version)
There’s also a slight difference in the urllib that’s used
for python3 but you don’t have to bother with this
Setting up your dev environment for the program!
Making changes in `client.py` (client3.py for python3)
main
● To review the changes in main (whether it was in python2 or python3), what we did
was create a prices dictionary to store the stock prices. Think of a dictionary
as a key-value store wherein you can specify a key and be able to retrieve a
value. In our case, they key was the stock name and the value was the price.
● We then used this prices dictionary at the end to pass in the right values in
the getRatio function.
Setting up your dev environment for the program!
Next step
● You’re done with the main task. You can either create your patch file now by
following this guide, or try and do the bonus task first

Más contenido relacionado

Similar a making_changes_m1_v4a.pdf

Installation of PC-Lint and its using in Visual Studio 2005
Installation of PC-Lint and its using in Visual Studio 2005Installation of PC-Lint and its using in Visual Studio 2005
Installation of PC-Lint and its using in Visual Studio 2005PVS-Studio
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox testsKevin Beeman
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmerLeylimYaln
 
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...Intel® Software
 
Trunk based development
Trunk based developmentTrunk based development
Trunk based developmentgo_oh
 
Patch File.pdf
Patch File.pdfPatch File.pdf
Patch File.pdfvilaylala
 
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxCASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxketurahhazelhurst
 
Optimize creative and design workflows and enjoy a better user experience wit...
Optimize creative and design workflows and enjoy a better user experience wit...Optimize creative and design workflows and enjoy a better user experience wit...
Optimize creative and design workflows and enjoy a better user experience wit...Principled Technologies
 
MOAC 70-687 - Configuring Windows 8.1 MLO WorksheetLab 10Confi.docx
MOAC 70-687 - Configuring Windows 8.1 MLO WorksheetLab 10Confi.docxMOAC 70-687 - Configuring Windows 8.1 MLO WorksheetLab 10Confi.docx
MOAC 70-687 - Configuring Windows 8.1 MLO WorksheetLab 10Confi.docxraju957290
 
Reproducible Research in R and R Studio
Reproducible Research in R and R StudioReproducible Research in R and R Studio
Reproducible Research in R and R StudioSusan Johnston
 
Guvnor presentation jervis liu
Guvnor presentation jervis liuGuvnor presentation jervis liu
Guvnor presentation jervis liujbossug
 
Introduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerIntroduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerNaoto Ono
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsnoahjamessss
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringscskvsmi44
 
Python Environment Variables A Step-by-Step Tutorial for Beginners
Python Environment Variables A Step-by-Step Tutorial for BeginnersPython Environment Variables A Step-by-Step Tutorial for Beginners
Python Environment Variables A Step-by-Step Tutorial for BeginnersInexture Solutions
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 
Qtp interview questions_1
Qtp interview questions_1Qtp interview questions_1
Qtp interview questions_1Ramu Palanki
 

Similar a making_changes_m1_v4a.pdf (20)

Installation of PC-Lint and its using in Visual Studio 2005
Installation of PC-Lint and its using in Visual Studio 2005Installation of PC-Lint and its using in Visual Studio 2005
Installation of PC-Lint and its using in Visual Studio 2005
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox tests
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmer
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
Tuning For Deep Learning Inference with Intel® Processor Graphics | SIGGRAPH ...
 
20150422 repro resr
20150422 repro resr20150422 repro resr
20150422 repro resr
 
Trunk based development
Trunk based developmentTrunk based development
Trunk based development
 
Patch File.pdf
Patch File.pdfPatch File.pdf
Patch File.pdf
 
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxCASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
 
Optimize creative and design workflows and enjoy a better user experience wit...
Optimize creative and design workflows and enjoy a better user experience wit...Optimize creative and design workflows and enjoy a better user experience wit...
Optimize creative and design workflows and enjoy a better user experience wit...
 
MOAC 70-687 - Configuring Windows 8.1 MLO WorksheetLab 10Confi.docx
MOAC 70-687 - Configuring Windows 8.1 MLO WorksheetLab 10Confi.docxMOAC 70-687 - Configuring Windows 8.1 MLO WorksheetLab 10Confi.docx
MOAC 70-687 - Configuring Windows 8.1 MLO WorksheetLab 10Confi.docx
 
Reproducible Research in R and R Studio
Reproducible Research in R and R StudioReproducible Research in R and R Studio
Reproducible Research in R and R Studio
 
Guvnor presentation jervis liu
Guvnor presentation jervis liuGuvnor presentation jervis liu
Guvnor presentation jervis liu
 
Introduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerIntroduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debugger
 
Vedic Calculator
Vedic CalculatorVedic Calculator
Vedic Calculator
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Python Environment Variables A Step-by-Step Tutorial for Beginners
Python Environment Variables A Step-by-Step Tutorial for BeginnersPython Environment Variables A Step-by-Step Tutorial for Beginners
Python Environment Variables A Step-by-Step Tutorial for Beginners
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
Qtp interview questions_1
Qtp interview questions_1Qtp interview questions_1
Qtp interview questions_1
 

Último

Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...vershagrag
 
CBD Belapur((Thane)) Charming Call Girls📞❤9833754194 Kamothe Beautiful Call G...
CBD Belapur((Thane)) Charming Call Girls📞❤9833754194 Kamothe Beautiful Call G...CBD Belapur((Thane)) Charming Call Girls📞❤9833754194 Kamothe Beautiful Call G...
CBD Belapur((Thane)) Charming Call Girls📞❤9833754194 Kamothe Beautiful Call G...priyasharma62062
 
Benefits & Risk Of Stock Loans
Benefits & Risk Of Stock LoansBenefits & Risk Of Stock Loans
Benefits & Risk Of Stock LoansMartinRowse
 
Pension dashboards forum 1 May 2024 (1).pdf
Pension dashboards forum 1 May 2024 (1).pdfPension dashboards forum 1 May 2024 (1).pdf
Pension dashboards forum 1 May 2024 (1).pdfHenry Tapper
 
Technology industry / Finnish economic outlook
Technology industry / Finnish economic outlookTechnology industry / Finnish economic outlook
Technology industry / Finnish economic outlookTechFinland
 
Q1 2024 Conference Call Presentation vF.pdf
Q1 2024 Conference Call Presentation vF.pdfQ1 2024 Conference Call Presentation vF.pdf
Q1 2024 Conference Call Presentation vF.pdfAdnet Communications
 
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...priyasharma62062
 
Significant AI Trends for the Financial Industry in 2024 and How to Utilize Them
Significant AI Trends for the Financial Industry in 2024 and How to Utilize ThemSignificant AI Trends for the Financial Industry in 2024 and How to Utilize Them
Significant AI Trends for the Financial Industry in 2024 and How to Utilize Them360factors
 
20240419-SMC-submission-Annual-Superannuation-Performance-Test-–-design-optio...
20240419-SMC-submission-Annual-Superannuation-Performance-Test-–-design-optio...20240419-SMC-submission-Annual-Superannuation-Performance-Test-–-design-optio...
20240419-SMC-submission-Annual-Superannuation-Performance-Test-–-design-optio...Henry Tapper
 
Female Escorts Service in Hyderabad Starting with 5000/- for Savita Escorts S...
Female Escorts Service in Hyderabad Starting with 5000/- for Savita Escorts S...Female Escorts Service in Hyderabad Starting with 5000/- for Savita Escorts S...
Female Escorts Service in Hyderabad Starting with 5000/- for Savita Escorts S...kajalverma014
 
7 steps to achieve financial freedom.pdf
7 steps to achieve financial freedom.pdf7 steps to achieve financial freedom.pdf
7 steps to achieve financial freedom.pdfthemoneyacademy07
 
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdfMASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdfCocity Enterprises
 
Call Girls in Benson Town / 8250092165 Genuine Call girls with real Photos an...
Call Girls in Benson Town / 8250092165 Genuine Call girls with real Photos an...Call Girls in Benson Town / 8250092165 Genuine Call girls with real Photos an...
Call Girls in Benson Town / 8250092165 Genuine Call girls with real Photos an...kajal
 
Mahendragarh Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Mahendragarh Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsMahendragarh Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Mahendragarh Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDeepika Singh
 
Fixed exchange rate and flexible exchange rate.pptx
Fixed exchange rate and flexible exchange rate.pptxFixed exchange rate and flexible exchange rate.pptx
Fixed exchange rate and flexible exchange rate.pptxTintoTom3
 
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.In Sharjah ௵(+971)558539980 *_௵abortion pills now available.
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.hyt3577
 
Certified Kala Jadu, Black magic specialist in Rawalpindi and Bangali Amil ba...
Certified Kala Jadu, Black magic specialist in Rawalpindi and Bangali Amil ba...Certified Kala Jadu, Black magic specialist in Rawalpindi and Bangali Amil ba...
Certified Kala Jadu, Black magic specialist in Rawalpindi and Bangali Amil ba...batoole333
 
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...priyasharma62062
 

Último (20)

Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
Premium Call Girls Bangalore Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
CBD Belapur((Thane)) Charming Call Girls📞❤9833754194 Kamothe Beautiful Call G...
CBD Belapur((Thane)) Charming Call Girls📞❤9833754194 Kamothe Beautiful Call G...CBD Belapur((Thane)) Charming Call Girls📞❤9833754194 Kamothe Beautiful Call G...
CBD Belapur((Thane)) Charming Call Girls📞❤9833754194 Kamothe Beautiful Call G...
 
Call Girls in Tilak Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Tilak Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in Tilak Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Tilak Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Benefits & Risk Of Stock Loans
Benefits & Risk Of Stock LoansBenefits & Risk Of Stock Loans
Benefits & Risk Of Stock Loans
 
Pension dashboards forum 1 May 2024 (1).pdf
Pension dashboards forum 1 May 2024 (1).pdfPension dashboards forum 1 May 2024 (1).pdf
Pension dashboards forum 1 May 2024 (1).pdf
 
Technology industry / Finnish economic outlook
Technology industry / Finnish economic outlookTechnology industry / Finnish economic outlook
Technology industry / Finnish economic outlook
 
W.D. Gann Theory Complete Information.pdf
W.D. Gann Theory Complete Information.pdfW.D. Gann Theory Complete Information.pdf
W.D. Gann Theory Complete Information.pdf
 
Q1 2024 Conference Call Presentation vF.pdf
Q1 2024 Conference Call Presentation vF.pdfQ1 2024 Conference Call Presentation vF.pdf
Q1 2024 Conference Call Presentation vF.pdf
 
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...
2999,Vashi Fantastic Ellete Call Girls📞📞9833754194 CBD Belapur Genuine Call G...
 
Significant AI Trends for the Financial Industry in 2024 and How to Utilize Them
Significant AI Trends for the Financial Industry in 2024 and How to Utilize ThemSignificant AI Trends for the Financial Industry in 2024 and How to Utilize Them
Significant AI Trends for the Financial Industry in 2024 and How to Utilize Them
 
20240419-SMC-submission-Annual-Superannuation-Performance-Test-–-design-optio...
20240419-SMC-submission-Annual-Superannuation-Performance-Test-–-design-optio...20240419-SMC-submission-Annual-Superannuation-Performance-Test-–-design-optio...
20240419-SMC-submission-Annual-Superannuation-Performance-Test-–-design-optio...
 
Female Escorts Service in Hyderabad Starting with 5000/- for Savita Escorts S...
Female Escorts Service in Hyderabad Starting with 5000/- for Savita Escorts S...Female Escorts Service in Hyderabad Starting with 5000/- for Savita Escorts S...
Female Escorts Service in Hyderabad Starting with 5000/- for Savita Escorts S...
 
7 steps to achieve financial freedom.pdf
7 steps to achieve financial freedom.pdf7 steps to achieve financial freedom.pdf
7 steps to achieve financial freedom.pdf
 
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdfMASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
MASTERING FOREX: STRATEGIES FOR SUCCESS.pdf
 
Call Girls in Benson Town / 8250092165 Genuine Call girls with real Photos an...
Call Girls in Benson Town / 8250092165 Genuine Call girls with real Photos an...Call Girls in Benson Town / 8250092165 Genuine Call girls with real Photos an...
Call Girls in Benson Town / 8250092165 Genuine Call girls with real Photos an...
 
Mahendragarh Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Mahendragarh Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsMahendragarh Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Mahendragarh Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
Fixed exchange rate and flexible exchange rate.pptx
Fixed exchange rate and flexible exchange rate.pptxFixed exchange rate and flexible exchange rate.pptx
Fixed exchange rate and flexible exchange rate.pptx
 
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.In Sharjah ௵(+971)558539980 *_௵abortion pills now available.
In Sharjah ௵(+971)558539980 *_௵abortion pills now available.
 
Certified Kala Jadu, Black magic specialist in Rawalpindi and Bangali Amil ba...
Certified Kala Jadu, Black magic specialist in Rawalpindi and Bangali Amil ba...Certified Kala Jadu, Black magic specialist in Rawalpindi and Bangali Amil ba...
Certified Kala Jadu, Black magic specialist in Rawalpindi and Bangali Amil ba...
 
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...
Virar Best Sex Call Girls Number-📞📞9833754194-Poorbi Nalasopara Housewife Cal...
 

making_changes_m1_v4a.pdf

  • 1. JPMorgan Chase Software Engineering Virtual Experience Task 1 - software engineering task : code changes Module 1 - Interface with a stock price data feed and create tests for it
  • 2. Setting up your dev environment for the program! Disclaimer ● This guide is only for those who did the setup locally on their machines. ● For those using REPL, see the REPL guide in the Instructions file of your REPL environment
  • 3. Setting up your dev environment for the program! Prerequisite ● Set up should have been done. This means,your server and client applications should have been running with no problems without introducing any changes to the code yet. You can verify this if you get a similar result to any of the following slides that include a picture of the server and client app running together
  • 4. Setting up your dev environment for the program! Prerequisite Mac OS (left side server, right side client)
  • 5. Setting up your dev environment for the program! Prerequisite Windows OS (left side server, right side client)
  • 6. Setting up your dev environment for the program! Prerequisite Linux OS (left side server, right side client)
  • 7. Setting up your dev environment for the program! Objectives ● If you closely inspect the output of the client applications in the previous slides, there are two incorrect things… ○ (1) Ratio is always 1 ○ (2) The price of each stock is always the same as its bid_price. ● These are obviously wrong so you job is to fix those things… ● Don’t worry we’ll walk you through how to get these things done
  • 8. Setting up your dev environment for the program! How to make changes to code ● You’ll be making changes to the code in the some of the files within the repository you cloned or downloaded to achieve the objectives the task. ● To do this, you can use any text editor your machine has and just open the files in the repository that must be changed (the guide will instruct you in the following slides which files these will be) ● Our recommendation of editors you can use would be VSCode or SublimeText as these are the most commonly used code editors out there.
  • 9. Setting up your dev environment for the program! Making changes in `client.py` (client3.py for python3) ● All the changes you have make to get the right output will be in the client.py file inside the repository (client3.py if you’re in python3 REPL) ● The changes you need to make will be in the following methods of the file ○ getDataPoint ○ getRatio ○ Main ● The changes for each method will be dissected for each method on the next slide
  • 10. Setting up your dev environment for the program! Making changes in `client.py` (client3.py for python3) getDataPoint getDataPoint. In this method, you'll have to make the modifications to compute for the right stock price. This means you have to change how `price` is computed for. The formula is (bid_price+ask_price) / 2. YOU DO NOT NEED TO CHANGE the return value as that is representational of the entire data point. You should end up with something like:
  • 11. Setting up your dev environment for the program! Making changes in `client.py` (client3.py for python3) getRatio getRatio. In the original case, this method just returns 1 all the time. To correct this, you must change the return value to the ratio of stock price_a to stock price_b note: that we’ve also added the condition of the case where in price_b could be zero, i.e. division by zero, in the rare chance that it might happen...
  • 12. Setting up your dev environment for the program! Making changes in `client.py` (client3.py for python3) main main method. Now that you've fixed the two other methods, it's just a matter of printing the correct values. For every iteration in the main method, you need to store the datapoints you get from getDataPoint method so that you can properly call getRatio and print the right ratio out. (the below image is for python 2.7.x version)
  • 13. Setting up your dev environment for the program! Making changes in `client.py` (client3.py for python3) main main method. (the image here is now for python 3.x version) There’s also a slight difference in the urllib that’s used for python3 but you don’t have to bother with this
  • 14. Setting up your dev environment for the program! Making changes in `client.py` (client3.py for python3) main ● To review the changes in main (whether it was in python2 or python3), what we did was create a prices dictionary to store the stock prices. Think of a dictionary as a key-value store wherein you can specify a key and be able to retrieve a value. In our case, they key was the stock name and the value was the price. ● We then used this prices dictionary at the end to pass in the right values in the getRatio function.
  • 15. Setting up your dev environment for the program! Next step ● You’re done with the main task. You can either create your patch file now by following this guide, or try and do the bonus task first