Skip to content

Commit 437fe9d

Browse files
committed
Fix stock symbol for new stock purchasing; fix document format
1 parent dba1392 commit 437fe9d

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ ShiPanE-Python-SDK
1616

1717
- 安装 Python 3.5(建议安装 Anaconda3)
1818
- cmd 中运行:pip install shipane_sdk
19-
- cmd 中运行:explorer %UserProfile%\.shipane_sdk
19+
- cmd 中运行:explorer %UserProfile%\\.shipane_sdk
2020
- 进入 config 目录;将 scheduler-example.ini 拷贝为 scheduler.ini;并修改内容(建议使用Notepad++)
21-
- 找到 python 安装目录,例如:C:\Users\[用户名]\Anaconda3
22-
- cmd 下执行(具体路径自行修改):python "C:\Users\[用户名]\Anaconda3\Scripts\shipane-scheduler.py"
21+
- 找到 python 安装目录,例如:C:\\Program Files\\Anaconda3
22+
- cmd 下执行(具体路径自行修改):python "C:\\Program Files\\Anaconda3\\Scripts\\shipane-scheduler.py"
2323

2424
二. Mac/Linux
2525
~~~~~~~~~~~~~

shipane_sdk/jobs/new_stock_purchase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __call__(self):
2424
for index, row in df.iterrows():
2525
try:
2626
order = {
27-
'symbol': row['code'], 'type': 'LIMIT', 'price': row['price'], 'amountProportion': 'ALL'
27+
'symbol': row['xcode'], 'type': 'LIMIT', 'price': row['price'], 'amountProportion': 'ALL'
2828
}
2929
self._log.info(u'下单:%s', json.dumps(order))
3030
response = self._client.buy(client, **order)

shipane_sdk/stock.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def new_stocks():
1515
table.remove(table.cssselect('thead')[0])
1616
table_html = lxml.html.etree.tostring(table).decode('utf-8')
1717
df = pd.read_html(table_html, skiprows=[0, 1])[0]
18-
df = df.drop([df.columns[idx] for idx in [1, 12, 13, 14]], axis=1)
19-
df.columns = ['code', 'name', 'ipo_date', 'issue_date', 'amount', 'markets', 'price', 'pe', 'limit', 'funds',
20-
'ballot']
21-
df['code'] = df['code'].astype(str)
18+
df = df.select(lambda x: x in [0, 1, 2, 3, 7], axis=1)
19+
df.columns = ['code', 'xcode', 'name', 'ipo_date', 'price']
20+
df['code'] = df['code'].map(lambda x: str(x).zfill(6))
21+
df['xcode'] = df['xcode'].map(lambda x: str(x).zfill(6))
2222
return df

tests/shipane_sdk/test_stock.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import unittest
4+
5+
from shipane_sdk.stock import StockUtils
6+
7+
8+
class StockUtilsTest(unittest.TestCase):
9+
def test_new_stocks(self):
10+
df = StockUtils.new_stocks()
11+
self.assertTrue((df.columns == ['code', 'xcode', 'name', 'ipo_date', 'price']).all())

0 commit comments

Comments
 (0)