From e8f4987988774122c852e916a1ee38381c5316f5 Mon Sep 17 00:00:00 2001 From: Srikanth1817 <123906945+Srikanth1817@users.noreply.github.com> Date: Mon, 8 Jul 2024 00:27:08 -0500 Subject: [PATCH 1/4] Update client3.py --- client3.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client3.py b/client3.py index 3fc09b75f1..455f2d66c2 100644 --- a/client3.py +++ b/client3.py @@ -35,15 +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 if __name__ == "__main__": @@ -52,8 +53,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(price["ABC"], price["DEF"])) From ea164f6ec0f57ea5d4508ca8970c55a3c101b162 Mon Sep 17 00:00:00 2001 From: Srikanth1817 Date: Mon, 8 Jul 2024 00:35:39 -0500 Subject: [PATCH 2/4] Update client3.py --- client3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client3.py b/client3.py index 455f2d66c2..737a84361c 100644 --- a/client3.py +++ b/client3.py @@ -42,7 +42,7 @@ def getDataPoint(quote): def getRatio(price_a, price_b): """ Get ratio of price_a and price_b """ """ ------------- Update this function ------------- """ - if(price_b==0) + if(price_b ==0 ): return return price_a/price_b From 60c12048b25330ecc5bc4b2a1a11f59f41e58084 Mon Sep 17 00:00:00 2001 From: Srikanth1817 <123906945+Srikanth1817@users.noreply.github.com> Date: Mon, 8 Jul 2024 01:07:02 -0500 Subject: [PATCH 3/4] Update client3.py --- client3.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/client3.py b/client3.py index 737a84361c..3fc09b75f1 100644 --- a/client3.py +++ b/client3.py @@ -35,16 +35,15 @@ def getDataPoint(quote): stock = quote['stock'] bid_price = float(quote['top_bid']['price']) ask_price = float(quote['top_ask']['price']) - price = (bid_price + ask_price) / 2 + price = bid_price return stock, bid_price, ask_price, price def getRatio(price_a, price_b): """ Get ratio of price_a and price_b """ """ ------------- Update this function ------------- """ - if(price_b ==0 ): - return - return price_a/price_b + return 1 + # Main if __name__ == "__main__": @@ -53,10 +52,8 @@ 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["ABC"], price["DEF"])) + print("Ratio %s" % getRatio(price, price)) From 019c3ddafb996e1f7b9014c8cfddd19903384899 Mon Sep 17 00:00:00 2001 From: Srikanth1817 Date: Mon, 8 Jul 2024 01:23:20 -0500 Subject: [PATCH 4/4] client3 file updated --- 0001-Update-client3.py.patch | 48 ++++++++++++++++++++++++++++++++++++ client3.py | 10 +++++--- 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 0001-Update-client3.py.patch diff --git a/0001-Update-client3.py.patch b/0001-Update-client3.py.patch new file mode 100644 index 0000000000..9fc333536a --- /dev/null +++ b/0001-Update-client3.py.patch @@ -0,0 +1,48 @@ +From 60c12048b25330ecc5bc4b2a1a11f59f41e58084 Mon Sep 17 00:00:00 2001 +From: Srikanth1817 <123906945+Srikanth1817@users.noreply.github.com> +Date: Mon, 8 Jul 2024 01:07:02 -0500 +Subject: [PATCH] Update client3.py + +--- + client3.py | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/client3.py b/client3.py +index 737a843..3fc09b7 100644 +--- a/client3.py ++++ b/client3.py +@@ -35,16 +35,15 @@ def getDataPoint(quote): + stock = quote['stock'] + bid_price = float(quote['top_bid']['price']) + ask_price = float(quote['top_ask']['price']) +- price = (bid_price + ask_price) / 2 ++ price = bid_price + return stock, bid_price, ask_price, price + + + def getRatio(price_a, price_b): + """ Get ratio of price_a and price_b """ + """ ------------- Update this function ------------- """ +- if(price_b ==0 ): +- return +- return price_a/price_b ++ return 1 ++ + + # Main + if __name__ == "__main__": +@@ -53,10 +52,8 @@ if __name__ == "__main__": + 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["ABC"], price["DEF"])) ++ print("Ratio %s" % getRatio(price, price)) +-- +2.43.0.windows.1 + diff --git a/client3.py b/client3.py index 3fc09b75f1..109c6ed9b8 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"]))