Skip to main content

Quotation System Analysis

SolPYAPI

After downloading the Python module from MasterLink, install the quotation system using the following command:

pip install .\MasterLink_PythonAPI\SolPYAPI\PY_TradeD-0.1.15-py3-none-any.whl
tip

At the time of use, the package version was 0.1.15.

Official Technical Documentation

Core Modules

We have deconstructed the MasterLink Python module into the following core modules:

ProductBasic

This class is used to record and return stock-related information.

Click to expand object properties
No.Field NameData TypeFormatDescription
1ExchangestrExchange (TWSE, TAIFEX)
2SymbolstrProduct Code (TWSE, TAIFEX)
3CategorystrProduct Category (TWSE, TAIFEX)
4TodayRefPricestrReference Price (TAIFEX)
5RiseStopPricestrUpper Limit Price (TWSE, TAIFEX)
6FallStopPricestrLower Limit Price (TWSE, TAIFEX)
7ChineseNamestrUTF-8Product Chinese Name (TWSE)
8PreTotalMatchQtystrPrevious Trading Day Total Volume (TWSE, TAIFEX)
9PreTodayRefPricestrPrevious Trading Day Reference Price (TWSE, TAIFEX)
10PreClosePricestrPrevious Trading Day Closing Price (TWSE, TAIFEX)
11IndustryCategorystrIndustry Category (TWSE)
12StockCategorystrStock Category (TWSE)
13BoardRemarkstrBoard Remark (TWSE)
14ClassRemarkstrClass Remark (TWSE)
15StockAnomalyCodestrStock Anomaly Code (TWSE)
16NonTenParValueRemarkstrNon-10 Par Value Remark (TWSE)
17AbnormalRecommendationIndicatorstrAbnormal Recommendation Indicator (TWSE)
18AbnormalSecuritiesIndicatorstrAbnormal Securities Indicator (TWSE)
19DayTradingRemarkstrDay Trading Remark (TWSE)
20TradingUnitstrTrading Unit (TWSE)
21TickSizestrMinimum Tick Size (TWSE)
22prodKindstrContract Type (TAIFEX)
23strikePriceDecimalLocatorstrStrike Price Decimal Locator (TAIFEX)
24PreTotalTradingAmountstrPrevious Trading Day Total Amount (TWSE)
25DecimalLocatorstrPrice Decimal Locator (TAIFEX)
26BeginDatestrYYYYMMDDListing Date (TAIFEX)
27EndDatestrYYYYMMDDDelisting Date (TAIFEX)
28FlowGroupstrFlow Group (TAIFEX)
29DeliveryDatestrYYYYMMDDLast Settlement Date (TAIFEX)
30DynamicBandingstrY: Applicable, N: Not Applicable, Dynamic Price Stabilization (TAIFEX)
31ContractSymbolstrContract Symbol (TAIFEX)
32ContractNamestrContract Chinese Name (TAIFEX)
33StockIDstrUnderlying Stock Code (TAIFEX)
34StatusCodestrN: Normal, P: Trading Halt, U: To be Listed, Status Code (TAIFEX)
35CurrencystrCurrency (TAIFEX)
36AcceptQuoteFlagstrAccept Quote Flag (TAIFEX)
37BlockTradeFlagstrY: Yes, N: No, Block Trade Flag (TAIFEX)
38ExpiryTypestrS: Standard, W: Weekly, Expiry Type (TAIFEX)
39UnderlyingTypestrE S: Underlying Type (TAIFEX)
40MarketCloseGroupstrMarket Close Group (TAIFEX)
41EndSessionstr0: Regular Trading Session, 1: After-Hours Trading Session (TAIFEX)
42isAfterHoursstr0: Morning Session, 1: Afternoon Session (TAIFEX)

ProductTick

Real-time transaction details.

Click to expand object properties
No.Field NameData TypeFormatDescription
1ExchangestrExchange (TWSE, TAIFEX)
2SymbolstrProduct Code (TWSE, TAIFEX)
3MatchTimestr%H:%M:%S.%fTransaction Data Time (TWSE, TAIFEX)
4OrderBookTimestr%H:%M:%S.%fOrder Book Data Time (TWSE, TAIFEX)
5TxSeqstrExchange Sequence Number (Transaction Data) (TWSE, TAIFEX)
6ObSeqstrExchange Sequence Number (Order Book Data) (TWSE, TAIFEX)
7IsTxTrailbool0: Non-Trail, 1: Trail, Is Transaction Trail Data (TWSE, TAIFEX)
8Is5QTrialbool0: Non-Trail, 1: Trail, Is Order Book Trail Data (TWSE, TAIFEX)
9IsTrailbool0: Non-Trail, 1: Trail, Is Trail Data (TWSE, TAIFEX)
10DecimalLocatorstrDecimal Locator for Price Field (TAIFEX)
11MatchPricestrTransaction Price (TWSE, TAIFEX)
12MatchQtystrProduct Transaction Volume (TAIFEX)
13MatchPriceListlistMultiple Transaction Prices for One Market Quote (TWSE, TAIFEX)
14MatchQtyListlistMultiple Transaction Volumes for One Market Quote (TWSE, TAIFEX)
15MatchBuyCountstrAccumulated Buy Transaction Count (TAIFEX)
16MatchSellCountstrAccumulated Sell Transaction Count (TAIFEX)
17TotalMatchQtystrTotal Product Transaction Volume (TWSE, TAIFEX)
18TotalTradingAmountstrTotal Product Transaction Amount (TWSE, TAIFEX)
19TradingUnitstrTrading Unit (TWSE, TAIFEX)
20DayHighstrDay High Price (TWSE, TAIFEX)
21DayLowstrDay Low Price (TWSE, TAIFEX)
22RefPricestrReference Price (TWSE)
23BuyPricelistOrder Book Buy Price (TWSE, TAIFEX)
24BuyQtylistOrder Book Buy Quantity (TWSE, TAIFEX)
25SellPricelistOrder Book Sell Price (TWSE, TAIFEX)
26SellQtylistOrder Book Sell Quantity (TWSE, TAIFEX)
27AllMarketAmountstrTotal Market Transaction Amount (TWSE)
28AllMarketVolumestrTotal Market Transaction Volume (TWSE)
29AllMarketCntstrTotal Market Transaction Count (TWSE)
30AllMarketBuyCntstrTotal Market Buy Order Count (TWSE)
31AllMarketSellCntstrTotal Market Sell Order Count (TWSE)
32AllMarketBuyQtystrTotal Market Buy Order Quantity (TWSE)
33AllMarketSellQtystrTotal Market Sell Order Quantity (TWSE)
34IsFixedPriceTransactionstrFixed Price Transaction (TWSE)
35OpenPricestrOpening Price (TWSE, TAIFEX)
36FirstDerivedBuyPricestrFirst Derived Buy Price (TAIFEX)
37FirstDerivedBuyQtystrFirst Derived Buy Quantity (TAIFEX)
38FirstDerivedSellPricestrFirst Derived Sell Price (TAIFEX)
39FirstDerivedSellQtystrFirst Derived Sell Quantity (TAIFEX)
40TotalBuyOrderstrAccumulated Buy Order Count (TAIFEX)
41TotalBuyQtystrAccumulated Buy Order Quantity (TAIFEX)
42TotalSellOrderstrAccumulated Sell Order Count (TAIFEX)
43TotalSellQtystrAccumulated Sell Order Quantity (TAIFEX)
44ClosePricestrClosing Price (TAIFEX)
45SettlePricestrSettlement Price (TAIFEX)

RCode

This class is used to record the error codes returned by the quotation system.

Click to expand object properties
ValueNameDescription
0OKSuccess
1SOLCLIENT_WOULD_BLOCKAPI call would block but request is non-blocking
2SOLCLIENT_IN_PROGRESSAPI call is in progress (non-blocking mode)
3SOLCLIENT_NOT_READYAPI cannot complete as the object is not ready
4SOLCLIENT_EOSNext operation on structured container returned EOS
5SOLCLIENT_NOT_FOUNDNamed field not found in MAP lookup
6SOLCLIENT_NOEVENTNo events to process in the context
7SOLCLIENT_INCOMPLETEAPI call completed some but not all requested functions
8SOLCLIENT_ROLLBACKCommit() returns this value when a transaction is rolled back
9SOLCLIENT_EVENTSolClient session event
10CLIENT_ALREADY_CONNECTEDConnection already established
11CLIENT_ALREADY_DISCONNECTEDConnection already disconnected
12ANNOUNCEMENTAnnouncement message
-1FAILFailure
-2CONNECTION_REFUSEDConnection refused
-3CONNECTION_FAILConnection failed
-4ALREADY_EXISTSTarget object already exists
-5NOT_FOUNDTarget object not found
-6CLIENT_NOT_READYConnection not ready
-7USER_SUBSCRIPTION_LIMIT_EXCEEDEDSubscription limit exceeded
-8USER_NOT_APPLIEDNot applied
-9USER_NOT_VERIFIEDNot verified
-10USER_VERIFICATION_FAILVerification failed
-11SUBSCRIPTION_FAILSubscription failed
-12RECOVERY_FAILRecovery failed
-13DOWNLOAD_PRODUCT_FAILFailed to download basic data file
-14MESSAGE_HANDLER_FAILMessage handling error
-15FUNCTION_SUBSCRIPTION_LIMIT_EXCEEDEDFunction subscription limit exceeded
-16USER_NOT_VERIFIED_TWSENot verified TWSE
-17USER_NOT_VERIFIED_TAIFEXNot verified TAIFEX
-18USER_NOT_VERIFIED_TWSE_TAIFEXNot verified TWSE & TAIFEX
-9999UNKNOWN_ERRORUnknown error

MarketDataMart

This is an entry point in the quotation system, defining a few methods that trigger events such as transaction messages and order messages.

To use these methods, you must manually attach the corresponding event handlers.

EventDescription
Fire_OnSystemEventSystem event notification
Fire_MarketDataMart_ConnectStateSystem connection status
Fire_OnUpdateBasicProduct basic data update
Fire_OnUpdateProductBasicListProduct basic data list update
Fire_OnUpdateLastSnapshotLatest product snapshot update
Fire_OnMatchProduct transaction message
Fire_OnOrderBookProduct order message
Fire_OnUpdateTotalOrderQtyProduct order quantity update
Fire_OnUpdateOptionGreeksOption product Greeks update
Fire_OnUpdateOvsBasicOverseas product basic data update
Fire_OnUpdateOvsMatchOverseas product transaction data update
Fire_OnUpdateOvsOrderBookOverseas product order book update

Sol_D

This class takes an instance of the MarketDataMart class as input and passes it to the MasterQuoteDAPI class, creating another instance.

In the MasterQuoteDAPI implementation, the MarketDataMart instance is passed to the SolAPI class, creating yet another instance.

Well, these are their implementation methods, so we'll leave it at that.


In the Sol_D class, several commonly used methods are provided:

  • Sol_D.Login: Log in
  • Sol_D.DisConnect: Log out
  • Sol_D.Subscribe: Subscribe to product quotes
  • Sol_D.UnSubscribe: Unsubscribe from product quotes

Additionally, there are several event handlers that must be defined externally and attached using their specified methods:

  • Sol_D.Set_OnLogEvent: Set log event handler
  • Sol_D.Set_OnInterruptEvent: Set system event handler
  • Sol_D.Set_OnLoginResultEvent_DAPI: Set login result event handler
  • Sol_D.Set_OnAnnouncementEvent_DAPI: Set announcement event handler
  • Sol_D.Set_OnVerifiedEvent_DAPI: Set verification event handler
  • Sol_D.Set_OnSystemEvent_DAPI: Set system event handler
  • Sol_D.Set_OnUpdateBasic_DAPI: Set product basic data update event handler
  • Sol_D.Set_OnMatch_DAPI: Set product transaction message event handler