91 lines
2.6 KiB
Python
Executable File
91 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
新股打新数据检查 (使用 akshare)
|
|
- A股可转债
|
|
- A股新股
|
|
- 港股新股 (如果可用)
|
|
"""
|
|
|
|
import akshare as ak
|
|
import pandas as pd
|
|
from datetime import datetime
|
|
|
|
def get_bond_report():
|
|
"""获取可转债数据"""
|
|
try:
|
|
df = ak.bond_cb_jsl()
|
|
df_sorted = df.sort_values('转股溢价率', ascending=True)
|
|
|
|
print("\n" + "=" * 60)
|
|
print("📈 可转债溢价排行 TOP 10 (按溢价率从低到高)")
|
|
print("=" * 60)
|
|
print(f"{'代码':<10} {'名称':<14} {'现价':>8} {'转股溢价率':>10}")
|
|
print("-" * 50)
|
|
|
|
for _, row in df_sorted.head(10).iterrows():
|
|
code = str(row['代码'])
|
|
name = str(row['转债名称'])[:12]
|
|
price = row['现价']
|
|
premium = row['转股溢价率']
|
|
print(f"{code:<10} {name:<14} {price:>8.2f} {premium:>+9.2f}%")
|
|
|
|
return True
|
|
except Exception as e:
|
|
print(f"获取可转债数据失败: {e}")
|
|
return False
|
|
|
|
def get_stock_ipo_report():
|
|
"""获取A股新股数据"""
|
|
try:
|
|
df = ak.stock_new_ipo_cninfo()
|
|
|
|
print("\n" + "=" * 60)
|
|
print("📈 A股新股申购 (即将/进行中)")
|
|
print("=" * 60)
|
|
print(f"{'代码':<10} {'名称':<14} {'申购日期':>12} {'发行价':>10}")
|
|
print("-" * 50)
|
|
|
|
# 显示最近的新股
|
|
for _, row in df.head(10).iterrows():
|
|
code = str(row['证劵代码'])
|
|
name = str(row['证券简称'])[:12]
|
|
date = str(row['申购日期'])
|
|
price = row['发行价']
|
|
print(f"{code:<10} {name:<14} {date:>12} {price:>10.2f}")
|
|
|
|
return True
|
|
except Exception as e:
|
|
print(f"获取新股数据失败: {e}")
|
|
return False
|
|
|
|
def get_hk_stock_note():
|
|
"""港股新股说明"""
|
|
print("\n" + "=" * 60)
|
|
print("📈 港股新股")
|
|
print("=" * 60)
|
|
print("akshare 暂港股新股数据,请访问:")
|
|
print(" - 集思录: https://www.jisilu.cn/data/new_stock/")
|
|
print(" - 东方财富: https://data.eastmoney.com/stock/ipo.html")
|
|
|
|
def main():
|
|
print(f"\n{'='*60}")
|
|
print(f"📊 新股打新数据报告")
|
|
print(f"更新时间: {datetime.now().strftime('%Y-%m-%d %H:%M')}")
|
|
print(f"{'='*60}")
|
|
|
|
# A股可转债
|
|
get_bond_report()
|
|
|
|
# A股新股
|
|
get_stock_ipo_report()
|
|
|
|
# 港股新股
|
|
get_hk_stock_note()
|
|
|
|
print("\n" + "=" * 60)
|
|
print("💡 提示: 数据仅供参考,不构成投资建议")
|
|
print("=" * 60)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|