diff --git a/vnpy/gateway/rohon/RohonBaseV64.dll b/vnpy/gateway/rohon/RohonBaseV64.dll new file mode 100644 index 00000000..a434d2a9 Binary files /dev/null and b/vnpy/gateway/rohon/RohonBaseV64.dll differ diff --git a/vnpy/gateway/rohon/WinDataCollect.dll b/vnpy/gateway/rohon/WinDataCollect.dll new file mode 100644 index 00000000..ecfdaac0 Binary files /dev/null and b/vnpy/gateway/rohon/WinDataCollect.dll differ diff --git a/vnpy/gateway/rohon/__init__.py b/vnpy/gateway/rohon/__init__.py new file mode 100644 index 00000000..7166d9cc --- /dev/null +++ b/vnpy/gateway/rohon/__init__.py @@ -0,0 +1 @@ +from .rohon_gateway import RohonGateway diff --git a/vnpy/gateway/rohon/ctp_constant.py b/vnpy/gateway/rohon/ctp_constant.py new file mode 100644 index 00000000..bf479ffe --- /dev/null +++ b/vnpy/gateway/rohon/ctp_constant.py @@ -0,0 +1,1223 @@ +THOST_FTDC_EXP_Normal = '0' +THOST_FTDC_EXP_GenOrderByTrade = '1' +THOST_FTDC_ICT_EID = '0' +THOST_FTDC_ICT_IDCard = '1' +THOST_FTDC_ICT_OfficerIDCard = '2' +THOST_FTDC_ICT_PoliceIDCard = '3' +THOST_FTDC_ICT_SoldierIDCard = '4' +THOST_FTDC_ICT_HouseholdRegister = '5' +THOST_FTDC_ICT_Passport = '6' +THOST_FTDC_ICT_TaiwanCompatriotIDCard = '7' +THOST_FTDC_ICT_HomeComingCard = '8' +THOST_FTDC_ICT_LicenseNo = '9' +THOST_FTDC_ICT_TaxNo = 'A' +THOST_FTDC_ICT_HMMainlandTravelPermit = 'B' +THOST_FTDC_ICT_TwMainlandTravelPermit = 'C' +THOST_FTDC_ICT_DrivingLicense = 'D' +THOST_FTDC_ICT_SocialID = 'F' +THOST_FTDC_ICT_LocalID = 'G' +THOST_FTDC_ICT_BusinessRegistration = 'H' +THOST_FTDC_ICT_HKMCIDCard = 'I' +THOST_FTDC_ICT_AccountsPermits = 'J' +THOST_FTDC_ICT_FrgPrmtRdCard = 'K' +THOST_FTDC_ICT_CptMngPrdLetter = 'L' +THOST_FTDC_ICT_OtherCard = 'x' +THOST_FTDC_IR_All = '1' +THOST_FTDC_IR_Group = '2' +THOST_FTDC_IR_Single = '3' +THOST_FTDC_DR_All = '1' +THOST_FTDC_DR_Group = '2' +THOST_FTDC_DR_Single = '3' +THOST_FTDC_DS_Asynchronous = '1' +THOST_FTDC_DS_Synchronizing = '2' +THOST_FTDC_DS_Synchronized = '3' +THOST_FTDC_BDS_Synchronized = '1' +THOST_FTDC_BDS_Synchronizing = '2' +THOST_FTDC_ECS_NoConnection = '1' +THOST_FTDC_ECS_QryInstrumentSent = '2' +THOST_FTDC_ECS_GotInformation = '9' +THOST_FTDC_TCS_NotConnected = '1' +THOST_FTDC_TCS_Connected = '2' +THOST_FTDC_TCS_QryInstrumentSent = '3' +THOST_FTDC_TCS_SubPrivateFlow = '4' +THOST_FTDC_FC_DataAsync = '1' +THOST_FTDC_FC_ForceUserLogout = '2' +THOST_FTDC_FC_UserPasswordUpdate = '3' +THOST_FTDC_FC_BrokerPasswordUpdate = '4' +THOST_FTDC_FC_InvestorPasswordUpdate = '5' +THOST_FTDC_FC_OrderInsert = '6' +THOST_FTDC_FC_OrderAction = '7' +THOST_FTDC_FC_SyncSystemData = '8' +THOST_FTDC_FC_SyncBrokerData = '9' +THOST_FTDC_FC_BachSyncBrokerData = 'A' +THOST_FTDC_FC_SuperQuery = 'B' +THOST_FTDC_FC_ParkedOrderInsert = 'C' +THOST_FTDC_FC_ParkedOrderAction = 'D' +THOST_FTDC_FC_SyncOTP = 'E' +THOST_FTDC_FC_DeleteOrder = 'F' +THOST_FTDC_BFC_ForceUserLogout = '1' +THOST_FTDC_BFC_UserPasswordUpdate = '2' +THOST_FTDC_BFC_SyncBrokerData = '3' +THOST_FTDC_BFC_BachSyncBrokerData = '4' +THOST_FTDC_BFC_OrderInsert = '5' +THOST_FTDC_BFC_OrderAction = '6' +THOST_FTDC_BFC_AllQuery = '7' +THOST_FTDC_BFC_log = 'a' +THOST_FTDC_BFC_BaseQry = 'b' +THOST_FTDC_BFC_TradeQry = 'c' +THOST_FTDC_BFC_Trade = 'd' +THOST_FTDC_BFC_Virement = 'e' +THOST_FTDC_BFC_Risk = 'f' +THOST_FTDC_BFC_Session = 'g' +THOST_FTDC_BFC_RiskNoticeCtl = 'h' +THOST_FTDC_BFC_RiskNotice = 'i' +THOST_FTDC_BFC_BrokerDeposit = 'j' +THOST_FTDC_BFC_QueryFund = 'k' +THOST_FTDC_BFC_QueryOrder = 'l' +THOST_FTDC_BFC_QueryTrade = 'm' +THOST_FTDC_BFC_QueryPosition = 'n' +THOST_FTDC_BFC_QueryMarketData = 'o' +THOST_FTDC_BFC_QueryUserEvent = 'p' +THOST_FTDC_BFC_QueryRiskNotify = 'q' +THOST_FTDC_BFC_QueryFundChange = 'r' +THOST_FTDC_BFC_QueryInvestor = 's' +THOST_FTDC_BFC_QueryTradingCode = 't' +THOST_FTDC_BFC_ForceClose = 'u' +THOST_FTDC_BFC_PressTest = 'v' +THOST_FTDC_BFC_RemainCalc = 'w' +THOST_FTDC_BFC_NetPositionInd = 'x' +THOST_FTDC_BFC_RiskPredict = 'y' +THOST_FTDC_BFC_DataExport = 'z' +THOST_FTDC_BFC_RiskTargetSetup = 'A' +THOST_FTDC_BFC_MarketDataWarn = 'B' +THOST_FTDC_BFC_QryBizNotice = 'C' +THOST_FTDC_BFC_CfgBizNotice = 'D' +THOST_FTDC_BFC_SyncOTP = 'E' +THOST_FTDC_BFC_SendBizNotice = 'F' +THOST_FTDC_BFC_CfgRiskLevelStd = 'G' +THOST_FTDC_BFC_TbCommand = 'H' +THOST_FTDC_BFC_DeleteOrder = 'J' +THOST_FTDC_BFC_ParkedOrderInsert = 'K' +THOST_FTDC_BFC_ParkedOrderAction = 'L' +THOST_FTDC_BFC_ExecOrderNoCheck = 'M' +THOST_FTDC_BFC_Designate = 'N' +THOST_FTDC_BFC_StockDisposal = 'O' +THOST_FTDC_BFC_BrokerDepositWarn = 'Q' +THOST_FTDC_BFC_CoverWarn = 'S' +THOST_FTDC_BFC_PreExecOrder = 'T' +THOST_FTDC_BFC_ExecOrderRisk = 'P' +THOST_FTDC_BFC_PosiLimitWarn = 'U' +THOST_FTDC_BFC_QryPosiLimit = 'V' +THOST_FTDC_BFC_FBSign = 'W' +THOST_FTDC_BFC_FBAccount = 'X' +THOST_FTDC_OAS_Submitted = 'a' +THOST_FTDC_OAS_Accepted = 'b' +THOST_FTDC_OAS_Rejected = 'c' +THOST_FTDC_OST_AllTraded = '0' +THOST_FTDC_OST_PartTradedQueueing = '1' +THOST_FTDC_OST_PartTradedNotQueueing = '2' +THOST_FTDC_OST_NoTradeQueueing = '3' +THOST_FTDC_OST_NoTradeNotQueueing = '4' +THOST_FTDC_OST_Canceled = '5' +THOST_FTDC_OST_Unknown = 'a' +THOST_FTDC_OST_NotTouched = 'b' +THOST_FTDC_OST_Touched = 'c' +THOST_FTDC_OSS_InsertSubmitted = '0' +THOST_FTDC_OSS_CancelSubmitted = '1' +THOST_FTDC_OSS_ModifySubmitted = '2' +THOST_FTDC_OSS_Accepted = '3' +THOST_FTDC_OSS_InsertRejected = '4' +THOST_FTDC_OSS_CancelRejected = '5' +THOST_FTDC_OSS_ModifyRejected = '6' +THOST_FTDC_PSD_Today = '1' +THOST_FTDC_PSD_History = '2' +THOST_FTDC_PDT_UseHistory = '1' +THOST_FTDC_PDT_NoUseHistory = '2' +THOST_FTDC_ER_Broker = '1' +THOST_FTDC_ER_Host = '2' +THOST_FTDC_ER_Maker = '3' +THOST_FTDC_PC_Futures = '1' +THOST_FTDC_PC_Options = '2' +THOST_FTDC_PC_Combination = '3' +THOST_FTDC_PC_Spot = '4' +THOST_FTDC_PC_EFP = '5' +THOST_FTDC_PC_SpotOption = '6' +THOST_FTDC_IP_NotStart = '0' +THOST_FTDC_IP_Started = '1' +THOST_FTDC_IP_Pause = '2' +THOST_FTDC_IP_Expired = '3' +THOST_FTDC_D_Buy = '0' +THOST_FTDC_D_Sell = '1' +THOST_FTDC_PT_Net = '1' +THOST_FTDC_PT_Gross = '2' +THOST_FTDC_PD_Net = '1' +THOST_FTDC_PD_Long = '2' +THOST_FTDC_PD_Short = '3' +THOST_FTDC_SS_NonActive = '1' +THOST_FTDC_SS_Startup = '2' +THOST_FTDC_SS_Operating = '3' +THOST_FTDC_SS_Settlement = '4' +THOST_FTDC_SS_SettlementFinished = '5' +THOST_FTDC_RA_Trade = '0' +THOST_FTDC_RA_Settlement = '1' +THOST_FTDC_HF_Speculation = '1' +THOST_FTDC_HF_Arbitrage = '2' +THOST_FTDC_HF_Hedge = '3' +THOST_FTDC_HF_MarketMaker = '5' +THOST_FTDC_HF_SpecHedge = '6' +THOST_FTDC_HF_HedgeSpec = '7' +THOST_FTDC_BHF_Speculation = '1' +THOST_FTDC_BHF_Arbitrage = '2' +THOST_FTDC_BHF_Hedge = '3' +THOST_FTDC_CIDT_Speculation = '1' +THOST_FTDC_CIDT_Arbitrage = '2' +THOST_FTDC_CIDT_Hedge = '3' +THOST_FTDC_CIDT_MarketMaker = '5' +THOST_FTDC_OPT_AnyPrice = '1' +THOST_FTDC_OPT_LimitPrice = '2' +THOST_FTDC_OPT_BestPrice = '3' +THOST_FTDC_OPT_LastPrice = '4' +THOST_FTDC_OPT_LastPricePlusOneTicks = '5' +THOST_FTDC_OPT_LastPricePlusTwoTicks = '6' +THOST_FTDC_OPT_LastPricePlusThreeTicks = '7' +THOST_FTDC_OPT_AskPrice1 = '8' +THOST_FTDC_OPT_AskPrice1PlusOneTicks = '9' +THOST_FTDC_OPT_AskPrice1PlusTwoTicks = 'A' +THOST_FTDC_OPT_AskPrice1PlusThreeTicks = 'B' +THOST_FTDC_OPT_BidPrice1 = 'C' +THOST_FTDC_OPT_BidPrice1PlusOneTicks = 'D' +THOST_FTDC_OPT_BidPrice1PlusTwoTicks = 'E' +THOST_FTDC_OPT_BidPrice1PlusThreeTicks = 'F' +THOST_FTDC_OPT_FiveLevelPrice = 'G' +THOST_FTDC_OF_Open = '0' +THOST_FTDC_OF_Close = '1' +THOST_FTDC_OF_ForceClose = '2' +THOST_FTDC_OF_CloseToday = '3' +THOST_FTDC_OF_CloseYesterday = '4' +THOST_FTDC_OF_ForceOff = '5' +THOST_FTDC_OF_LocalForceClose = '6' +THOST_FTDC_FCC_NotForceClose = '0' +THOST_FTDC_FCC_LackDeposit = '1' +THOST_FTDC_FCC_ClientOverPositionLimit = '2' +THOST_FTDC_FCC_MemberOverPositionLimit = '3' +THOST_FTDC_FCC_NotMultiple = '4' +THOST_FTDC_FCC_Violation = '5' +THOST_FTDC_FCC_Other = '6' +THOST_FTDC_FCC_PersonDeliv = '7' +THOST_FTDC_ORDT_Normal = '0' +THOST_FTDC_ORDT_DeriveFromQuote = '1' +THOST_FTDC_ORDT_DeriveFromCombination = '2' +THOST_FTDC_ORDT_Combination = '3' +THOST_FTDC_ORDT_ConditionalOrder = '4' +THOST_FTDC_ORDT_Swap = '5' +THOST_FTDC_ORDT_DeriveFromBlockTrade = '6' +THOST_FTDC_ORDT_DeriveFromEFPTrade = '7' +THOST_FTDC_TC_IOC = '1' +THOST_FTDC_TC_GFS = '2' +THOST_FTDC_TC_GFD = '3' +THOST_FTDC_TC_GTD = '4' +THOST_FTDC_TC_GTC = '5' +THOST_FTDC_TC_GFA = '6' +THOST_FTDC_VC_AV = '1' +THOST_FTDC_VC_MV = '2' +THOST_FTDC_VC_CV = '3' +THOST_FTDC_CC_Immediately = '1' +THOST_FTDC_CC_Touch = '2' +THOST_FTDC_CC_TouchProfit = '3' +THOST_FTDC_CC_ParkedOrder = '4' +THOST_FTDC_CC_LastPriceGreaterThanStopPrice = '5' +THOST_FTDC_CC_LastPriceGreaterEqualStopPrice = '6' +THOST_FTDC_CC_LastPriceLesserThanStopPrice = '7' +THOST_FTDC_CC_LastPriceLesserEqualStopPrice = '8' +THOST_FTDC_CC_AskPriceGreaterThanStopPrice = '9' +THOST_FTDC_CC_AskPriceGreaterEqualStopPrice = 'A' +THOST_FTDC_CC_AskPriceLesserThanStopPrice = 'B' +THOST_FTDC_CC_AskPriceLesserEqualStopPrice = 'C' +THOST_FTDC_CC_BidPriceGreaterThanStopPrice = 'D' +THOST_FTDC_CC_BidPriceGreaterEqualStopPrice = 'E' +THOST_FTDC_CC_BidPriceLesserThanStopPrice = 'F' +THOST_FTDC_CC_BidPriceLesserEqualStopPrice = 'H' +THOST_FTDC_AF_Delete = '0' +THOST_FTDC_AF_Modify = '3' +THOST_FTDC_TR_Allow = '0' +THOST_FTDC_TR_CloseOnly = '1' +THOST_FTDC_TR_Forbidden = '2' +THOST_FTDC_OSRC_Participant = '0' +THOST_FTDC_OSRC_Administrator = '1' +THOST_FTDC_TRDT_SplitCombination = '#' +THOST_FTDC_TRDT_Common = '0' +THOST_FTDC_TRDT_OptionsExecution = '1' +THOST_FTDC_TRDT_OTC = '2' +THOST_FTDC_TRDT_EFPDerived = '3' +THOST_FTDC_TRDT_CombinationDerived = '4' +THOST_FTDC_TRDT_BlockTrade = '5' +THOST_FTDC_PSRC_LastPrice = '0' +THOST_FTDC_PSRC_Buy = '1' +THOST_FTDC_PSRC_Sell = '2' +THOST_FTDC_PSRC_OTC = '3' +THOST_FTDC_IS_BeforeTrading = '0' +THOST_FTDC_IS_NoTrading = '1' +THOST_FTDC_IS_Continous = '2' +THOST_FTDC_IS_AuctionOrdering = '3' +THOST_FTDC_IS_AuctionBalance = '4' +THOST_FTDC_IS_AuctionMatch = '5' +THOST_FTDC_IS_Closed = '6' +THOST_FTDC_IER_Automatic = '1' +THOST_FTDC_IER_Manual = '2' +THOST_FTDC_IER_Fuse = '3' +THOST_FTDC_BS_NoUpload = '1' +THOST_FTDC_BS_Uploaded = '2' +THOST_FTDC_BS_Failed = '3' +THOST_FTDC_RS_All = '1' +THOST_FTDC_RS_ByProduct = '2' +THOST_FTDC_RP_ByVolume = '1' +THOST_FTDC_RP_ByFeeOnHand = '2' +THOST_FTDC_RL_Level1 = '1' +THOST_FTDC_RL_Level2 = '2' +THOST_FTDC_RL_Level3 = '3' +THOST_FTDC_RL_Level4 = '4' +THOST_FTDC_RL_Level5 = '5' +THOST_FTDC_RL_Level6 = '6' +THOST_FTDC_RL_Level7 = '7' +THOST_FTDC_RL_Level8 = '8' +THOST_FTDC_RL_Level9 = '9' +THOST_FTDC_RSD_ByPeriod = '1' +THOST_FTDC_RSD_ByStandard = '2' +THOST_FTDC_MT_Out = '0' +THOST_FTDC_MT_In = '1' +THOST_FTDC_ISPI_MortgageRatio = '4' +THOST_FTDC_ISPI_MarginWay = '5' +THOST_FTDC_ISPI_BillDeposit = '9' +THOST_FTDC_ESPI_MortgageRatio = '1' +THOST_FTDC_ESPI_OtherFundItem = '2' +THOST_FTDC_ESPI_OtherFundImport = '3' +THOST_FTDC_ESPI_CFFEXMinPrepa = '6' +THOST_FTDC_ESPI_CZCESettlementType = '7' +THOST_FTDC_ESPI_ExchDelivFeeMode = '9' +THOST_FTDC_ESPI_DelivFeeMode = '0' +THOST_FTDC_ESPI_CZCEComMarginType = 'A' +THOST_FTDC_ESPI_DceComMarginType = 'B' +THOST_FTDC_ESPI_OptOutDisCountRate = 'a' +THOST_FTDC_ESPI_OptMiniGuarantee = 'b' +THOST_FTDC_SPI_InvestorIDMinLength = '1' +THOST_FTDC_SPI_AccountIDMinLength = '2' +THOST_FTDC_SPI_UserRightLogon = '3' +THOST_FTDC_SPI_SettlementBillTrade = '4' +THOST_FTDC_SPI_TradingCode = '5' +THOST_FTDC_SPI_CheckFund = '6' +THOST_FTDC_SPI_CommModelRight = '7' +THOST_FTDC_SPI_MarginModelRight = '9' +THOST_FTDC_SPI_IsStandardActive = '8' +THOST_FTDC_SPI_UploadSettlementFile = 'U' +THOST_FTDC_SPI_DownloadCSRCFile = 'D' +THOST_FTDC_SPI_SettlementBillFile = 'S' +THOST_FTDC_SPI_CSRCOthersFile = 'C' +THOST_FTDC_SPI_InvestorPhoto = 'P' +THOST_FTDC_SPI_CSRCData = 'R' +THOST_FTDC_SPI_InvestorPwdModel = 'I' +THOST_FTDC_SPI_CFFEXInvestorSettleFile = 'F' +THOST_FTDC_SPI_InvestorIDType = 'a' +THOST_FTDC_SPI_FreezeMaxReMain = 'r' +THOST_FTDC_SPI_IsSync = 'A' +THOST_FTDC_SPI_RelieveOpenLimit = 'O' +THOST_FTDC_SPI_IsStandardFreeze = 'X' +THOST_FTDC_SPI_CZCENormalProductHedge = 'B' +THOST_FTDC_TPID_EncryptionStandard = 'E' +THOST_FTDC_TPID_RiskMode = 'R' +THOST_FTDC_TPID_RiskModeGlobal = 'G' +THOST_FTDC_TPID_modeEncode = 'P' +THOST_FTDC_TPID_tickMode = 'T' +THOST_FTDC_TPID_SingleUserSessionMaxNum = 'S' +THOST_FTDC_TPID_LoginFailMaxNum = 'L' +THOST_FTDC_TPID_IsAuthForce = 'A' +THOST_FTDC_TPID_IsPosiFreeze = 'F' +THOST_FTDC_TPID_IsPosiLimit = 'M' +THOST_FTDC_TPID_ForQuoteTimeInterval = 'Q' +THOST_FTDC_TPID_IsFuturePosiLimit = 'B' +THOST_FTDC_TPID_IsFutureOrderFreq = 'C' +THOST_FTDC_TPID_IsExecOrderProfit = 'H' +THOST_FTDC_TPID_IsCheckBankAcc = 'I' +THOST_FTDC_TPID_PasswordDeadLine = 'J' +THOST_FTDC_TPID_IsStrongPassword = 'K' +THOST_FTDC_TPID_BalanceMorgage = 'a' +THOST_FTDC_TPID_MinPwdLen = 'O' +THOST_FTDC_TPID_LoginFailMaxNumForIP = 'U' +THOST_FTDC_TPID_PasswordPeriod = 'V' +THOST_FTDC_FI_SettlementFund = 'F' +THOST_FTDC_FI_Trade = 'T' +THOST_FTDC_FI_InvestorPosition = 'P' +THOST_FTDC_FI_SubEntryFund = 'O' +THOST_FTDC_FI_CZCECombinationPos = 'C' +THOST_FTDC_FI_CSRCData = 'R' +THOST_FTDC_FI_CZCEClose = 'L' +THOST_FTDC_FI_CZCENoClose = 'N' +THOST_FTDC_FI_PositionDtl = 'D' +THOST_FTDC_FI_OptionStrike = 'S' +THOST_FTDC_FI_SettlementPriceComparison = 'M' +THOST_FTDC_FI_NonTradePosChange = 'B' +THOST_FTDC_FUT_Settlement = '0' +THOST_FTDC_FUT_Check = '1' +THOST_FTDC_FFT_Txt = '0' +THOST_FTDC_FFT_Zip = '1' +THOST_FTDC_FFT_DBF = '2' +THOST_FTDC_FUS_SucceedUpload = '1' +THOST_FTDC_FUS_FailedUpload = '2' +THOST_FTDC_FUS_SucceedLoad = '3' +THOST_FTDC_FUS_PartSucceedLoad = '4' +THOST_FTDC_FUS_FailedLoad = '5' +THOST_FTDC_TD_Out = '0' +THOST_FTDC_TD_In = '1' +THOST_FTDC_SC_NoSpecialRule = '0' +THOST_FTDC_SC_NoSpringFestival = '1' +THOST_FTDC_IPT_LastSettlement = '1' +THOST_FTDC_IPT_LaseClose = '2' +THOST_FTDC_PLP_Active = '1' +THOST_FTDC_PLP_NonActive = '2' +THOST_FTDC_PLP_Canceled = '3' +THOST_FTDC_DM_CashDeliv = '1' +THOST_FTDC_DM_CommodityDeliv = '2' +THOST_FTDC_FIOT_FundIO = '1' +THOST_FTDC_FIOT_Transfer = '2' +THOST_FTDC_FIOT_SwapCurrency = '3' +THOST_FTDC_FT_Deposite = '1' +THOST_FTDC_FT_ItemFund = '2' +THOST_FTDC_FT_Company = '3' +THOST_FTDC_FT_InnerTransfer = '4' +THOST_FTDC_FD_In = '1' +THOST_FTDC_FD_Out = '2' +THOST_FTDC_FS_Record = '1' +THOST_FTDC_FS_Check = '2' +THOST_FTDC_FS_Charge = '3' +THOST_FTDC_PS_None = '1' +THOST_FTDC_PS_Publishing = '2' +THOST_FTDC_PS_Published = '3' +THOST_FTDC_ES_NonActive = '1' +THOST_FTDC_ES_Startup = '2' +THOST_FTDC_ES_Initialize = '3' +THOST_FTDC_ES_Initialized = '4' +THOST_FTDC_ES_Close = '5' +THOST_FTDC_ES_Closed = '6' +THOST_FTDC_ES_Settlement = '7' +THOST_FTDC_STS_Initialize = '0' +THOST_FTDC_STS_Settlementing = '1' +THOST_FTDC_STS_Settlemented = '2' +THOST_FTDC_STS_Finished = '3' +THOST_FTDC_CT_Person = '0' +THOST_FTDC_CT_Company = '1' +THOST_FTDC_CT_Fund = '2' +THOST_FTDC_CT_SpecialOrgan = '3' +THOST_FTDC_CT_Asset = '4' +THOST_FTDC_BT_Trade = '0' +THOST_FTDC_BT_TradeSettle = '1' +THOST_FTDC_FAS_Low = '1' +THOST_FTDC_FAS_Normal = '2' +THOST_FTDC_FAS_Focus = '3' +THOST_FTDC_FAS_Risk = '4' +THOST_FTDC_FAS_ByTrade = '1' +THOST_FTDC_FAS_ByDeliv = '2' +THOST_FTDC_FAS_None = '3' +THOST_FTDC_FAS_FixFee = '4' +THOST_FTDC_PWDT_Trade = '1' +THOST_FTDC_PWDT_Account = '2' +THOST_FTDC_AG_All = '1' +THOST_FTDC_AG_OnlyLost = '2' +THOST_FTDC_AG_OnlyGain = '3' +THOST_FTDC_AG_None = '4' +THOST_FTDC_ICP_Include = '0' +THOST_FTDC_ICP_NotInclude = '2' +THOST_FTDC_AWT_Enable = '0' +THOST_FTDC_AWT_Disable = '2' +THOST_FTDC_AWT_NoHoldEnable = '3' +THOST_FTDC_FPWD_UnCheck = '0' +THOST_FTDC_FPWD_Check = '1' +THOST_FTDC_TT_BankToFuture = '0' +THOST_FTDC_TT_FutureToBank = '1' +THOST_FTDC_TVF_Invalid = '0' +THOST_FTDC_TVF_Valid = '1' +THOST_FTDC_TVF_Reverse = '2' +THOST_FTDC_RN_CD = '0' +THOST_FTDC_RN_ZT = '1' +THOST_FTDC_RN_QT = '2' +THOST_FTDC_SEX_None = '0' +THOST_FTDC_SEX_Man = '1' +THOST_FTDC_SEX_Woman = '2' +THOST_FTDC_UT_Investor = '0' +THOST_FTDC_UT_Operator = '1' +THOST_FTDC_UT_SuperUser = '2' +THOST_FTDC_RATETYPE_MarginRate = '2' +THOST_FTDC_NOTETYPE_TradeSettleBill = '1' +THOST_FTDC_NOTETYPE_TradeSettleMonth = '2' +THOST_FTDC_NOTETYPE_CallMarginNotes = '3' +THOST_FTDC_NOTETYPE_ForceCloseNotes = '4' +THOST_FTDC_NOTETYPE_TradeNotes = '5' +THOST_FTDC_NOTETYPE_DelivNotes = '6' +THOST_FTDC_SBS_Day = '1' +THOST_FTDC_SBS_Volume = '2' +THOST_FTDC_ST_Day = '0' +THOST_FTDC_ST_Month = '1' +THOST_FTDC_URT_Logon = '1' +THOST_FTDC_URT_Transfer = '2' +THOST_FTDC_URT_EMail = '3' +THOST_FTDC_URT_Fax = '4' +THOST_FTDC_URT_ConditionOrder = '5' +THOST_FTDC_MPT_PreSettlementPrice = '1' +THOST_FTDC_MPT_SettlementPrice = '2' +THOST_FTDC_MPT_AveragePrice = '3' +THOST_FTDC_MPT_OpenPrice = '4' +THOST_FTDC_BGS_None = '0' +THOST_FTDC_BGS_NoGenerated = '1' +THOST_FTDC_BGS_Generated = '2' +THOST_FTDC_AT_HandlePositionAlgo = '1' +THOST_FTDC_AT_FindMarginRateAlgo = '2' +THOST_FTDC_HPA_Base = '1' +THOST_FTDC_HPA_DCE = '2' +THOST_FTDC_HPA_CZCE = '3' +THOST_FTDC_FMRA_Base = '1' +THOST_FTDC_FMRA_DCE = '2' +THOST_FTDC_FMRA_CZCE = '3' +THOST_FTDC_HTAA_Base = '1' +THOST_FTDC_HTAA_DCE = '2' +THOST_FTDC_HTAA_CZCE = '3' +THOST_FTDC_PST_Order = '1' +THOST_FTDC_PST_Open = '2' +THOST_FTDC_PST_Fund = '3' +THOST_FTDC_PST_Settlement = '4' +THOST_FTDC_PST_Company = '5' +THOST_FTDC_PST_Corporation = '6' +THOST_FTDC_PST_LinkMan = '7' +THOST_FTDC_PST_Ledger = '8' +THOST_FTDC_PST_Trustee = '9' +THOST_FTDC_PST_TrusteeCorporation = 'A' +THOST_FTDC_PST_TrusteeOpen = 'B' +THOST_FTDC_PST_TrusteeContact = 'C' +THOST_FTDC_PST_ForeignerRefer = 'D' +THOST_FTDC_PST_CorporationRefer = 'E' +THOST_FTDC_QIR_All = '1' +THOST_FTDC_QIR_Group = '2' +THOST_FTDC_QIR_Single = '3' +THOST_FTDC_IRS_Normal = '1' +THOST_FTDC_IRS_Warn = '2' +THOST_FTDC_IRS_Call = '3' +THOST_FTDC_IRS_Force = '4' +THOST_FTDC_IRS_Exception = '5' +THOST_FTDC_UET_Login = '1' +THOST_FTDC_UET_Logout = '2' +THOST_FTDC_UET_Trading = '3' +THOST_FTDC_UET_TradingError = '4' +THOST_FTDC_UET_UpdatePassword = '5' +THOST_FTDC_UET_Authenticate = '6' +THOST_FTDC_UET_Other = '9' +THOST_FTDC_ICS_Close = '0' +THOST_FTDC_ICS_CloseToday = '1' +THOST_FTDC_SM_Non = '0' +THOST_FTDC_SM_Instrument = '1' +THOST_FTDC_SM_Product = '2' +THOST_FTDC_SM_Investor = '3' +THOST_FTDC_PAOS_NotSend = '1' +THOST_FTDC_PAOS_Send = '2' +THOST_FTDC_PAOS_Deleted = '3' +THOST_FTDC_VDS_Dealing = '1' +THOST_FTDC_VDS_DeaclSucceed = '2' +THOST_FTDC_ORGS_Standard = '0' +THOST_FTDC_ORGS_ESunny = '1' +THOST_FTDC_ORGS_KingStarV6 = '2' +THOST_FTDC_VTS_NaturalDeal = '0' +THOST_FTDC_VTS_SucceedEnd = '1' +THOST_FTDC_VTS_FailedEND = '2' +THOST_FTDC_VTS_Exception = '3' +THOST_FTDC_VTS_ManualDeal = '4' +THOST_FTDC_VTS_MesException = '5' +THOST_FTDC_VTS_SysException = '6' +THOST_FTDC_VBAT_BankBook = '1' +THOST_FTDC_VBAT_BankCard = '2' +THOST_FTDC_VBAT_CreditCard = '3' +THOST_FTDC_VMS_Natural = '0' +THOST_FTDC_VMS_Canceled = '9' +THOST_FTDC_VAA_NoAvailAbility = '0' +THOST_FTDC_VAA_AvailAbility = '1' +THOST_FTDC_VAA_Repeal = '2' +THOST_FTDC_VTC_BankBankToFuture = '102001' +THOST_FTDC_VTC_BankFutureToBank = '102002' +THOST_FTDC_VTC_FutureBankToFuture = '202001' +THOST_FTDC_VTC_FutureFutureToBank = '202002' +THOST_FTDC_GEN_Program = '0' +THOST_FTDC_GEN_HandWork = '1' +THOST_FTDC_CFMMCKK_REQUEST = 'R' +THOST_FTDC_CFMMCKK_AUTO = 'A' +THOST_FTDC_CFMMCKK_MANUAL = 'M' +THOST_FTDC_CFT_IDCard = '0' +THOST_FTDC_CFT_Passport = '1' +THOST_FTDC_CFT_OfficerIDCard = '2' +THOST_FTDC_CFT_SoldierIDCard = '3' +THOST_FTDC_CFT_HomeComingCard = '4' +THOST_FTDC_CFT_HouseholdRegister = '5' +THOST_FTDC_CFT_LicenseNo = '6' +THOST_FTDC_CFT_InstitutionCodeCard = '7' +THOST_FTDC_CFT_TempLicenseNo = '8' +THOST_FTDC_CFT_NoEnterpriseLicenseNo = '9' +THOST_FTDC_CFT_OtherCard = 'x' +THOST_FTDC_CFT_SuperDepAgree = 'a' +THOST_FTDC_FBC_Others = '0' +THOST_FTDC_FBC_TransferDetails = '1' +THOST_FTDC_FBC_CustAccStatus = '2' +THOST_FTDC_FBC_AccountTradeDetails = '3' +THOST_FTDC_FBC_FutureAccountChangeInfoDetails = '4' +THOST_FTDC_FBC_CustMoneyDetail = '5' +THOST_FTDC_FBC_CustCancelAccountInfo = '6' +THOST_FTDC_FBC_CustMoneyResult = '7' +THOST_FTDC_FBC_OthersExceptionResult = '8' +THOST_FTDC_FBC_CustInterestNetMoneyDetails = '9' +THOST_FTDC_FBC_CustMoneySendAndReceiveDetails = 'a' +THOST_FTDC_FBC_CorporationMoneyTotal = 'b' +THOST_FTDC_FBC_MainbodyMoneyTotal = 'c' +THOST_FTDC_FBC_MainPartMonitorData = 'd' +THOST_FTDC_FBC_PreparationMoney = 'e' +THOST_FTDC_FBC_BankMoneyMonitorData = 'f' +THOST_FTDC_CEC_Exchange = '1' +THOST_FTDC_CEC_Cash = '2' +THOST_FTDC_YNI_Yes = '0' +THOST_FTDC_YNI_No = '1' +THOST_FTDC_BLT_CurrentMoney = '0' +THOST_FTDC_BLT_UsableMoney = '1' +THOST_FTDC_BLT_FetchableMoney = '2' +THOST_FTDC_BLT_FreezeMoney = '3' +THOST_FTDC_GD_Unknown = '0' +THOST_FTDC_GD_Male = '1' +THOST_FTDC_GD_Female = '2' +THOST_FTDC_FPF_BEN = '0' +THOST_FTDC_FPF_OUR = '1' +THOST_FTDC_FPF_SHA = '2' +THOST_FTDC_PWKT_ExchangeKey = '0' +THOST_FTDC_PWKT_PassWordKey = '1' +THOST_FTDC_PWKT_MACKey = '2' +THOST_FTDC_PWKT_MessageKey = '3' +THOST_FTDC_PWT_Query = '0' +THOST_FTDC_PWT_Fetch = '1' +THOST_FTDC_PWT_Transfer = '2' +THOST_FTDC_PWT_Trade = '3' +THOST_FTDC_EM_NoEncry = '0' +THOST_FTDC_EM_DES = '1' +THOST_FTDC_EM_3DES = '2' +THOST_FTDC_BRF_BankNotNeedRepeal = '0' +THOST_FTDC_BRF_BankWaitingRepeal = '1' +THOST_FTDC_BRF_BankBeenRepealed = '2' +THOST_FTDC_BRORF_BrokerNotNeedRepeal = '0' +THOST_FTDC_BRORF_BrokerWaitingRepeal = '1' +THOST_FTDC_BRORF_BrokerBeenRepealed = '2' +THOST_FTDC_TS_Bank = '0' +THOST_FTDC_TS_Future = '1' +THOST_FTDC_TS_Store = '2' +THOST_FTDC_LF_Yes = '0' +THOST_FTDC_LF_No = '1' +THOST_FTDC_BAS_Normal = '0' +THOST_FTDC_BAS_Freeze = '1' +THOST_FTDC_BAS_ReportLoss = '2' +THOST_FTDC_MAS_Normal = '0' +THOST_FTDC_MAS_Cancel = '1' +THOST_FTDC_MSS_Point = '0' +THOST_FTDC_MSS_PrePoint = '1' +THOST_FTDC_MSS_CancelPoint = '2' +THOST_FTDC_SYT_FutureBankTransfer = '0' +THOST_FTDC_SYT_StockBankTransfer = '1' +THOST_FTDC_SYT_TheThirdPartStore = '2' +THOST_FTDC_TEF_NormalProcessing = '0' +THOST_FTDC_TEF_Success = '1' +THOST_FTDC_TEF_Failed = '2' +THOST_FTDC_TEF_Abnormal = '3' +THOST_FTDC_TEF_ManualProcessedForException = '4' +THOST_FTDC_TEF_CommuFailedNeedManualProcess = '5' +THOST_FTDC_TEF_SysErrorNeedManualProcess = '6' +THOST_FTDC_PSS_NotProcess = '0' +THOST_FTDC_PSS_StartProcess = '1' +THOST_FTDC_PSS_Finished = '2' +THOST_FTDC_CUSTT_Person = '0' +THOST_FTDC_CUSTT_Institution = '1' +THOST_FTDC_FBTTD_FromBankToFuture = '1' +THOST_FTDC_FBTTD_FromFutureToBank = '2' +THOST_FTDC_OOD_Open = '1' +THOST_FTDC_OOD_Destroy = '0' +THOST_FTDC_AVAF_Invalid = '0' +THOST_FTDC_AVAF_Valid = '1' +THOST_FTDC_AVAF_Repeal = '2' +THOST_FTDC_OT_Bank = '1' +THOST_FTDC_OT_Future = '2' +THOST_FTDC_OT_PlateForm = '9' +THOST_FTDC_OL_HeadQuarters = '1' +THOST_FTDC_OL_Branch = '2' +THOST_FTDC_PID_FutureProtocal = '0' +THOST_FTDC_PID_ICBCProtocal = '1' +THOST_FTDC_PID_ABCProtocal = '2' +THOST_FTDC_PID_CBCProtocal = '3' +THOST_FTDC_PID_CCBProtocal = '4' +THOST_FTDC_PID_BOCOMProtocal = '5' +THOST_FTDC_PID_FBTPlateFormProtocal = 'X' +THOST_FTDC_CM_ShortConnect = '0' +THOST_FTDC_CM_LongConnect = '1' +THOST_FTDC_SRM_ASync = '0' +THOST_FTDC_SRM_Sync = '1' +THOST_FTDC_BAT_BankBook = '1' +THOST_FTDC_BAT_SavingCard = '2' +THOST_FTDC_BAT_CreditCard = '3' +THOST_FTDC_FAT_BankBook = '1' +THOST_FTDC_FAT_SavingCard = '2' +THOST_FTDC_FAT_CreditCard = '3' +THOST_FTDC_OS_Ready = '0' +THOST_FTDC_OS_CheckIn = '1' +THOST_FTDC_OS_CheckOut = '2' +THOST_FTDC_OS_CheckFileArrived = '3' +THOST_FTDC_OS_CheckDetail = '4' +THOST_FTDC_OS_DayEndClean = '5' +THOST_FTDC_OS_Invalid = '9' +THOST_FTDC_CCBFM_ByAmount = '1' +THOST_FTDC_CCBFM_ByMonth = '2' +THOST_FTDC_CAPIT_Client = '1' +THOST_FTDC_CAPIT_Server = '2' +THOST_FTDC_CAPIT_UserApi = '3' +THOST_FTDC_LS_Connected = '1' +THOST_FTDC_LS_Disconnected = '2' +THOST_FTDC_BPWDF_NoCheck = '0' +THOST_FTDC_BPWDF_BlankCheck = '1' +THOST_FTDC_BPWDF_EncryptCheck = '2' +THOST_FTDC_SAT_AccountID = '1' +THOST_FTDC_SAT_CardID = '2' +THOST_FTDC_SAT_SHStockholderID = '3' +THOST_FTDC_SAT_SZStockholderID = '4' +THOST_FTDC_TRFS_Normal = '0' +THOST_FTDC_TRFS_Repealed = '1' +THOST_FTDC_SPTYPE_Broker = '0' +THOST_FTDC_SPTYPE_Bank = '1' +THOST_FTDC_REQRSP_Request = '0' +THOST_FTDC_REQRSP_Response = '1' +THOST_FTDC_FBTUET_SignIn = '0' +THOST_FTDC_FBTUET_FromBankToFuture = '1' +THOST_FTDC_FBTUET_FromFutureToBank = '2' +THOST_FTDC_FBTUET_OpenAccount = '3' +THOST_FTDC_FBTUET_CancelAccount = '4' +THOST_FTDC_FBTUET_ChangeAccount = '5' +THOST_FTDC_FBTUET_RepealFromBankToFuture = '6' +THOST_FTDC_FBTUET_RepealFromFutureToBank = '7' +THOST_FTDC_FBTUET_QueryBankAccount = '8' +THOST_FTDC_FBTUET_QueryFutureAccount = '9' +THOST_FTDC_FBTUET_SignOut = 'A' +THOST_FTDC_FBTUET_SyncKey = 'B' +THOST_FTDC_FBTUET_ReserveOpenAccount = 'C' +THOST_FTDC_FBTUET_CancelReserveOpenAccount = 'D' +THOST_FTDC_FBTUET_ReserveOpenAccountConfirm = 'E' +THOST_FTDC_FBTUET_Other = 'Z' +THOST_FTDC_DBOP_Insert = '0' +THOST_FTDC_DBOP_Update = '1' +THOST_FTDC_DBOP_Delete = '2' +THOST_FTDC_SYNF_Yes = '0' +THOST_FTDC_SYNF_No = '1' +THOST_FTDC_SYNT_OneOffSync = '0' +THOST_FTDC_SYNT_TimerSync = '1' +THOST_FTDC_SYNT_TimerFullSync = '2' +THOST_FTDC_FBEDIR_Settlement = '0' +THOST_FTDC_FBEDIR_Sale = '1' +THOST_FTDC_FBERES_Success = '0' +THOST_FTDC_FBERES_InsufficientBalance = '1' +THOST_FTDC_FBERES_UnknownTrading = '8' +THOST_FTDC_FBERES_Fail = 'x' +THOST_FTDC_FBEES_Normal = '0' +THOST_FTDC_FBEES_ReExchange = '1' +THOST_FTDC_FBEFG_DataPackage = '0' +THOST_FTDC_FBEFG_File = '1' +THOST_FTDC_FBEAT_NotTrade = '0' +THOST_FTDC_FBEAT_Trade = '1' +THOST_FTDC_FBEUET_SignIn = '0' +THOST_FTDC_FBEUET_Exchange = '1' +THOST_FTDC_FBEUET_ReExchange = '2' +THOST_FTDC_FBEUET_QueryBankAccount = '3' +THOST_FTDC_FBEUET_QueryExchDetial = '4' +THOST_FTDC_FBEUET_QueryExchSummary = '5' +THOST_FTDC_FBEUET_QueryExchRate = '6' +THOST_FTDC_FBEUET_CheckBankAccount = '7' +THOST_FTDC_FBEUET_SignOut = '8' +THOST_FTDC_FBEUET_Other = 'Z' +THOST_FTDC_FBERF_UnProcessed = '0' +THOST_FTDC_FBERF_WaitSend = '1' +THOST_FTDC_FBERF_SendSuccess = '2' +THOST_FTDC_FBERF_SendFailed = '3' +THOST_FTDC_FBERF_WaitReSend = '4' +THOST_FTDC_NC_NOERROR = '0' +THOST_FTDC_NC_Warn = '1' +THOST_FTDC_NC_Call = '2' +THOST_FTDC_NC_Force = '3' +THOST_FTDC_NC_CHUANCANG = '4' +THOST_FTDC_NC_Exception = '5' +THOST_FTDC_FCT_Manual = '0' +THOST_FTDC_FCT_Single = '1' +THOST_FTDC_FCT_Group = '2' +THOST_FTDC_RNM_System = '0' +THOST_FTDC_RNM_SMS = '1' +THOST_FTDC_RNM_EMail = '2' +THOST_FTDC_RNM_Manual = '3' +THOST_FTDC_RNS_NotGen = '0' +THOST_FTDC_RNS_Generated = '1' +THOST_FTDC_RNS_SendError = '2' +THOST_FTDC_RNS_SendOk = '3' +THOST_FTDC_RNS_Received = '4' +THOST_FTDC_RNS_Confirmed = '5' +THOST_FTDC_RUE_ExportData = '0' +THOST_FTDC_COST_LastPriceAsc = '0' +THOST_FTDC_COST_LastPriceDesc = '1' +THOST_FTDC_COST_AskPriceAsc = '2' +THOST_FTDC_COST_AskPriceDesc = '3' +THOST_FTDC_COST_BidPriceAsc = '4' +THOST_FTDC_COST_BidPriceDesc = '5' +THOST_FTDC_UOAST_NoSend = '0' +THOST_FTDC_UOAST_Sended = '1' +THOST_FTDC_UOAST_Generated = '2' +THOST_FTDC_UOAST_SendFail = '3' +THOST_FTDC_UOAST_Success = '4' +THOST_FTDC_UOAST_Fail = '5' +THOST_FTDC_UOAST_Cancel = '6' +THOST_FTDC_UOACS_NoApply = '1' +THOST_FTDC_UOACS_Submited = '2' +THOST_FTDC_UOACS_Sended = '3' +THOST_FTDC_UOACS_Success = '4' +THOST_FTDC_UOACS_Refuse = '5' +THOST_FTDC_UOACS_Cancel = '6' +THOST_FTDC_QT_Radio = '1' +THOST_FTDC_QT_Option = '2' +THOST_FTDC_QT_Blank = '3' +THOST_FTDC_BT_Request = '1' +THOST_FTDC_BT_Response = '2' +THOST_FTDC_BT_Notice = '3' +THOST_FTDC_CRC_Success = '0' +THOST_FTDC_CRC_Working = '1' +THOST_FTDC_CRC_InfoFail = '2' +THOST_FTDC_CRC_IDCardFail = '3' +THOST_FTDC_CRC_OtherFail = '4' +THOST_FTDC_CfMMCCT_All = '0' +THOST_FTDC_CfMMCCT_Person = '1' +THOST_FTDC_CfMMCCT_Company = '2' +THOST_FTDC_CfMMCCT_Other = '3' +THOST_FTDC_CfMMCCT_SpecialOrgan = '4' +THOST_FTDC_CfMMCCT_Asset = '5' +THOST_FTDC_EIDT_SHFE = 'S' +THOST_FTDC_EIDT_CZCE = 'Z' +THOST_FTDC_EIDT_DCE = 'D' +THOST_FTDC_EIDT_CFFEX = 'J' +THOST_FTDC_EIDT_INE = 'N' +THOST_FTDC_ECIDT_Hedge = '1' +THOST_FTDC_ECIDT_Arbitrage = '2' +THOST_FTDC_ECIDT_Speculation = '3' +THOST_FTDC_UF_NoUpdate = '0' +THOST_FTDC_UF_Success = '1' +THOST_FTDC_UF_Fail = '2' +THOST_FTDC_UF_TCSuccess = '3' +THOST_FTDC_UF_TCFail = '4' +THOST_FTDC_UF_Cancel = '5' +THOST_FTDC_AOID_OpenInvestor = '1' +THOST_FTDC_AOID_ModifyIDCard = '2' +THOST_FTDC_AOID_ModifyNoIDCard = '3' +THOST_FTDC_AOID_ApplyTradingCode = '4' +THOST_FTDC_AOID_CancelTradingCode = '5' +THOST_FTDC_AOID_CancelInvestor = '6' +THOST_FTDC_AOID_FreezeAccount = '8' +THOST_FTDC_AOID_ActiveFreezeAccount = '9' +THOST_FTDC_ASID_NoComplete = '1' +THOST_FTDC_ASID_Submited = '2' +THOST_FTDC_ASID_Checked = '3' +THOST_FTDC_ASID_Refused = '4' +THOST_FTDC_ASID_Deleted = '5' +THOST_FTDC_UOASM_ByAPI = '1' +THOST_FTDC_UOASM_ByFile = '2' +THOST_FTDC_EvM_ADD = '1' +THOST_FTDC_EvM_UPDATE = '2' +THOST_FTDC_EvM_DELETE = '3' +THOST_FTDC_EvM_CHECK = '4' +THOST_FTDC_EvM_COPY = '5' +THOST_FTDC_EvM_CANCEL = '6' +THOST_FTDC_EvM_Reverse = '7' +THOST_FTDC_UOAA_ASR = '1' +THOST_FTDC_UOAA_ASNR = '2' +THOST_FTDC_UOAA_NSAR = '3' +THOST_FTDC_UOAA_NSR = '4' +THOST_FTDC_EvM_InvestorGroupFlow = '1' +THOST_FTDC_EvM_InvestorRate = '2' +THOST_FTDC_EvM_InvestorCommRateModel = '3' +THOST_FTDC_CL_Zero = '0' +THOST_FTDC_CL_One = '1' +THOST_FTDC_CL_Two = '2' +THOST_FTDC_CHS_Init = '0' +THOST_FTDC_CHS_Checking = '1' +THOST_FTDC_CHS_Checked = '2' +THOST_FTDC_CHS_Refuse = '3' +THOST_FTDC_CHS_Cancel = '4' +THOST_FTDC_CHU_Unused = '0' +THOST_FTDC_CHU_Used = '1' +THOST_FTDC_CHU_Fail = '2' +THOST_FTDC_BAO_ByAccProperty = '0' +THOST_FTDC_BAO_ByFBTransfer = '1' +THOST_FTDC_MBTS_ByInstrument = '0' +THOST_FTDC_MBTS_ByDayInsPrc = '1' +THOST_FTDC_MBTS_ByDayIns = '2' +THOST_FTDC_FTC_BankLaunchBankToBroker = '102001' +THOST_FTDC_FTC_BrokerLaunchBankToBroker = '202001' +THOST_FTDC_FTC_BankLaunchBrokerToBank = '102002' +THOST_FTDC_FTC_BrokerLaunchBrokerToBank = '202002' +THOST_FTDC_OTP_NONE = '0' +THOST_FTDC_OTP_TOTP = '1' +THOST_FTDC_OTPS_Unused = '0' +THOST_FTDC_OTPS_Used = '1' +THOST_FTDC_OTPS_Disuse = '2' +THOST_FTDC_BUT_Investor = '1' +THOST_FTDC_BUT_BrokerUser = '2' +THOST_FTDC_FUTT_Commodity = '1' +THOST_FTDC_FUTT_Financial = '2' +THOST_FTDC_FET_Restriction = '0' +THOST_FTDC_FET_TodayRestriction = '1' +THOST_FTDC_FET_Transfer = '2' +THOST_FTDC_FET_Credit = '3' +THOST_FTDC_FET_InvestorWithdrawAlm = '4' +THOST_FTDC_FET_BankRestriction = '5' +THOST_FTDC_FET_Accountregister = '6' +THOST_FTDC_FET_ExchangeFundIO = '7' +THOST_FTDC_FET_InvestorFundIO = '8' +THOST_FTDC_AST_FBTransfer = '0' +THOST_FTDC_AST_ManualEntry = '1' +THOST_FTDC_CST_UnifyAccount = '0' +THOST_FTDC_CST_ManualEntry = '1' +THOST_FTDC_UR_All = '0' +THOST_FTDC_UR_Single = '1' +THOST_FTDC_BG_Investor = '2' +THOST_FTDC_BG_Group = '1' +THOST_FTDC_TSSM_Instrument = '1' +THOST_FTDC_TSSM_Product = '2' +THOST_FTDC_TSSM_Exchange = '3' +THOST_FTDC_ESM_Relative = '1' +THOST_FTDC_ESM_Typical = '2' +THOST_FTDC_RIR_All = '1' +THOST_FTDC_RIR_Model = '2' +THOST_FTDC_RIR_Single = '3' +THOST_FTDC_SDS_Initialize = '0' +THOST_FTDC_SDS_Settlementing = '1' +THOST_FTDC_SDS_Settlemented = '2' +THOST_FTDC_TSRC_NORMAL = '0' +THOST_FTDC_TSRC_QUERY = '1' +THOST_FTDC_FSM_Product = '1' +THOST_FTDC_FSM_Exchange = '2' +THOST_FTDC_FSM_All = '3' +THOST_FTDC_BIR_Property = '1' +THOST_FTDC_BIR_All = '2' +THOST_FTDC_PIR_All = '1' +THOST_FTDC_PIR_Property = '2' +THOST_FTDC_PIR_Single = '3' +THOST_FTDC_FIS_NoCreate = '0' +THOST_FTDC_FIS_Created = '1' +THOST_FTDC_FIS_Failed = '2' +THOST_FTDC_FGS_FileTransmit = '0' +THOST_FTDC_FGS_FileGen = '1' +THOST_FTDC_SoM_Add = '1' +THOST_FTDC_SoM_Update = '2' +THOST_FTDC_SoM_Delete = '3' +THOST_FTDC_SoM_Copy = '4' +THOST_FTDC_SoM_AcTive = '5' +THOST_FTDC_SoM_CanCel = '6' +THOST_FTDC_SoM_ReSet = '7' +THOST_FTDC_SoT_UpdatePassword = '0' +THOST_FTDC_SoT_UserDepartment = '1' +THOST_FTDC_SoT_RoleManager = '2' +THOST_FTDC_SoT_RoleFunction = '3' +THOST_FTDC_SoT_BaseParam = '4' +THOST_FTDC_SoT_SetUserID = '5' +THOST_FTDC_SoT_SetUserRole = '6' +THOST_FTDC_SoT_UserIpRestriction = '7' +THOST_FTDC_SoT_DepartmentManager = '8' +THOST_FTDC_SoT_DepartmentCopy = '9' +THOST_FTDC_SoT_Tradingcode = 'A' +THOST_FTDC_SoT_InvestorStatus = 'B' +THOST_FTDC_SoT_InvestorAuthority = 'C' +THOST_FTDC_SoT_PropertySet = 'D' +THOST_FTDC_SoT_ReSetInvestorPasswd = 'E' +THOST_FTDC_SoT_InvestorPersonalityInfo = 'F' +THOST_FTDC_CSRCQ_Current = '0' +THOST_FTDC_CSRCQ_History = '1' +THOST_FTDC_FRS_Normal = '1' +THOST_FTDC_FRS_Freeze = '0' +THOST_FTDC_STST_Standard = '0' +THOST_FTDC_STST_NonStandard = '1' +THOST_FTDC_RPT_Freeze = '1' +THOST_FTDC_RPT_FreezeActive = '2' +THOST_FTDC_RPT_OpenLimit = '3' +THOST_FTDC_RPT_RelieveOpenLimit = '4' +THOST_FTDC_AMLDS_Normal = '0' +THOST_FTDC_AMLDS_Deleted = '1' +THOST_FTDC_AMLCHS_Init = '0' +THOST_FTDC_AMLCHS_Checking = '1' +THOST_FTDC_AMLCHS_Checked = '2' +THOST_FTDC_AMLCHS_RefuseReport = '3' +THOST_FTDC_AMLDT_DrawDay = '0' +THOST_FTDC_AMLDT_TouchDay = '1' +THOST_FTDC_AMLCL_CheckLevel0 = '0' +THOST_FTDC_AMLCL_CheckLevel1 = '1' +THOST_FTDC_AMLCL_CheckLevel2 = '2' +THOST_FTDC_AMLCL_CheckLevel3 = '3' +THOST_FTDC_EFT_CSV = '0' +THOST_FTDC_EFT_EXCEL = '1' +THOST_FTDC_EFT_DBF = '2' +THOST_FTDC_SMT_Before = '1' +THOST_FTDC_SMT_Settlement = '2' +THOST_FTDC_SMT_After = '3' +THOST_FTDC_SMT_Settlemented = '4' +THOST_FTDC_SML_Must = '1' +THOST_FTDC_SML_Alarm = '2' +THOST_FTDC_SML_Prompt = '3' +THOST_FTDC_SML_Ignore = '4' +THOST_FTDC_SMG_Exhcange = '1' +THOST_FTDC_SMG_ASP = '2' +THOST_FTDC_SMG_CSRC = '3' +THOST_FTDC_LUT_Repeatable = '1' +THOST_FTDC_LUT_Unrepeatable = '2' +THOST_FTDC_DAR_Settle = '1' +THOST_FTDC_DAR_Exchange = '2' +THOST_FTDC_DAR_CSRC = '3' +THOST_FTDC_MGT_ExchMarginRate = '0' +THOST_FTDC_MGT_InstrMarginRate = '1' +THOST_FTDC_MGT_InstrMarginRateTrade = '2' +THOST_FTDC_ACT_Intraday = '1' +THOST_FTDC_ACT_Long = '2' +THOST_FTDC_MRT_Exchange = '1' +THOST_FTDC_MRT_Investor = '2' +THOST_FTDC_MRT_InvestorTrade = '3' +THOST_FTDC_BUS_UnBak = '0' +THOST_FTDC_BUS_BakUp = '1' +THOST_FTDC_BUS_BakUped = '2' +THOST_FTDC_BUS_BakFail = '3' +THOST_FTDC_SIS_UnInitialize = '0' +THOST_FTDC_SIS_Initialize = '1' +THOST_FTDC_SIS_Initialized = '2' +THOST_FTDC_SRS_NoCreate = '0' +THOST_FTDC_SRS_Create = '1' +THOST_FTDC_SRS_Created = '2' +THOST_FTDC_SRS_CreateFail = '3' +THOST_FTDC_SSS_UnSaveData = '0' +THOST_FTDC_SSS_SaveDatad = '1' +THOST_FTDC_SAS_UnArchived = '0' +THOST_FTDC_SAS_Archiving = '1' +THOST_FTDC_SAS_Archived = '2' +THOST_FTDC_SAS_ArchiveFail = '3' +THOST_FTDC_CTPT_Unkown = '0' +THOST_FTDC_CTPT_MainCenter = '1' +THOST_FTDC_CTPT_BackUp = '2' +THOST_FTDC_CDT_Normal = '0' +THOST_FTDC_CDT_SpecFirst = '1' +THOST_FTDC_MFUR_None = '0' +THOST_FTDC_MFUR_Margin = '1' +THOST_FTDC_MFUR_All = '2' +THOST_FTDC_MFUR_CNY3 = '3' +THOST_FTDC_SPT_CzceHedge = '1' +THOST_FTDC_SPT_IneForeignCurrency = '2' +THOST_FTDC_SPT_DceOpenClose = '3' +THOST_FTDC_FMT_Mortgage = '1' +THOST_FTDC_FMT_Redemption = '2' +THOST_FTDC_ASPI_BaseMargin = '1' +THOST_FTDC_ASPI_LowestInterest = '2' +THOST_FTDC_FMD_In = '1' +THOST_FTDC_FMD_Out = '2' +THOST_FTDC_BT_Profit = '0' +THOST_FTDC_BT_Loss = '1' +THOST_FTDC_BT_Other = 'Z' +THOST_FTDC_SST_Manual = '0' +THOST_FTDC_SST_Automatic = '1' +THOST_FTDC_CED_Settlement = '0' +THOST_FTDC_CED_Sale = '1' +THOST_FTDC_CSS_Entry = '1' +THOST_FTDC_CSS_Approve = '2' +THOST_FTDC_CSS_Refuse = '3' +THOST_FTDC_CSS_Revoke = '4' +THOST_FTDC_CSS_Send = '5' +THOST_FTDC_CSS_Success = '6' +THOST_FTDC_CSS_Failure = '7' +THOST_FTDC_REQF_NoSend = '0' +THOST_FTDC_REQF_SendSuccess = '1' +THOST_FTDC_REQF_SendFailed = '2' +THOST_FTDC_REQF_WaitReSend = '3' +THOST_FTDC_RESF_Success = '0' +THOST_FTDC_RESF_InsuffiCient = '1' +THOST_FTDC_RESF_UnKnown = '8' +THOST_FTDC_EXS_Before = '0' +THOST_FTDC_EXS_After = '1' +THOST_FTDC_CR_Domestic = '1' +THOST_FTDC_CR_GMT = '2' +THOST_FTDC_CR_Foreign = '3' +THOST_FTDC_HB_No = '0' +THOST_FTDC_HB_Yes = '1' +THOST_FTDC_SM_Normal = '1' +THOST_FTDC_SM_Emerge = '2' +THOST_FTDC_SM_Restore = '3' +THOST_FTDC_TPT_Full = '1' +THOST_FTDC_TPT_Increment = '2' +THOST_FTDC_TPT_BackUp = '3' +THOST_FTDC_LM_Trade = '0' +THOST_FTDC_LM_Transfer = '1' +THOST_FTDC_CPT_Instrument = '1' +THOST_FTDC_CPT_Margin = '2' +THOST_FTDC_HT_Yes = '1' +THOST_FTDC_HT_No = '0' +THOST_FTDC_AMT_Bank = '1' +THOST_FTDC_AMT_Securities = '2' +THOST_FTDC_AMT_Fund = '3' +THOST_FTDC_AMT_Insurance = '4' +THOST_FTDC_AMT_Trust = '5' +THOST_FTDC_AMT_Other = '9' +THOST_FTDC_CFIOT_FundIO = '0' +THOST_FTDC_CFIOT_SwapCurrency = '1' +THOST_FTDC_CAT_Futures = '1' +THOST_FTDC_CAT_AssetmgrFuture = '2' +THOST_FTDC_CAT_AssetmgrTrustee = '3' +THOST_FTDC_CAT_AssetmgrTransfer = '4' +THOST_FTDC_LT_Chinese = '1' +THOST_FTDC_LT_English = '2' +THOST_FTDC_AMCT_Person = '1' +THOST_FTDC_AMCT_Organ = '2' +THOST_FTDC_AMCT_SpecialOrgan = '4' +THOST_FTDC_ASST_Futures = '3' +THOST_FTDC_ASST_SpecialOrgan = '4' +THOST_FTDC_CIT_HasExch = '0' +THOST_FTDC_CIT_HasATP = '1' +THOST_FTDC_CIT_HasDiff = '2' +THOST_FTDC_DT_HandDeliv = '1' +THOST_FTDC_DT_PersonDeliv = '2' +THOST_FTDC_MMSA_NO = '0' +THOST_FTDC_MMSA_YES = '1' +THOST_FTDC_CACT_Person = '0' +THOST_FTDC_CACT_Company = '1' +THOST_FTDC_CACT_Other = '2' +THOST_FTDC_UOAAT_Futures = '1' +THOST_FTDC_UOAAT_SpecialOrgan = '2' +THOST_FTDC_DEN_Buy = '0' +THOST_FTDC_DEN_Sell = '1' +THOST_FTDC_OFEN_Open = '0' +THOST_FTDC_OFEN_Close = '1' +THOST_FTDC_OFEN_ForceClose = '2' +THOST_FTDC_OFEN_CloseToday = '3' +THOST_FTDC_OFEN_CloseYesterday = '4' +THOST_FTDC_OFEN_ForceOff = '5' +THOST_FTDC_OFEN_LocalForceClose = '6' +THOST_FTDC_HFEN_Speculation = '1' +THOST_FTDC_HFEN_Arbitrage = '2' +THOST_FTDC_HFEN_Hedge = '3' +THOST_FTDC_FIOTEN_FundIO = '1' +THOST_FTDC_FIOTEN_Transfer = '2' +THOST_FTDC_FIOTEN_SwapCurrency = '3' +THOST_FTDC_FTEN_Deposite = '1' +THOST_FTDC_FTEN_ItemFund = '2' +THOST_FTDC_FTEN_Company = '3' +THOST_FTDC_FTEN_InnerTransfer = '4' +THOST_FTDC_FDEN_In = '1' +THOST_FTDC_FDEN_Out = '2' +THOST_FTDC_FMDEN_In = '1' +THOST_FTDC_FMDEN_Out = '2' +THOST_FTDC_CP_CallOptions = '1' +THOST_FTDC_CP_PutOptions = '2' +THOST_FTDC_STM_Continental = '0' +THOST_FTDC_STM_American = '1' +THOST_FTDC_STM_Bermuda = '2' +THOST_FTDC_STT_Hedge = '0' +THOST_FTDC_STT_Match = '1' +THOST_FTDC_APPT_NotStrikeNum = '4' +THOST_FTDC_GUDS_Gen = '0' +THOST_FTDC_GUDS_Hand = '1' +THOST_FTDC_OER_NoExec = 'n' +THOST_FTDC_OER_Canceled = 'c' +THOST_FTDC_OER_OK = '0' +THOST_FTDC_OER_NoPosition = '1' +THOST_FTDC_OER_NoDeposit = '2' +THOST_FTDC_OER_NoParticipant = '3' +THOST_FTDC_OER_NoClient = '4' +THOST_FTDC_OER_NoInstrument = '6' +THOST_FTDC_OER_NoRight = '7' +THOST_FTDC_OER_InvalidVolume = '8' +THOST_FTDC_OER_NoEnoughHistoryTrade = '9' +THOST_FTDC_OER_Unknown = 'a' +THOST_FTDC_COMBT_Future = '0' +THOST_FTDC_COMBT_BUL = '1' +THOST_FTDC_COMBT_BER = '2' +THOST_FTDC_COMBT_STD = '3' +THOST_FTDC_COMBT_STG = '4' +THOST_FTDC_COMBT_PRT = '5' +THOST_FTDC_COMBT_CLD = '6' +THOST_FTDC_DCECOMBT_SPL = '0' +THOST_FTDC_DCECOMBT_OPL = '1' +THOST_FTDC_DCECOMBT_SP = '2' +THOST_FTDC_DCECOMBT_SPC = '3' +THOST_FTDC_DCECOMBT_BLS = '4' +THOST_FTDC_DCECOMBT_BES = '5' +THOST_FTDC_DCECOMBT_CAS = '6' +THOST_FTDC_DCECOMBT_STD = '7' +THOST_FTDC_DCECOMBT_STG = '8' +THOST_FTDC_DCECOMBT_BFO = '9' +THOST_FTDC_DCECOMBT_SFO = 'a' +THOST_FTDC_ORPT_PreSettlementPrice = '1' +THOST_FTDC_ORPT_OpenPrice = '4' +THOST_FTDC_ORPT_MaxPreSettlementPrice = '5' +THOST_FTDC_BLAG_Default = '1' +THOST_FTDC_BLAG_IncludeOptValLost = '2' +THOST_FTDC_ACTP_Exec = '1' +THOST_FTDC_ACTP_Abandon = '2' +THOST_FTDC_FQST_Submitted = 'a' +THOST_FTDC_FQST_Accepted = 'b' +THOST_FTDC_FQST_Rejected = 'c' +THOST_FTDC_VM_Absolute = '0' +THOST_FTDC_VM_Ratio = '1' +THOST_FTDC_EOPF_Reserve = '0' +THOST_FTDC_EOPF_UnReserve = '1' +THOST_FTDC_EOCF_AutoClose = '0' +THOST_FTDC_EOCF_NotToClose = '1' +THOST_FTDC_PTE_Futures = '1' +THOST_FTDC_PTE_Options = '2' +THOST_FTDC_CUFN_CUFN_O = 'O' +THOST_FTDC_CUFN_CUFN_T = 'T' +THOST_FTDC_CUFN_CUFN_P = 'P' +THOST_FTDC_CUFN_CUFN_N = 'N' +THOST_FTDC_CUFN_CUFN_L = 'L' +THOST_FTDC_CUFN_CUFN_F = 'F' +THOST_FTDC_CUFN_CUFN_C = 'C' +THOST_FTDC_CUFN_CUFN_M = 'M' +THOST_FTDC_DUFN_DUFN_O = 'O' +THOST_FTDC_DUFN_DUFN_T = 'T' +THOST_FTDC_DUFN_DUFN_P = 'P' +THOST_FTDC_DUFN_DUFN_F = 'F' +THOST_FTDC_DUFN_DUFN_C = 'C' +THOST_FTDC_DUFN_DUFN_D = 'D' +THOST_FTDC_DUFN_DUFN_M = 'M' +THOST_FTDC_DUFN_DUFN_S = 'S' +THOST_FTDC_SUFN_SUFN_O = 'O' +THOST_FTDC_SUFN_SUFN_T = 'T' +THOST_FTDC_SUFN_SUFN_P = 'P' +THOST_FTDC_SUFN_SUFN_F = 'F' +THOST_FTDC_CFUFN_SUFN_T = 'T' +THOST_FTDC_CFUFN_SUFN_P = 'P' +THOST_FTDC_CFUFN_SUFN_F = 'F' +THOST_FTDC_CFUFN_SUFN_S = 'S' +THOST_FTDC_CMDR_Comb = '0' +THOST_FTDC_CMDR_UnComb = '1' +THOST_FTDC_STOV_RealValue = '1' +THOST_FTDC_STOV_ProfitValue = '2' +THOST_FTDC_STOV_RealRatio = '3' +THOST_FTDC_STOV_ProfitRatio = '4' +THOST_FTDC_ROAST_Processing = '0' +THOST_FTDC_ROAST_Cancelled = '1' +THOST_FTDC_ROAST_Opened = '2' +THOST_FTDC_ROAST_Invalid = '3' +THOST_FTDC_WPSR_Lib = '1' +THOST_FTDC_WPSR_Manual = '2' +THOST_FTDC_OSCF_CloseSelfOptionPosition = '1' +THOST_FTDC_OSCF_ReserveOptionPosition = '2' +THOST_FTDC_OSCF_SellCloseSelfFuturePosition = '3' +THOST_FTDC_OSCF_ReserveFuturePosition = '4' +THOST_FTDC_BZTP_Future = '1' +THOST_FTDC_BZTP_Stock = '2' +THOST_FTDC_APP_TYPE_Investor = '1' +THOST_FTDC_APP_TYPE_InvestorRelay = '2' +THOST_FTDC_APP_TYPE_OperatorRelay = '3' +THOST_FTDC_APP_TYPE_UnKnown = '4' +THOST_FTDC_RV_Right = '0' +THOST_FTDC_RV_Refuse = '1' +THOST_FTDC_OTC_TRDT_Block = '0' +THOST_FTDC_OTC_TRDT_EFP = '1' +THOST_FTDC_OTC_MT_DV01 = '1' +THOST_FTDC_OTC_MT_ParValue = '2' diff --git a/vnpy/gateway/rohon/rohon_gateway.py b/vnpy/gateway/rohon/rohon_gateway.py new file mode 100644 index 00000000..c41744eb --- /dev/null +++ b/vnpy/gateway/rohon/rohon_gateway.py @@ -0,0 +1,804 @@ +""" +""" + +from datetime import datetime + +from .vnctpmd import MdApi +from .vnctptd import TdApi +from .ctp_constant import ( + THOST_FTDC_OAS_Submitted, + THOST_FTDC_OAS_Accepted, + THOST_FTDC_OAS_Rejected, + THOST_FTDC_OST_NoTradeQueueing, + THOST_FTDC_OST_PartTradedQueueing, + THOST_FTDC_OST_AllTraded, + THOST_FTDC_OST_Canceled, + THOST_FTDC_D_Buy, + THOST_FTDC_D_Sell, + THOST_FTDC_PD_Long, + THOST_FTDC_PD_Short, + THOST_FTDC_OPT_LimitPrice, + THOST_FTDC_OPT_AnyPrice, + THOST_FTDC_OF_Open, + THOST_FTDC_OFEN_Close, + THOST_FTDC_OFEN_CloseYesterday, + THOST_FTDC_OFEN_CloseToday, + THOST_FTDC_PC_Futures, + THOST_FTDC_PC_Options, + THOST_FTDC_PC_Combination, + THOST_FTDC_CP_CallOptions, + THOST_FTDC_CP_PutOptions, + THOST_FTDC_HF_Speculation, + THOST_FTDC_CC_Immediately, + THOST_FTDC_FCC_NotForceClose, + THOST_FTDC_TC_GFD, + THOST_FTDC_VC_AV, + THOST_FTDC_TC_IOC, + THOST_FTDC_VC_CV, + THOST_FTDC_AF_Delete +) +from vnpy.trader.constant import ( + Direction, + Offset, + Exchange, + OrderType, + Product, + Status, + OptionType +) +from vnpy.trader.gateway import BaseGateway +from vnpy.trader.object import ( + TickData, + OrderData, + TradeData, + PositionData, + AccountData, + ContractData, + OrderRequest, + CancelRequest, + SubscribeRequest, +) +from vnpy.trader.utility import get_folder_path +from vnpy.trader.event import EVENT_TIMER + + +STATUS_ROHON2VT = { + THOST_FTDC_OAS_Submitted: Status.SUBMITTING, + THOST_FTDC_OAS_Accepted: Status.SUBMITTING, + THOST_FTDC_OAS_Rejected: Status.REJECTED, + THOST_FTDC_OST_NoTradeQueueing: Status.NOTTRADED, + THOST_FTDC_OST_PartTradedQueueing: Status.PARTTRADED, + THOST_FTDC_OST_AllTraded: Status.ALLTRADED, + THOST_FTDC_OST_Canceled: Status.CANCELLED +} + +DIRECTION_VT2ROHON = { + Direction.LONG: THOST_FTDC_D_Buy, + Direction.SHORT: THOST_FTDC_D_Sell +} +DIRECTION_ROHON2VT = {v: k for k, v in DIRECTION_VT2ROHON.items()} +DIRECTION_ROHON2VT[THOST_FTDC_PD_Long] = Direction.LONG +DIRECTION_ROHON2VT[THOST_FTDC_PD_Short] = Direction.SHORT + +ORDERTYPE_VT2ROHON = { + OrderType.LIMIT: THOST_FTDC_OPT_LimitPrice, + OrderType.MARKET: THOST_FTDC_OPT_AnyPrice +} +ORDERTYPE_ROHON2VT = {v: k for k, v in ORDERTYPE_VT2ROHON.items()} + +OFFSET_VT2ROHON = { + Offset.OPEN: THOST_FTDC_OF_Open, + Offset.CLOSE: THOST_FTDC_OFEN_Close, + Offset.CLOSETODAY: THOST_FTDC_OFEN_CloseToday, + Offset.CLOSEYESTERDAY: THOST_FTDC_OFEN_CloseYesterday, +} +OFFSET_ROHON2VT = {v: k for k, v in OFFSET_VT2ROHON.items()} + +EXCHANGE_ROHON2VT = { + "CFFEX": Exchange.CFFEX, + "SHFE": Exchange.SHFE, + "CZCE": Exchange.CZCE, + "DCE": Exchange.DCE, + "INE": Exchange.INE +} + +PRODUCT_ROHON2VT = { + THOST_FTDC_PC_Futures: Product.FUTURES, + THOST_FTDC_PC_Options: Product.OPTION, + THOST_FTDC_PC_Combination: Product.SPREAD +} + +OPTIONTYPE_ROHON2VT = { + THOST_FTDC_CP_CallOptions: OptionType.CALL, + THOST_FTDC_CP_PutOptions: OptionType.PUT +} + + +symbol_exchange_map = {} +symbol_name_map = {} +symbol_size_map = {} + + +class RohonGateway(BaseGateway): + """ + VN Trader Gateway for ROHON . + """ + + default_setting = { + "用户名": "", + "密码": "", + "经纪商代码": "", + "交易服务器": "", + "行情服务器": "", + "产品名称": "", + "授权编码": "", + "产品信息": "" + } + + exchanges = list(EXCHANGE_ROHON2VT.values()) + + def __init__(self, event_engine): + """Constructor""" + super().__init__(event_engine, "ROHON") + + self.td_api = RohonTdApi(self) + self.md_api = RohonMdApi(self) + + def connect(self, setting: dict): + """""" + userid = setting["用户名"] + password = setting["密码"] + brokerid = setting["经纪商代码"] + td_address = setting["交易服务器"] + md_address = setting["行情服务器"] + appid = setting["产品名称"] + auth_code = setting["授权编码"] + product_info = setting["产品信息"] + + if not td_address.startswith("tcp://"): + td_address = "tcp://" + td_address + if not md_address.startswith("tcp://"): + md_address = "tcp://" + md_address + + self.td_api.connect(td_address, userid, password, brokerid, auth_code, appid, product_info) + self.md_api.connect(md_address, userid, password, brokerid) + + self.init_query() + + def subscribe(self, req: SubscribeRequest): + """""" + self.md_api.subscribe(req) + + def send_order(self, req: OrderRequest): + """""" + return self.td_api.send_order(req) + + def cancel_order(self, req: CancelRequest): + """""" + self.td_api.cancel_order(req) + + def query_account(self): + """""" + self.td_api.query_account() + + def query_position(self): + """""" + self.td_api.query_position() + + def close(self): + """""" + self.td_api.close() + self.md_api.close() + + def write_error(self, msg: str, error: dict): + """""" + error_id = error["ErrorID"] + error_msg = error["ErrorMsg"] + msg = f"{msg},代码:{error_id},信息:{error_msg}" + self.write_log(msg) + + def process_timer_event(self, event): + """""" + self.count += 1 + if self.count < 2: + return + self.count = 0 + + func = self.query_functions.pop(0) + func() + self.query_functions.append(func) + + def init_query(self): + """""" + self.count = 0 + self.query_functions = [self.query_account, self.query_position] + self.event_engine.register(EVENT_TIMER, self.process_timer_event) + + +class RohonMdApi(MdApi): + """""" + + def __init__(self, gateway): + """Constructor""" + super(RohonMdApi, self).__init__() + + self.gateway = gateway + self.gateway_name = gateway.gateway_name + + self.reqid = 0 + + self.connect_status = False + self.login_status = False + self.subscribed = set() + + self.userid = "" + self.password = "" + self.brokerid = "" + + def onFrontConnected(self): + """ + Callback when front server is connected. + """ + self.gateway.write_log("行情服务器连接成功") + self.login() + + def onFrontDisconnected(self, reason: int): + """ + Callback when front server is disconnected. + """ + self.login_status = False + self.gateway.write_log(f"行情服务器连接断开,原因{reason}") + + def onRspUserLogin(self, data: dict, error: dict, reqid: int, last: bool): + """ + Callback when user is logged in. + """ + if not error["ErrorID"]: + self.login_status = True + self.gateway.write_log("行情服务器登录成功") + + for symbol in self.subscribed: + self.subscribeMarketData(symbol) + else: + self.gateway.write_error("行情服务器登录失败", error) + + def onRspError(self, error: dict, reqid: int, last: bool): + """ + Callback when error occured. + """ + self.gateway.write_error("行情接口报错", error) + + def onRspSubMarketData(self, data: dict, error: dict, reqid: int, last: bool): + """""" + if not error or not error["ErrorID"]: + return + + self.gateway.write_error("行情订阅失败", error) + + def onRtnDepthMarketData(self, data: dict): + """ + Callback of tick data update. + """ + symbol = data["InstrumentID"] + exchange = symbol_exchange_map.get(symbol, "") + if not exchange: + return + + timestamp = f"{data['ActionDay']} {data['UpdateTime']}.{int(data['UpdateMillisec']/100)}" + + tick = TickData( + symbol=symbol, + exchange=exchange, + datetime=datetime.strptime(timestamp, "%Y%m%d %H:%M:%S.%f"), + name=symbol_name_map[symbol], + volume=data["Volume"], + open_interest=data["OpenInterest"], + last_price=data["LastPrice"], + limit_up=data["UpperLimitPrice"], + limit_down=data["LowerLimitPrice"], + open_price=data["OpenPrice"], + high_price=data["HighestPrice"], + low_price=data["LowestPrice"], + pre_close=data["PreClosePrice"], + bid_price_1=data["BidPrice1"], + ask_price_1=data["AskPrice1"], + bid_volume_1=data["BidVolume1"], + ask_volume_1=data["AskVolume1"], + gateway_name=self.gateway_name + ) + self.gateway.on_tick(tick) + + def connect(self, address: str, userid: str, password: str, brokerid: int): + """ + Start connection to server. + """ + self.userid = userid + self.password = password + self.brokerid = brokerid + + # If not connected, then start connection first. + if not self.connect_status: + path = get_folder_path(self.gateway_name.lower()) + self.createFtdcMdApi(str(path) + "\\Md") + + self.registerFront(address) + self.init() + + self.connect_status = True + # If already connected, then login immediately. + elif not self.login_status: + self.login() + + def login(self): + """ + Login onto server. + """ + req = { + "UserID": self.userid, + "Password": self.password, + "BrokerID": self.brokerid + } + + self.reqid += 1 + self.reqUserLogin(req, self.reqid) + + def subscribe(self, req: SubscribeRequest): + """ + Subscribe to tick data update. + """ + if self.login_status: + self.subscribeMarketData(req.symbol) + self.subscribed.add(req.symbol) + + def close(self): + """ + Close the connection. + """ + if self.connect_status: + self.exit() + + +class RohonTdApi(TdApi): + """""" + + def __init__(self, gateway): + """Constructor""" + super(RohonTdApi, self).__init__() + + self.gateway = gateway + self.gateway_name = gateway.gateway_name + + self.reqid = 0 + self.order_ref = 0 + + self.connect_status = False + self.login_status = False + self.auth_staus = False + self.login_failed = False + + self.userid = "" + self.password = "" + self.brokerid = "" + self.auth_code = "" + self.appid = "" + self.product_info = "" + + self.frontid = 0 + self.sessionid = 0 + + self.order_data = [] + self.trade_data = [] + self.positions = {} + self.sysid_orderid_map = {} + + def onFrontConnected(self): + """""" + self.gateway.write_log("交易服务器连接成功") + + if self.auth_code: + self.authenticate() + else: + self.login() + + def onFrontDisconnected(self, reason: int): + """""" + self.login_status = False + self.gateway.write_log(f"交易服务器连接断开,原因{reason}") + + def onRspAuthenticate(self, data: dict, error: dict, reqid: int, last: bool): + """""" + if not error['ErrorID']: + self.auth_staus = True + self.gateway.write_log("交易服务器授权验证成功") + self.login() + else: + self.gateway.write_error("交易服务器授权验证失败", error) + + def onRspUserLogin(self, data: dict, error: dict, reqid: int, last: bool): + """""" + if not error["ErrorID"]: + self.frontid = data["FrontID"] + self.sessionid = data["SessionID"] + self.login_status = True + self.gateway.write_log("交易服务器登录成功") + + # Confirm settlement + req = { + "BrokerID": self.brokerid, + "InvestorID": self.userid + } + self.reqid += 1 + self.reqSettlementInfoConfirm(req, self.reqid) + else: + self.login_failed = True + + self.gateway.write_error("交易服务器登录失败", error) + + def onRspOrderInsert(self, data: dict, error: dict, reqid: int, last: bool): + """""" + order_ref = data["OrderRef"] + orderid = f"{self.frontid}_{self.sessionid}_{order_ref}" + + symbol = data["InstrumentID"] + exchange = symbol_exchange_map[symbol] + + order = OrderData( + symbol=symbol, + exchange=exchange, + orderid=orderid, + direction=DIRECTION_ROHON2VT[data["Direction"]], + offset=OFFSET_ROHON2VT.get(data["CombOffsetFlag"], Offset.NONE), + price=data["LimitPrice"], + volume=data["VolumeTotalOriginal"], + status=Status.REJECTED, + gateway_name=self.gateway_name + ) + self.gateway.on_order(order) + + self.gateway.write_error("交易委托失败", error) + + def onRspOrderAction(self, data: dict, error: dict, reqid: int, last: bool): + """""" + self.gateway.write_error("交易撤单失败", error) + + def onRspQueryMaxOrderVolume(self, data: dict, error: dict, reqid: int, last: bool): + """""" + pass + + def onRspSettlementInfoConfirm(self, data: dict, error: dict, reqid: int, last: bool): + """ + Callback of settlment info confimation. + """ + self.gateway.write_log("结算信息确认成功") + + self.reqid += 1 + self.reqQryInstrument({}, self.reqid) + + def onRspQryInvestorPosition(self, data: dict, error: dict, reqid: int, last: bool): + """""" + if not data: + return + + # Get buffered position object + key = f"{data['InstrumentID'], data['PosiDirection']}" + position = self.positions.get(key, None) + if not position: + position = PositionData( + symbol=data["InstrumentID"], + exchange=symbol_exchange_map[data["InstrumentID"]], + direction=DIRECTION_ROHON2VT[data["PosiDirection"]], + gateway_name=self.gateway_name + ) + self.positions[key] = position + + # For SHFE position data update + if position.exchange == Exchange.SHFE: + if data["YdPosition"] and not data["TodayPosition"]: + position.yd_volume = data["Position"] + # For other exchange position data update + else: + position.yd_volume = data["Position"] - data["TodayPosition"] + + # Get contract size (spread contract has no size value) + size = symbol_size_map.get(position.symbol, 0) + + # Calculate previous position cost + cost = position.price * position.volume * size + + # Update new position volume + position.volume += data["Position"] + position.pnl += data["PositionProfit"] + + # Calculate average position price + if position.volume and size: + cost += data["PositionCost"] + position.price = cost / (position.volume * size) + + # Get frozen volume + if position.direction == Direction.LONG: + position.frozen += data["ShortFrozen"] + else: + position.frozen += data["LongFrozen"] + + if last: + for position in self.positions.values(): + self.gateway.on_position(position) + + self.positions.clear() + + def onRspQryTradingAccount(self, data: dict, error: dict, reqid: int, last: bool): + """""" + if "AccountID" not in data: + return + + account = AccountData( + accountid=data["AccountID"], + balance=data["Balance"], + frozen=data["FrozenMargin"] + data["FrozenCash"] + data["FrozenCommission"], + gateway_name=self.gateway_name + ) + account.available = data["Available"] + + self.gateway.on_account(account) + + def onRspQryInstrument(self, data: dict, error: dict, reqid: int, last: bool): + """ + Callback of instrument query. + """ + product = PRODUCT_ROHON2VT.get(data["ProductClass"], None) + if product: + contract = ContractData( + symbol=data["InstrumentID"], + exchange=EXCHANGE_ROHON2VT[data["ExchangeID"]], + name=data["InstrumentName"], + product=product, + size=data["VolumeMultiple"], + pricetick=data["PriceTick"], + gateway_name=self.gateway_name + ) + + # For option only + if contract.product == Product.OPTION: + contract.option_underlying = data["UnderlyingInstrID"], + contract.option_type = OPTIONTYPE_ROHON2VT.get(data["OptionsType"], None), + contract.option_strike = data["StrikePrice"], + contract.option_expiry = datetime.strptime(data["ExpireDate"], "%Y%m%d"), + + self.gateway.on_contract(contract) + + symbol_exchange_map[contract.symbol] = contract.exchange + symbol_name_map[contract.symbol] = contract.name + symbol_size_map[contract.symbol] = contract.size + + if last: + self.gateway.write_log("合约信息查询成功") + + for data in self.order_data: + self.onRtnOrder(data) + self.order_data.clear() + + for data in self.trade_data: + self.onRtnTrade(data) + self.trade_data.clear() + + def onRtnOrder(self, data: dict): + """ + Callback of order status update. + """ + symbol = data["InstrumentID"] + exchange = symbol_exchange_map.get(symbol, "") + if not exchange: + self.order_data.append(data) + return + + frontid = data["FrontID"] + sessionid = data["SessionID"] + order_ref = data["OrderRef"] + orderid = f"{frontid}_{sessionid}_{order_ref}" + + order = OrderData( + symbol=symbol, + exchange=exchange, + orderid=orderid, + type=ORDERTYPE_ROHON2VT[data["OrderPriceType"]], + direction=DIRECTION_ROHON2VT[data["Direction"]], + offset=OFFSET_ROHON2VT[data["CombOffsetFlag"]], + price=data["LimitPrice"], + volume=data["VolumeTotalOriginal"], + traded=data["VolumeTraded"], + status=STATUS_ROHON2VT[data["OrderStatus"]], + time=data["InsertTime"], + gateway_name=self.gateway_name + ) + self.gateway.on_order(order) + + self.sysid_orderid_map[data["OrderSysID"]] = orderid + + def onRtnTrade(self, data: dict): + """ + Callback of trade status update. + """ + symbol = data["InstrumentID"] + exchange = symbol_exchange_map.get(symbol, "") + if not exchange: + self.trade_data.append(data) + return + + orderid = self.sysid_orderid_map[data["OrderSysID"]] + + trade = TradeData( + symbol=symbol, + exchange=exchange, + orderid=orderid, + tradeid=data["TradeID"], + direction=DIRECTION_ROHON2VT[data["Direction"]], + offset=OFFSET_ROHON2VT[data["OffsetFlag"]], + price=data["Price"], + volume=data["Volume"], + time=data["TradeTime"], + gateway_name=self.gateway_name + ) + self.gateway.on_trade(trade) + + def connect( + self, + address: str, + userid: str, + password: str, + brokerid: int, + auth_code: str, + appid: str, + product_info + ): + """ + Start connection to server. + """ + self.userid = userid + self.password = password + self.brokerid = brokerid + self.auth_code = auth_code + self.appid = appid + self.product_info = product_info + + if not self.connect_status: + path = get_folder_path(self.gateway_name.lower()) + self.createFtdcTraderApi(str(path) + "\\Td") + + self.subscribePrivateTopic(0) + self.subscribePublicTopic(0) + + self.registerFront(address) + self.init() + + self.connect_status = True + else: + self.authenticate() + + def authenticate(self): + """ + Authenticate with auth_code and appid. + """ + req = { + "UserID": self.userid, + "BrokerID": self.brokerid, + "AuthCode": self.auth_code, + "AppID": self.appid + } + + if self.product_info: + req["UserProductInfo"] = self.product_info + + self.reqid += 1 + self.reqAuthenticate(req, self.reqid) + + def login(self): + """ + Login onto server. + """ + if self.login_failed: + return + + req = { + "UserID": self.userid, + "Password": self.password, + "BrokerID": self.brokerid, + "AppID": self.appid + } + + if self.product_info: + req["UserProductInfo"] = self.product_info + + self.reqid += 1 + self.reqUserLogin(req, self.reqid) + + def send_order(self, req: OrderRequest): + """ + Send new order. + """ + self.order_ref += 1 + + rohon_req = { + "InstrumentID": req.symbol, + "ExchangeID": req.exchange.value, + "LimitPrice": req.price, + "VolumeTotalOriginal": int(req.volume), + "OrderPriceType": ORDERTYPE_VT2ROHON.get(req.type, ""), + "Direction": DIRECTION_VT2ROHON.get(req.direction, ""), + "CombOffsetFlag": OFFSET_VT2ROHON.get(req.offset, ""), + "OrderRef": str(self.order_ref), + "InvestorID": self.userid, + "UserID": self.userid, + "BrokerID": self.brokerid, + "CombHedgeFlag": THOST_FTDC_HF_Speculation, + "ContingentCondition": THOST_FTDC_CC_Immediately, + "ForceCloseReason": THOST_FTDC_FCC_NotForceClose, + "IsAutoSuspend": 0, + "TimeCondition": THOST_FTDC_TC_GFD, + "VolumeCondition": THOST_FTDC_VC_AV, + "MinVolume": 1 + } + + if req.type == OrderType.FAK: + rohon_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice + rohon_req["TimeCondition"] = THOST_FTDC_TC_IOC + rohon_req["VolumeCondition"] = THOST_FTDC_VC_AV + elif req.type == OrderType.FOK: + rohon_req["OrderPriceType"] = THOST_FTDC_OPT_LimitPrice + rohon_req["TimeCondition"] = THOST_FTDC_TC_IOC + rohon_req["VolumeCondition"] = THOST_FTDC_VC_CV + + self.reqid += 1 + self.reqOrderInsert(rohon_req, self.reqid) + + orderid = f"{self.frontid}_{self.sessionid}_{self.order_ref}" + order = req.create_order_data(orderid, self.gateway_name) + self.gateway.on_order(order) + + return order.vt_orderid + + def cancel_order(self, req: CancelRequest): + """ + Cancel existing order. + """ + frontid, sessionid, order_ref = req.orderid.split("_") + + rohon_req = { + "InstrumentID": req.symbol, + "ExchangeID": req.exchange.value, + "OrderRef": order_ref, + "FrontID": int(frontid), + "SessionID": int(sessionid), + "ActionFlag": THOST_FTDC_AF_Delete, + "BrokerID": self.brokerid, + "InvestorID": self.userid + } + + self.reqid += 1 + self.reqOrderAction(rohon_req, self.reqid) + + def query_account(self): + """ + Query account balance data. + """ + self.reqid += 1 + self.reqQryTradingAccount({}, self.reqid) + + def query_position(self): + """ + Query position holding data. + """ + if not symbol_exchange_map: + return + + req = { + "BrokerID": self.brokerid, + "InvestorID": self.userid + } + + self.reqid += 1 + self.reqQryInvestorPosition(req, self.reqid) + + def close(self): + """""" + if self.connect_status: + self.exit() diff --git a/vnpy/gateway/rohon/thostmduserapi_se.dll b/vnpy/gateway/rohon/thostmduserapi_se.dll new file mode 100644 index 00000000..f71079ac Binary files /dev/null and b/vnpy/gateway/rohon/thostmduserapi_se.dll differ diff --git a/vnpy/gateway/rohon/thosttraderapi_se.dll b/vnpy/gateway/rohon/thosttraderapi_se.dll new file mode 100644 index 00000000..ef1e56a9 Binary files /dev/null and b/vnpy/gateway/rohon/thosttraderapi_se.dll differ diff --git a/vnpy/gateway/rohon/vnctpmd.pyd b/vnpy/gateway/rohon/vnctpmd.pyd new file mode 100644 index 00000000..476c6511 Binary files /dev/null and b/vnpy/gateway/rohon/vnctpmd.pyd differ diff --git a/vnpy/gateway/rohon/vnctptd.pyd b/vnpy/gateway/rohon/vnctptd.pyd new file mode 100644 index 00000000..c78343e5 Binary files /dev/null and b/vnpy/gateway/rohon/vnctptd.pyd differ