Share your repls and programming experiences

← Back to all posts
Task_1
DivyanshaSharma (0)

From ae103672ec15db52ca6df9e496fcb901d40c6dea Mon Sep 17 00:00:00 2001
From: Divyansha_Sharma [email protected]
Date: Fri, 22 May 2020 10:24:52 +0000
Subject: [PATCH] Create Patch File


pycache/client3.cpython-38.pyc | Bin 0 -> 1088 bytes
client3.py | 34 +++++++++++++----------------
2 files changed, 15 insertions(+), 19 deletions(-)
create mode 100644 pycache/client3.cpython-38.pyc

diff --git a/pycache/client3.cpython-38.pyc b/pycache/client3.cpython-38.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..8ec63ba80e09c86ccbf3444acf171dcf4dbaa897
GIT binary patch
literal 1088
zcmYjQO>f&a7$zl3mJ>T(|pY6g*[email protected]<g05L(mWOFk-8~n6GUmlIW21 zux8FF!+wWz+~3$?wzVC)ca05?G?QQrSN|875Vac$T$7|2EkGOSajN5%PB%d^oxo
zJVUX6qEbZBiU=BPB%)wr5eLfzQ;|qiEK<c(@+%P?m8uTf47w^ii_9Oe0qGSzBtQNv
zHX&a1fS&eOTac_i0=8n;<eFa7)t%OgyCo6Za2IP2#69T1y({_y6FXv8?1_EYhi%w-
zLf~W7g&o+1J=mYHJ#s}UId
=dfDE?P=76B?4aimW|J=8Vz9xD9J)VUeUwkriZax|g
zD?OIgOj|d4eDL^Sc)kGh?#og={[email protected]<-4zb&c-h>CGP
zdKrb7-Nx}UTE_cCCHKiCThcaKvI)a((u)y)VYFI|[email protected]<V10Lz
zQ)s|QhecdTC+E6s9QTQJdVJ<PPS1;zQu$<V$}y~CY0utA
kVq7GO4t5dE%4vg?3=t
zwC~~%#k#(WwQJY3r~93lOH>[email protected]&YYE1t(!w^qta75Je}7?
zjVGv}-r[email protected]([email protected]%fX1#P%&aYpap
Q2J7xpCXe&1n5r0=zruEUBV+
zb$WtMu3;}KH5AwHZ3Qi$2=09aE3zOI45CZt$JAJGwkD)bfwNQvMDM;Gs>vh3bRE~ z%d#noi~MB^j^[email protected]&i877g<;jvp)Xn>qcJo+Xdh^>XG zsBKK0lY-kiF6%%[email protected]+wMbsRIePWIr^f+>+g2J`Ls9qytES7ddQrz
zqI0um2iMedXnZ=+rk2h#15)`k5Nk!cZqndmCV^([email protected]*sCq;VfW)G}?>I6Yaj
g{A=!EJu|gPWZ(vW>MD7k=hnh+NBHM)#us0JvQb4FCWD

literal 0
HcmV?d00001

diff --git a/client3.py b/client3.py
index f1771c3..ade781b 100644
--- a/client3.py
+++ b/client3.py
@@ -35,25 +35,21 @@ def getDataPoint(quote):
stock = quote['stock']
bid_price = float(quote['top_bid'])
ask_price = float(quote['top_ask'])

  • 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 ------------- """
  • """ Also create some unit tests for this function in client_test.py """
  • return 1

-# Main

-if name == "main":

  • Query the price once every N seconds.

  • for _ in iter(range(N)):
  • quotes = json.loads(urllib.request.urlopen(QUERY.format(random.random())).read())
  • """ ----------- Update to get the ratio --------------- """
  • for quote in quotes:
  • 	stock, bid_price, ask_price, price = getDataPoint(quote)
  • 	print ("Quoted %s at (bid:%s, ask:%s, price:%s)" % (stock, bid_price, ask_price, price))
  • print ("Ratio %s" % getRatio(price, price))
  • if (price_b == 0):
  • return
  • return price_a/price_b

+if name=="main":

  • for _ in range(N):
  • quotes = json.loads(urllib.request.urlopen(QUERY.format(random.random())).read())
  • prices = {}
  • for quote in quotes:
  •  stock,bid_price,ask_price,price = getDataPoint(quote)
  •  prices[stock]=price
  •  print("Quoted %s at (bid:%s, ask: %s, prices:%s)" % (stock, bid_price , ask_price, price))
  • print("Ratio %s" % getRatio(prices['ABC'],prices['DEF']))
    \ No newline at end of file
    --
    2.17.1