Git Product home page Git Product logo

jpmc-tech-task-1-py3's Introduction


Task Overview | Installation Instructions | Link to Module 1 | JP Morgan Chase & Co Software Engineering Virtual Experience

Introduction

Experience Technology at JP Morgan Chase & Co

Try out what real work is like in the technology team at JP Morgan Chase & Co. Fast track to the tech team with your work.

Module 1 Task Overview

Interface with a stock price data feed and set up your system for analysis of the data

Aim: We want to process the data feed of stock A and stock B’s price to enable us to analyse when trading for the stock should occur.

  1. Please clone this repository to start the task
  2. Adjust the getRatio, getDataPoint and main functions
  3. Bonus: Pass all unit tests and add more to cover edge cases
  4. Upload a git patch file as the submission to this task

Set up / Installation

In order to get the server and client application code working on your machine, follow the setup here

Note:This is the Python 3 version of the JPM 1 exercise. The Python 2.7 version is in this other repo

How to Run

To start the server, run
python server3.py

this will create random market called 'test.csv' in your working directory if one does not already exist.

If you encounter an issue with datautil.parser, run this command:

pip install python-dateutil

If you don't have pip yet, you can install it from: https://pip.pypa.io/en/stable/installing/

To start the example client, run:

python client3.py

To unit test the example client, run: python client_test.py

How to request from the server using curl

Query:
$ curl 'http://localhost:8080/query?id=1'
{"id": "1", "top_ask": {"price": 129.18, "size": 70}, "timestamp": "2016-08-06 12:32:11.821574", "top_bid": {"price": 128.79, "size": 61}}

How to fix the code to meet objectives

To make the changes necessary to complete the objectives of this task, follow this guide.

To do the bonus task, read this.

How to submit your work

A patch file is what is required from you to submit. To create a patch file, follow this guide. Then submit the patch file in the JPM Module 1 Page.

jpmc-tech-task-1-py3's People

Contributors

jbf-insidesherpa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jpmc-tech-task-1-py3's Issues

Server3.py file not running properly

When I tried running server3.py, the phrase "HTTP server started on port 8080" was the only thing that showed up. Nothing else happened after an hour so I tried the suggested workarounds in the troubleshooting guidelines (i.e. removed the firewall and changed port to 8085) but the same thing is showing up. I've attached a couple screenshots of Terminal.
screenshot
screenshot2

Issue with Client3.py server

I was able to complete the installation and set-up for the server environment; however, this is the error I encounter when I follow the same steps for the client server. I am working on Python 3.8.0.
error

'float' object is not subscriptable

Dear Supervisor,

when I execute the patch file ’python client3. py‘ which has been modified in accordance with the guide,it shows that Type Error :'float' object is not subscript-able at line 46. The Type Error is in the module "print ("Ratio %s" % getRatio(price['DEF'], price['ABC']))".
image
image

Thank you for your kind help.

Best Regards,
RD

Port already in USE error

I have python 3.6.x version installed.
When I am executing python server3.py command in the path /JPMC-tech-task-1-py3$ I am getting below error even after killing currently running process several times:

OSError: [Errno 98] Address already in use

Server not starting

After moving to Desktop\JPMC-tech-task-1-py3> when I use python3 server3.py nothing happens it just move to the next line which is same as of the previous Desktop\JPMC-tech-task-1-py3>
.Now what to do am stuck?

Server3.py & Client3.py not working

When it try to run server3.py, the only thing that showed up was "HTTP server started on port 8080", I followed the advice to change the port to 8085 & remove the firewall, but the same thing still happened

server3

When I try to run client3.py, the following happens:
client3 part 1
client3 part 2

Error in server3.py

File "C:\Users\tikam suvasiyA\jpmorgan\JPMC-tech-task-1-py3\server3.py", line 26, in
import dateutil.parser
File "C:\Users\watson\DJANgo~1\env\lib\site-packages\dateutil\parser.py", line 158
l.append("%s=%s" % (attr, value))
^
SyntaxError: invalid syntax

dateutil installation problem

I tried going through the dependency troubleshooting slides but to no avail.
Here are my steps:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Result:
Screen Shot 2020-04-18 at 1 08 57 AM

Then, I do
python3 get-pip.py

Result:
Screen Shot 2020-04-18 at 1 10 07 AM

Finally, I run
pip3 install python-dateutil

But after I try
python3 server3.py

I still get the same error message. I've tried reinstalling and installing pip but nothing has worked. Thanks in advance for your help.

Can't open server.py and client.py

I have python 3.8.1 installed on my system. I am trying to run server and client using python server.py and python client.py but I am getting errors like No such directory. How to resolve this error?
Screenshot (86)

NameError: Prices is not defined

I followed the instructions precisely and I got a name error that prices is not defined

  File "client3.py", line 60, in <module>
    print ("Ratio %s" % (getRatio(prices['ABC'], prices['DEF'])))
NameError: name 'prices' is not defined```

problem in patching in cmd .

JPMC-tech-task-1-py3>git commit -m 'Create Patch File"
error: pathspec 'Patch' did not match any file(s) known to git
error: pathspec 'File' did not match any file(s) known to git

i'm getting error in the server3.py

File "C:\Users\tikam suvasiyA\jpmorgan\JPMC-tech-task-1-py3\server3.py", line 26, in
import dateutil.parser
File "C:\Users\watson\DJANgo~1\env\lib\site-packages\dateutil\parser.py", line 158
l.append("%s=%s" % (attr, value))
^
SyntaxError: invalid syntax

OS Error for "python server3.py"

I already had python and git installed in my windows system, yet I installed everything from start to end. But I am getting and OSError as shown in the image while running "python server3.py
JPM
"

A huge exception occured on running client3.py

This issue occured when i was setting up environment to do tasks (task 1).
Help me to fix it. I am a beginner.

C:\Users\Shivani>cd JPMC-tech-task-1-py3

C:\Users\Shivani\JPMC-tech-task-1-py3>python client3.py
Traceback (most recent call last):
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1319, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1230, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1276, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1225, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1004, in _send_output
self.send(msg)
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 944, in send
self.connect()
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 915, in connect
self.sock = self._create_connection(
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\socket.py", line 808, in create_connection
raise err
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\socket.py", line 796, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "client3.py", line 52, in
quotes = json.loads(urllib.request.urlopen(QUERY.format(random.random())).read())
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1348, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\Shivani\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1322, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>

C:\Users\Shivani\JPMC-tech-task-1-py3>
Screenshot (25)

Error running client3.py

I got the server to run locally but I get the following error when trying to run the client.

clientError

Is this due to my python installation? The troubleshooter on the slides gave a walkthrough for server.py but I don't see anything for client.py

Server is not running

This what Isee when I type python server3.py

Traceback (most recent call last):
File "server3.py", line 320, in
run(App())
File "server3.py", line 214, in run
server = ThreadedHTTPServer((host, port), RequestHandler)
File "/home/bideen/anaconda3/lib/python3.7/socketserver.py", line 452, in init
self.server_bind()
File "/home/bideen/anaconda3/lib/python3.7/http/server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File "/home/bideen/anaconda3/lib/python3.7/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

HTTP Error 401: Unauthorized

Each Time I run my Server-Side Code with Admin CMD, This shows up-
Traceback (most recent call last):
File "client3.py", line 52, in
quotes = json.loads(urllib.request.urlopen(QUERY.format(random.random())).read())
File "D:\Program Files\Anaconda\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "D:\Program Files\Anaconda\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "D:\Program Files\Anaconda\lib\urllib\request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "D:\Program Files\Anaconda\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "D:\Program Files\Anaconda\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "D:\Program Files\Anaconda\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

No response

When i type python3 client3.py cmd give me no response.
Screenshot (15)

InsideSherpa>JPMC-tech-task-1py3 on Windows 10

I am trying to install the dependencies for Windows 10, and I have accomplished the following task successfully assuming that the Command Prompt is running as an Administrator:

  • git clone https://github.com/insidesherpa/JPMC-tech-task-1-py3.git

  • python --version is Python 3.4.0

  • python3 get-pip.py

  • To install the dateutil I had to do: python -m pip install python-dateutil
    image

  • Then running the server as: python server3.py
    image

  • Then the error comes when I ran the client as an administrator: python client3.py
    image

  • I ran the client_test.py:
    image

Looks like I'm connected to the server because it is receiving queries, but I'm not sure If I'm done with the whole process, Can anyone help me please?

TypeError: a bytes-like object is required, not 'str'

Getting this issue while running python server3.py

Traceback (most recent call last):
  File "f:/JP Morgan Chase/JPMC-tech-task-1-py3/server3.py", line 319, in <module>
    generate_csv()
  File "f:/JP Morgan Chase/JPMC-tech-task-1-py3/server3.py", line 151, in generate_csv
    writer.writerow([t, stock, side, order, size])
TypeError: a bytes-like object is required, not 'str'

urlopen error [WinError 10061]

Hi, when I try to run the client3.py script from the cmd line (as admin), I get the error:
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>

Issues with python server3.py

I installed python 3, and was able to run all the commands signed in as an administrator. I also was able to successfully install pip and its dependencies because when running the python server command i was getting the dateutil error. I followed how to install pip, and now i see what version I have but when I run the server3 command i get the below error
image

Wrong data value in client_test.py

In the test_getDataPoint_calculatePriceBidGreaterThanAsk method of client_test.py, for the second quote, bid_price=117.87 and ask_price=121.68, but according to the method bid_price should be > ask_price, here reverse is happening.

unknown issue with setting up development environment

Exception happened during processing of request from ('127.0.0.1', 63786)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 599, in process_request_thread
self.finish_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 655, in init
self.handle()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "server3.py", line 213, in do_GET
get(self, routes)
File "server3.py", line 202, in get
req_handler.wfile.write(bytes(data, encoding = 'utf-8'))
TypeError: str() takes at most 1 argument (2 given)

Missing requirements.txt

I think it would be a good idea to add a requirements.txt file for easy setup

These are the requirements I think are necessary
python-dateutil==2.8.1
six==1.14.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.