Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #48

Closed
brianw921 opened this issue Apr 17, 2020 · 2 comments
Closed

Issue #48

brianw921 opened this issue Apr 17, 2020 · 2 comments

Comments

@brianw921
Copy link

brianw921 commented Apr 17, 2020

When I entered in the directions for python3 as followed I got the following error

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

I then tried to search for the "prices" method/function and it's not there. 

Then I tried to access the price function, I get the following error.

```Traceback (most recent call last):
  File "client3.py", line 58, in <module>
    print ("Ratio %s" % (getRatio(price['ABC'], price['DEF'])))
TypeError: 'float' object is not subscriptable```


When I try to create a git patch file, it says that it is not a git repository

runner@9400d4b74689:~/JPM-MODULE1-PY3-REPL-2/jpm_module_1$ git add -A
fatal: not a git repository (or any parent up to mount point /home/runner)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).```

@harivansh0
Copy link

did you define dictionary price ={}

@kirankuyate2157
Copy link

first, think you have to define prieces={}
then while iterating Quotes that time add then stocks with their price
prices[stock] = price
this is a Tab error I think
PS D:\professional work\JpMorgan\JPMC-tech-task-1-py3> python client3.py
File "D:\professional work\JpMorgan\JPMC-tech-task-1-py3\client3.py", line 65
for quote in quotes:
terror: inconsistent use of tabs and spaces in indentation

You can you single space instead of Tabs (tabs may be spaces diff but after single spaces not going to be a problem 👍

Solution
`if name == "main":

# Query the price once every N seconds.
for _ in range(N):
    quotes = json.loads(urllib.request.urlopen(
        QUERY.format(random.random())).read())
    """ ----------- Update to get the ratio --------------- """
    prices = {}
    for quote in quotes:
        stock, bid_price, ask_price, price = getDataPoint(quote)
        prices[stock] = price
        print("Quoted %s at (bid:%s, ask:%s, price:%s)" %
              (stock, bid_price, ask_price, price))

    print("Ratio %s" % (getRatio(prices['ABC'], prices['DEF'])))

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants