forked from theforage/forage-jpmc-swe-task-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0001-Updated-client3.py-file.patch
150 lines (141 loc) · 4.84 KB
/
0001-Updated-client3.py-file.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
From 1994a394b569fce36e27d257dbaa51ec656f2c54 Mon Sep 17 00:00:00 2001
From: AbhaBarge <[email protected]>
Date: Thu, 6 Jul 2023 21:20:52 +0530
Subject: [PATCH] Updated client3.py file
---
.idea/.gitignore | 3 +++
.idea/.name | 1 +
.idea/forage-jpmc-swe-task-1.iml | 12 ++++++++++++
.idea/inspectionProfiles/profiles_settings.xml | 6 ++++++
.idea/misc.xml | 4 ++++
.idea/modules.xml | 8 ++++++++
.idea/vcs.xml | 6 ++++++
client3.py | 11 ++++++++---
8 files changed, 48 insertions(+), 3 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/.name
create mode 100644 .idea/forage-jpmc-swe-task-1.iml
create mode 100644 .idea/inspectionProfiles/profiles_settings.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..abf35fb
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+client3.py
\ No newline at end of file
diff --git a/.idea/forage-jpmc-swe-task-1.iml b/.idea/forage-jpmc-swe-task-1.iml
new file mode 100644
index 0000000..8b8c395
--- /dev/null
+++ b/.idea/forage-jpmc-swe-task-1.iml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$" />
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+ <component name="PyDocumentationSettings">
+ <option name="format" value="PLAIN" />
+ <option name="myDocStringFormat" value="Plain" />
+ </component>
+</module>
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+ <settings>
+ <option name="USE_PROJECT_PROFILE" value="false" />
+ <version value="1.0" />
+ </settings>
+</component>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..90ba53d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (forage-jpmc-swe-task-1)" project-jdk-type="Python SDK" />
+</project>
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..973696f
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/forage-jpmc-swe-task-1.iml" filepath="$PROJECT_DIR$/.idea/forage-jpmc-swe-task-1.iml" />
+ </modules>
+ </component>
+</project>
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="" vcs="Git" />
+ </component>
+</project>
\ No newline at end of file
diff --git a/client3.py b/client3.py
index 3fc09b7..197cdbf 100644
--- a/client3.py
+++ b/client3.py
@@ -35,14 +35,17 @@ 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
+ else:
+ return float(price_a/price_b)
# Main
@@ -52,8 +55,10 @@ 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, price))
+ print("Ratio %s" % getRatio(prices["ABC"], prices["DEF"]))
--
2.40.0.windows.1