fix bug
This commit is contained in:
@@ -13,9 +13,9 @@ class DataMixin:
|
||||
def last_volume(self, code): return self._one("last_volume", "stockcode", code, "last_volume")
|
||||
def bar_timetag(self, index): return self._one("bar_timetag", "index", index, "timetag")
|
||||
def tick_timetag(self): return self._get_field("/api/data/tick_timetag", "timetag")
|
||||
def sector(self, sector, realtime): return self._post("/api/data/sector", {"sector": sector, "realtime": realtime}).get("stocks", [])
|
||||
def industry(self, industry): return self._post("/api/data/industry", {"industry": industry}).get("stocks", [])
|
||||
def stock_list_in_sector(self, name): return self._post("/api/data/stock_list_in_sector", {"sectorname": name}).get("stocks", [])
|
||||
def sector(self, sector, realtime): return self._post_json("/api/data/sector", {"sector": sector, "realtime": realtime}).get("stocks", [])
|
||||
def industry(self, industry): return self._post_json("/api/data/industry", {"industry": industry}).get("stocks", [])
|
||||
def stock_list_in_sector(self, name): return self._post_json("/api/data/stock_list_in_sector", {"sectorname": name}).get("stocks", [])
|
||||
def weight_in_index(self, indexcode, stockcode): return self._post_field("/api/data/weight_in_index", locals_body(indexcode=indexcode, stockcode=stockcode), "weight")
|
||||
def contract_multiplier(self, code): return self._one("contract_multiplier", "contractcode", code, "multiplier")
|
||||
def risk_free_rate(self, index): return self._one("risk_free_rate", "index", index, "risk_free_rate")
|
||||
@@ -28,7 +28,7 @@ class DataMixin:
|
||||
def market_data_ex(self, req): return self._post_field("/api/data/market_data_ex", self._market_body(req), "data")
|
||||
|
||||
def full_tick(self, stocks):
|
||||
raw = self._post("/api/data/full_tick", {"stocks": stocks}) or {}
|
||||
raw = self._post_json("/api/data/full_tick", {"stocks": stocks}) or {}
|
||||
def number(data, *names):
|
||||
for name in names:
|
||||
try: return float(data[name])
|
||||
@@ -46,7 +46,7 @@ class DataMixin:
|
||||
def trading_dates(self, stockcode, start_date, end_date, period, count=0):
|
||||
body = locals_body(stockcode=stockcode, start_date=start_date, end_date=end_date, period=period)
|
||||
if count: body["count"] = count
|
||||
return self._post("/api/data/trading_dates", body).get("dates", [])
|
||||
return self._post_json("/api/data/trading_dates", body).get("dates", [])
|
||||
def svol(self, code): return self._one("svol", "stockcode", code, "svol")
|
||||
def bvol(self, code): return self._one("bvol", "stockcode", code, "bvol")
|
||||
def longhubang(self, stocks, start, end): return self._post_field("/api/data/longhubang", {"stock_list": csv_join(stocks), "startTime": start, "endTime": end}, "data")
|
||||
@@ -73,8 +73,8 @@ class DataMixin:
|
||||
return self._post_field("/api/data/bsm_price", {"optionType": req.option_type, "objectPrices": prices, "strikePrice": req.strike_price, "riskFree": req.risk_free, "sigma": req.sigma, "days": req.days, "dividend": req.dividend}, "price")
|
||||
def bsm_iv(self, req): return self._post_field("/api/data/bsm_iv", camel_request(req), "iv")
|
||||
def local_data(self, req): return self._post_field("/api/data/local_data", {"stock_code": req.stock_code, "start_time": req.start_time, "end_time": req.end_time, "period": req.period, "divid_type": req.divid_type, "count": req.count}, "data")
|
||||
def subscribe_quote(self, code, period, dividend_type): return self._post("/api/data/subscribe_quote", {"stock_code": code, "period": period, "dividend_type": dividend_type})
|
||||
def unsubscribe_quote(self, sub_id): return self._post("/api/data/unsubscribe_quote", {"sub_id": sub_id})
|
||||
def subscribe_quote(self, code, period, dividend_type): return self._post_json("/api/data/subscribe_quote", {"stock_code": code, "period": period, "dividend_type": dividend_type})
|
||||
def unsubscribe_quote(self, sub_id): return self._post_json("/api/data/unsubscribe_quote", {"sub_id": sub_id})
|
||||
|
||||
|
||||
def locals_body(**kwargs): return kwargs
|
||||
|
||||
Reference in New Issue
Block a user