Skip to content

Commit

Permalink
fix(jsl): 修复集思路分级套利接口的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
shidenggui committed Mar 19, 2016
1 parent 7e7b509 commit 90af0b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion easyquotation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .api import *
from .helpers import get_stock_codes, update_stock_codes

__version__ = '0.3.7'
__version__ = '0.3.8'
__author__ = 'shidenggui'
30 changes: 16 additions & 14 deletions easyquotation/jsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Jsl(object):
__fundarb_url = 'http://www.jisilu.cn/data/sfnew/arbitrage_vip_list/?___t={ctime:d}'

# 集思录登录接口
__jxl_login_url = 'http://www.jisilu.cn/account/ajax/login_process/'
__jsl_login_url = 'https://www.jisilu.cn/account/ajax/login_process/'

# 集思录 ETF 接口
__etf_index_url = "https://www.jisilu.cn/jisiludata/etf.php?___t={ctime:d}"
Expand Down Expand Up @@ -102,7 +102,6 @@ def formatetfindexjson(fundbjson):
d[fundb_id] = cell
return d


@staticmethod
def percentage2float(per):
"""
Expand Down Expand Up @@ -180,7 +179,7 @@ def fundarb(self, jsl_username, jsl_password, avolume=100, bvolume=100, ptype='p
"""
s = requests.session()
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko'
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko',
}
s.headers.update(headers)

Expand All @@ -189,9 +188,11 @@ def fundarb(self, jsl_username, jsl_password, avolume=100, bvolume=100, ptype='p
password=jsl_password,
net_auto_login='1',
_post_type='ajax')
rep = s.post(self.__jxl_login_url, data=logindata)

if rep.status_code != 200: return {}
rep = s.post(self.__jsl_login_url, data=logindata)

if rep.json()['err'] is not None:
return rep.json()

# 添加当前的ctime
fundarb_url = self.__fundarb_url.format(ctime=int(time.time()))
Expand All @@ -201,7 +202,7 @@ def fundarb(self, jsl_username, jsl_password, avolume=100, bvolume=100, ptype='p
ptype=ptype,
is_search='1',
market=['sh', 'sz'],
rp='100')
rp='50')
# 请求数据
rep = s.post(fundarb_url, data=pdata)

Expand All @@ -213,7 +214,6 @@ def fundarb(self, jsl_username, jsl_password, avolume=100, bvolume=100, ptype='p
self.__fundarb = data
return self.__fundarb


def etfindex(self, index_id="", min_volume=0, max_discount=None, min_discount=None):
"""
以字典形式返回 指数ETF 数据
Expand Down Expand Up @@ -248,7 +248,8 @@ def etfindex(self, index_id="", min_volume=0, max_discount=None, min_discount=No
min_discount = self.percentage2float(min_discount)
else:
min_discount = float(min_discount) / 100.
data = {fund_id: cell for fund_id, cell in data.items() if self.percentage2float(cell["discount_rt"]) >= min_discount}
data = {fund_id: cell for fund_id, cell in data.items() if
self.percentage2float(cell["discount_rt"]) >= min_discount}
if max_discount is not None:
# 指定最大溢价率
if isinstance(max_discount, str):
Expand All @@ -257,16 +258,17 @@ def etfindex(self, index_id="", min_volume=0, max_discount=None, min_discount=No
max_discount = self.percentage2float(max_discount)
else:
max_discount = float(max_discount) / 100.
data = {fund_id: cell for fund_id, cell in data.items() if self.percentage2float(cell["discount_rt"]) <= max_discount}
data = {fund_id: cell for fund_id, cell in data.items() if
self.percentage2float(cell["discount_rt"]) <= max_discount}

self.__etfindex = data
return self.__etfindex


if __name__ == "__main__":
Jsl().etfindex(
index_id="000016",
min_volume=0,
max_discount="-0.4",
min_discount="-1.3%"
)
index_id="000016",
min_volume=0,
max_discount="-0.4",
min_discount="-1.3%"
)

0 comments on commit 90af0b6

Please sign in to comment.