Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
shidenggui committed Mar 2, 2016
1 parent 36d765b commit 72a34f0
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
5 changes: 3 additions & 2 deletions easyquotation/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
from .sina import Sina
from .leverfun import Leverfun

from .jsl import Jsl
from .leverfun import Leverfun
from .sina import Sina

PY_VERSION = sys.version_info[:2]
if PY_VERSION < (3, 5):
Expand Down
5 changes: 3 additions & 2 deletions easyquotation/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
import os
import json
import os
import re

import requests

STOCK_CODE_PATH = 'stock_codes.conf'
Expand Down
2 changes: 1 addition & 1 deletion easyquotation/jsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def formatfundajson(fundajson):
cell = row['cell']
d[funda_id] = cell
return d

@staticmethod
def formatfundbjson(fundbjson):
"""格式化集思录返回的json数据,以字典形式保存"""
Expand Down
2 changes: 1 addition & 1 deletion easyquotation/leverfun.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio

import aiohttp


Expand Down Expand Up @@ -52,4 +53,3 @@ def format_response_data(cls, response_data):
q = Leverfun()
print(q.stocks(['000001', '162411']))
print(q.stocks('162411'))

70 changes: 36 additions & 34 deletions easyquotation/sina.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import re
import json
import asyncio
import json
import re

import aiohttp

from . import helpers


Expand Down Expand Up @@ -63,37 +65,37 @@ def format_response_data(self):
for stock_match_object in result:
stock = stock_match_object.groups()
stock_dict[stock[0]] = dict(
name=stock[1],
open=float(stock[2]),
close=float(stock[3]),
now=float(stock[4]),
high=float(stock[5]),
low=float(stock[6]),
buy=float(stock[7]),
sell=float(stock[8]),
turnover=int(stock[9]),
volume=float(stock[10]),
bid1_volume=int(stock[11]),
bid1=float(stock[12]),
bid2_volume=int(stock[13]),
bid2=float(stock[14]),
bid3_volume=int(stock[15]),
bid3=float(stock[16]),
bid4_volume=int(stock[17]),
bid4=float(stock[18]),
bid5_volume=int(stock[19]),
bid5=float(stock[20]),
ask1_volume=int(stock[21]),
ask1=float(stock[22]),
ask2_volume=int(stock[23]),
ask2=float(stock[24]),
ask3_volume=int(stock[25]),
ask3=float(stock[26]),
ask4_volume=int(stock[27]),
ask4=float(stock[28]),
ask5_volume=int(stock[29]),
ask5=float(stock[30]),
date=stock[31],
time=stock[32],
name=stock[1],
open=float(stock[2]),
close=float(stock[3]),
now=float(stock[4]),
high=float(stock[5]),
low=float(stock[6]),
buy=float(stock[7]),
sell=float(stock[8]),
turnover=int(stock[9]),
volume=float(stock[10]),
bid1_volume=int(stock[11]),
bid1=float(stock[12]),
bid2_volume=int(stock[13]),
bid2=float(stock[14]),
bid3_volume=int(stock[15]),
bid3=float(stock[16]),
bid4_volume=int(stock[17]),
bid4=float(stock[18]),
bid5_volume=int(stock[19]),
bid5=float(stock[20]),
ask1_volume=int(stock[21]),
ask1=float(stock[22]),
ask2_volume=int(stock[23]),
ask2=float(stock[24]),
ask3_volume=int(stock[25]),
ask3=float(stock[26]),
ask4_volume=int(stock[27]),
ask4=float(stock[28]),
ask5_volume=int(stock[29]),
ask5=float(stock[30]),
date=stock[31],
time=stock[32],
)
return stock_dict

0 comments on commit 72a34f0

Please sign in to comment.