From 24707a7c3f267047838c97f07e5ff52284f7be6a Mon Sep 17 00:00:00 2001 From: Joe Ferrer Date: Wed, 1 Mar 2023 00:10:28 +1100 Subject: [PATCH 1/3] Rename client and server files --- client.py => client3.py | 0 server.py => server3.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename client.py => client3.py (100%) rename server.py => server3.py (100%) diff --git a/client.py b/client3.py similarity index 100% rename from client.py rename to client3.py diff --git a/server.py b/server3.py similarity index 100% rename from server.py rename to server3.py From 6292570a3cd4dd279e133c2f3ab00b1ed63b3c49 Mon Sep 17 00:00:00 2001 From: jeetc7 Date: Fri, 23 Feb 2024 17:37:27 -0500 Subject: [PATCH 2/3] First task --- client3.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client3.py b/client3.py index 3fc09b75f16..f7d16571410 100644 --- a/client3.py +++ b/client3.py @@ -35,14 +35,16 @@ def getDataPoint(quote): stock = quote['stock'] bid_price = float(quote['top_bid']['price']) ask_price = float(quote['top_ask']['price']) - price = bid_price + price = (bid_price + ask_price)/2 return stock, bid_price, ask_price, price def getRatio(price_a, price_b): """ Get ratio of price_a and price_b """ """ ------------- Update this function ------------- """ - return 1 + if(price_b==0): + return + return price_a/price_b # Main @@ -52,8 +54,10 @@ def getRatio(price_a, price_b): 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(price, price)) + print("Ratio %s" % getRatio(prices["ABC"], prices["DEF"])) From b567af9a8d18ef65d4e85c92c28974c14bc98d6a Mon Sep 17 00:00:00 2001 From: Jeet Date: Fri, 23 Feb 2024 17:45:49 -0500 Subject: [PATCH 3/3] First --- client3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client3.py b/client3.py index f7d16571410..1712f29cb20 100644 --- a/client3.py +++ b/client3.py @@ -54,7 +54,7 @@ def getRatio(price_a, price_b): quotes = json.loads(urllib.request.urlopen(QUERY.format(random.random())).read()) """ ----------- Update to get the ratio --------------- """ - prices={} + prices = {} for quote in quotes: stock, bid_price, ask_price, price = getDataPoint(quote) prices[stock] = price