fix ipo bug
This commit is contained in:
@@ -102,6 +102,10 @@ def AutoBuyIpo() -> int:
|
||||
orders = client.orders() # 查询失败时不提交,不能将未知当作无委托。
|
||||
for item in candidates:
|
||||
try:
|
||||
stock = item.get('stock') if isinstance(item, dict) else None
|
||||
if isinstance(stock, str) and re.fullmatch(r'[0-9]{6}\.BJ', stock.strip()):
|
||||
logging.info('[IPO] %s 已跳过:北交所不在申购范围内', stock.strip())
|
||||
continue
|
||||
stock, price, volume = _candidate(item)
|
||||
submitted += _subscribe(client, orders, account, now.strftime('%Y%m%d'),
|
||||
stock, price, volume)
|
||||
|
||||
@@ -187,6 +187,17 @@ class IPOTests(unittest.TestCase):
|
||||
self.assertEqual(client.submitted[0]['price'], 12.5)
|
||||
self.assertEqual([r['status'] for r in self.records()], ['pending'])
|
||||
|
||||
def test_beijing_candidate_is_excluded_without_error(self):
|
||||
client = IPOResponseClient({
|
||||
'920202.BJ': {'issuePrice': 7.55, 'maxPurchaseNum': 1190000},
|
||||
'301716.SZ': {'issuePrice': 10, 'maxPurchaseNum': 3500},
|
||||
})
|
||||
with patch.object(boot, 'Client', return_value=client), self.assertLogs(level='INFO') as logs:
|
||||
self.assertEqual(boot.AutoBuyIpo(), 1)
|
||||
self.assertTrue(all(record.levelno == 20 for record in logs.records))
|
||||
self.assertEqual([order['stock'] for order in client.submitted], ['301716.SZ'])
|
||||
self.assertEqual([record['stock'] for record in self.records()], ['301716.SZ'])
|
||||
|
||||
def test_supported_codes_and_numeric_strings(self):
|
||||
for stock in ['600001.SH', '688001.SH', '689001.SH', '000001.SZ',
|
||||
'001001.SZ', '002001.SZ', '003001.SZ', '300001.SZ', '301001.SZ']:
|
||||
|
||||
Reference in New Issue
Block a user