mirror of
https://github.com/wassname/optlib.git
synced 2026-06-27 16:10:18 +08:00
use requests instead of curl
This commit is contained in:
+4
-6
@@ -1,5 +1,4 @@
|
||||
from subprocess import check_output
|
||||
import json
|
||||
import requests
|
||||
import os
|
||||
|
||||
import logging
|
||||
@@ -43,10 +42,9 @@ def _get(endpoint, *args, **kwargs):
|
||||
url = "?".join([endpoint, "&".join(f"{k}={v}" for k, v in kwargs.items())])
|
||||
logger.debug("GET", url)
|
||||
|
||||
if (resp := json.loads(check_output(["curl", "-gs", url]))).get("error"):
|
||||
raise API_InputError("{0}".format(resp["error"]))
|
||||
|
||||
return resp
|
||||
r = requests.get(url)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
def get_chain(*args, **kwargs):
|
||||
"""Request an option chain from TDAmeritrade's API.
|
||||
|
||||
Reference in New Issue
Block a user