兆源股份有限公司(FISTEK)提供台股報價API
Project description
PyNetstockQuoteLib簡介
針對臺灣股期交易市場,兆源公司提供輕量級報價API模組
功能:
即時提供證券、期貨與期權市場報價,多合一接口
特點:
- 極致化 高效,快速響應市場行情
- 輕量級,整包大小不到 200 KB
適合需要高速數據獲取且對資源占用敏感的應用場景
安裝方法:pip install PyNetstockQuoteLib
申請帳號請洽公司網站:https://www.fistek.com/
電話:+886-2-87717385
地址:臺灣臺北市大安區106光復南路72巷73號3樓
函數列表:
1,連接
def Connect(Address: str, nPort: unsigned short)-> bool: ...
2,斷開連接
def Disconnect() -> None: ...
3,登錄
def Login(UserName: str, Password: str, Software: str, Version: str, Company: str, Branch: str) -> None: ...
4,運行阻塞函數
def Go() -> None: ...
5,注冊報價函數
def SubscribeToQuote(Symbol: str, Exc: int, sExc: int = -1, rlot:bool = False) -> int: ...
6,關閉注冊報價
def CloseSubscribe(Index: int) -> bool: ...
7,注冊Tick函數
def SubscribeToTick(Symbol: str, Exc: int, sExc: int = -1, rlot:bool = False) -> int: ...
8,獲得報價
def GetQuote(Index: int, Field: int) -> int | float: ...
9,獲得Tick數據
def GetTick(Index:int)-> List[Dict[str, Union[int, float]]]: ...
10,獲得基本資料(9-16)
def GetInfo(Exc:int, Symbol:str, Field:str, sExc:int)-> str: ...
11,設置主動回報callback
def SetNoticeCallback(callback: Callable[[int, int, object, int], None]) -> None: ...
12,設置登錄回報函數
def SetLoginCallback(callback: Callable[[int, str, int], None]) -> None: ...
13,設置交易日資訊回報函數
def SetExcInfoCallback(callback: Callable[[int, int], None]) -> None: ...
14,設置基本資料更新回報函數
def SetStkiCallback(callback: Callable[[int, int, int], None]) -> None: ...
15,設置報價回報callback
def SetQuoteCallback(callback: Callable[[int, int], None]) -> None: ...
16,設置Tick回報函數
def SetTickCallback(callback: Callable[[int], None]) -> None: ...
示例1:Quote.py
import PyNetstockQuoteLib as NsQuote
Ind = 0
Ind1 = 0
#登錄回報
def OnLogin(Type,pInfo,InfoSize):
if(Type == NsQuote.SMSGL_LOGIN_OKAY):
global Ind,Ind1
print("登錄成功!")
#登錄成功后對商品進行報價訂閱
Ind = NsQuote.SubscribeToQuote("FITX",NsQuote.EXC_FITXN,NsQuote.EXC_FITX_T2)
Ind1 = NsQuote.SubscribeToQuote("2330",NsQuote.EXC_STOCK)
else:
print("登錄失敗")
#報價回報
def OnQuote(Index,Type):
if(Type == 1):
global Ind,Ind1
if(Index == Ind):
print("Sym:FITX,Name:" + NsQuote.GetInfo(NsQuote.EXC_FITXN,"FITX","name") +
"," + NsQuote.SYM_GLOBAL_DESC[NsQuote.SYM_LAST] +":" +
str(NsQuote.GetQuote(Index,NsQuote.SYM_LAST)) +
"," + NsQuote.SYM_GLOBAL_DESC[NsQuote.SYM_VOLUME] +":" +
str(NsQuote.GetQuote(Index,NsQuote.SYM_VOLUME)))
if(Index == Ind1):
print("Sym:2330,Last:" + str(NsQuote.GetQuote(Index,NsQuote.SYM_LAST)) +
",Vol:" + str(NsQuote.GetQuote(Index,NsQuote.SYM_VOLUME)))
#啟動入口
if NsQuote.Connect():
print("連接成功")
NsQuote.SetLoginCallback(OnLogin)
NsQuote.SetQuoteCallback(OnQuote)
NsQuote.Login("xxxxx", "xxxxx")
NsQuote.Go()
else:
print("連接失敗")
print("Over")
示例2:Tick.py
import PyNetstockQuoteLib as NsQuote
indTick = 0
#登錄回報
def OnLogin(Type,pInfo,InfoSize):
if(Type == NsQuote.SMSGL_LOGIN_OKAY):
print("登錄成功!")
else:
print("登錄失敗")
#Tick回報
def OnTick(Index):
#獲得Tick數據,返回字典列表迭代器
TickList = NsQuote.GetTick(Index)
#獲得Tick總數
Ticklen = len(TickList)
count = 0
#用基本資料獲取商品名稱
print(NsQuote.GetInfo(NsQuote.EXC_FITXN,"FITX","name"))
#顯示本次Tick信息
print("Index:" + str(Index) + " TickCount:",str(Ticklen))
#顯示10條數據用于測試
for Item in TickList:
print(Item)#Item是字典對象,實際使用時可以用Key取單元數據例如:Item["Last"]
count = count + 1
if (count >=10): break
#交易日資訊回報
def OnExcInfo(Type,Exc):
if(Exc == NsQuote.EXC_FITXN):#收到對應市場交易日資訊后注冊(較為單純)
global indTick
indTick = NsQuote.SubscribeToTick("FITX",NsQuote.EXC_FITXN,NsQuote.EXC_FITX_T2)
#程序入口
if NsQuote.Connect():
print("連接成功")
NsQuote.SetLoginCallback(OnLogin)
NsQuote.SetExcInfoCallback(OnExcInfo)
NsQuote.SetTickCallback(OnTick)
NsQuote.Login("xxxxx", "xxxxx")
NsQuote.Go()
else:
print("連接失敗")
print("Over")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pynetstockquotelib-1.0.9.tar.gz.
File metadata
- Download URL: pynetstockquotelib-1.0.9.tar.gz
- Upload date:
- Size: 187.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d10d95b5fe5a6bb1d49d7a104393311b0c7221161dc6a4f2bc1224cbd6f04ef
|
|
| MD5 |
c2f0620193c8e196b3ec58a9c5f7ae7e
|
|
| BLAKE2b-256 |
14786bda0d182bacb383c6e7fe7d12c2052f21ede66f4c2af5cd675f975dd13e
|
File details
Details for the file pynetstockquotelib-1.0.9-py3-none-any.whl.
File metadata
- Download URL: pynetstockquotelib-1.0.9-py3-none-any.whl
- Upload date:
- Size: 185.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a34e5bafb663f1b7aea4708188029a66302bbf0971d0cac546db2845f80e418
|
|
| MD5 |
7081d2a77cab63c25a6b06b0b951850f
|
|
| BLAKE2b-256 |
3ae8f10622a1c1490f849a1a928e2aebe2d3ebfe486502d178ea888dca806af9
|