Skip to content

Commit 2f93a9f

Browse files
author
Your Name
committed
fix bug: do not output string to json file
1 parent 4464903 commit 2f93a9f

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
install:
2-
pip install -r requirements.txt
2+
pip3 install -r requirements.txt
33
setup:
4-
python setup.py install
4+
python3 setup.py install
55
lint:
66
pylint * --ignore build dist
77
lint-fix:

SPY.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

cnbc/api_response.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ def __init__(self, code, headers):
66
self.code = code
77
self.headers = headers
88

9-
109
class ApiResponse(ApiResponseBase):
1110
def __init__(self, code, headers, body, interface):
1211
# super(ApiResponse, self).__init__(code, headers)

cnbc/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ def queryQuote(self, symbol):
88
return Quote.retrieve(symbol)
99

1010
def apply(self, symbol, requestFn, saveFn):
11-
return saveFn(symbol, requestFn(symbol))
11+
return saveFn(symbol, requestFn(symbol).data)
1212

13-
def save(self, symbol, data):
14-
toJSON(self._build_filename(symbol), data)
13+
@classmethod
14+
def save(cls, symbol, data):
15+
toJSON(cls._build_filename(symbol), data)
1516
return data
1617

17-
def _build_filename(self, symbol):
18+
@classmethod
19+
def _build_filename(cls, symbol):
1820
return '{}.json'.format(symbol)

cnbc/interfaces/options_chain.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from cnbc.interfaces.object_base import ObjectBase
77

8-
98
class OptionsChain(ObjectBase):
109
def __init__(self, payload={}):
1110
super()

cnbc/resources/quote.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from cnbc.api_response import ApiResponse
55
from cnbc.interfaces import OptionsChain
66

7+
API_ENDPOINT = "https://cdn.cboe.com/api/global/delayed_quotes/options/"
8+
79
class Quote():
810
def __init__(self, symbol):
911
self.symbol = symbol
@@ -18,7 +20,6 @@ def retrieve(cls, symbol):
1820

1921
@classmethod
2022
def _build_instance_url(cls, symbol):
21-
API_ENDPOINT = "https://cdn.cboe.com/api/global/delayed_quotes/options/"
2223
return '{}{}.json'.format(API_ENDPOINT, symbol)
2324

2425
def instance_url(self):

cnbc/util.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
def toJSON(filename, data):
44
outFile = open(filename, "w")
5-
# print(data);
65
outFile.write(str(data))
7-
# json.dump(data, outFile, indent = 4)
86
outFile.close()
97
return True

examples/spy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
STOCK = "SPY"
44

55
client = cnbc.Client()
6-
client.apply(STOCK, client.queryQuote, client.save)
6+
client.apply(STOCK, client.queryQuote, cnbc.Client.save)

0 commit comments

Comments
 (0)