Giter Site home page Giter Site logo

openctp / webctp Goto Github PK

View Code? Open in Web Editor NEW
25.0 25.0 10.0 258 KB

将CTP接口转换成websocket+json协议对外通讯,适合web类应用。

Home Page: http://www.openctp.cn

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
ctp ctpapi finance fintech futures openctp options quant stocks trader

webctp's Issues

订阅行情和取消订阅行情的应答数据格式有误

期望为

{
  "MsgType": "OnRspUnSubscribeMarketData",
  "SpecificInstrument": {
    "InstrumentID": "au2305"
  },
  "RspInfo": {
    "ErrorID": 0,
    "ErrorMsg": ""
  },
  "RequestID": 0,
  "IsLast": true
}

实际是

{
    "MsgType": "OnRspSubMarketData",
    "RspInfo": {
        "ErrorID": 0,
        "ErrorMsg": "CTP:No Error"
    },
    "RequestID": 0,
    "IsLast": true,
    "SpecificInstrument": "ag2306"
}

Add request validation code.

Requirements:

  • Can easily define the validation strategy.
  • Easy to use.
  • Better to throw an exception with the response info, then we can catch it and return it in the connection.

Unit test

  • For clients package.
  • For service package.

Repeated client

Now one connection(websocket) has one client(md/td).
If the same user login by multi clients, then server will create multi same clients which are repeated.
Can webctp avoid the repeated resources ?

查询交易所、产品、行情、持仓明细、保证金率、手续费、交易成本和合约手续费API及SPI函数

相关issue #5

///请求查询交易所
virtual int ReqQryExchange(CThostFtdcQryExchangeField *pQryExchange, int nRequestID) = 0;

///请求查询产品
virtual int ReqQryProduct(CThostFtdcQryProductField *pQryProduct, int nRequestID) = 0;

///请求查询合约
virtual int ReqQryInstrument(CThostFtdcQryInstrumentField *pQryInstrument, int nRequestID) = 0;

///请求查询行情
virtual int ReqQryDepthMarketData(CThostFtdcQryDepthMarketDataField *pQryDepthMarketData, int nRequestID) = 0;
///请求查询投资者持仓明细
virtual int ReqQryInvestorPositionDetail(CThostFtdcQryInvestorPositionDetailField *pQryInvestorPositionDetail, int nRequestID) = 0;
///请求查询交易所保证金率
virtual int ReqQryExchangeMarginRate(CThostFtdcQryExchangeMarginRateField *pQryExchangeMarginRate, int nRequestID) = 0;
///请求查询报单手续费
virtual int ReqQryInstrumentOrderCommRate(CThostFtdcQryInstrumentOrderCommRateField *pQryInstrumentOrderCommRate, int nRequestID) = 0;
///请求查询期权交易成本
virtual int ReqQryOptionInstrTradeCost(CThostFtdcQryOptionInstrTradeCostField *pQryOptionInstrTradeCost, int nRequestID) = 0;

///请求查询期权合约手续费
virtual int ReqQryOptionInstrCommRate(CThostFtdcQryOptionInstrCommRateField *pQryOptionInstrCommRate, int nRequestID) = 0;

补充行情接口的相关API和SPI

请另外建一个issue说明在补充哪些API和SPI,新建的issue请引用本issue并在本issue下comment,然后把开发中的API和SPI填写在开发中一栏,merge以后再改到已有中。

已有

  • login
  • SubscribeMarketData
  • OnRspSubscribeMarketData
  • UnSubscribeMarketData
  • OnRspUnSubMarketData
  • OnRtnDepthMarketData

开发中

未开发

  • GetTradingDay
  • RegisterFensUserInfo
  • RegisterNameServer
  • ReqQryMulticastInstrument
  • ReqUserLogout
  • SubscribeForQuoteRsp
  • UnSubscribeForQuoteRsp
  • OnHeartBeatWarning
  • OnRspError
  • OnRspQryMulticastInstrument
  • OnRspSubForQuoteRsp
  • OnRspUnSubForQuoteRsp
  • OnRspUserLogout
  • OnRtnForQuoteRsp

查询成交、持仓、资金账户、投资者、交易编码、保证金率和手续费率的API和SPI函数

相关issue #5
///请求查询成交
virtual int ReqQryTrade(CThostFtdcQryTradeField *pQryTrade, int nRequestID) = 0;

///请求查询投资者持仓
virtual int ReqQryInvestorPosition(CThostFtdcQryInvestorPositionField *pQryInvestorPosition, int nRequestID) = 0;

///请求查询资金账户
virtual int ReqQryTradingAccount(CThostFtdcQryTradingAccountField *pQryTradingAccount, int nRequestID) = 0;

///请求查询投资者
virtual int ReqQryInvestor(CThostFtdcQryInvestorField *pQryInvestor, int nRequestID) = 0;

///请求查询交易编码
virtual int ReqQryTradingCode(CThostFtdcQryTradingCodeField *pQryTradingCode, int nRequestID) = 0;

///请求查询合约保证金率
virtual int ReqQryInstrumentMarginRate(CThostFtdcQryInstrumentMarginRateField *pQryInstrumentMarginRate, int nRequestID) = 0;

///请求查询合约手续费率
virtual int ReqQryInstrumentCommissionRate(CThostFtdcQryInstrumentCommissionRateField *pQryInstrumentCommissionRate, int nRequestID) = 0;

补充交易接口的API和SPI

请另外建一个issue说明在补充哪些API和SPI,新建的issue请引用本issue并在本issue下comment,然后把开发中的API和SPI填写在开发中一栏,merge以后再改到已有中。

已有

  • login
  • ReqQryInstrument
  • OnRspReqQryInstrument

开发中

  • ReqUserPasswordUpdate
  • OnRspUserPasswordUpdate
  • ReqOrderInsert
  • OnRspOrderInsert
  • OnErrRtnOrderInsert
  • ReqOrderAction
  • OnRspOrderAction
  • OnErrRtnOrderAction
  • ReqQryMaxOrderVolume
  • OnRspQryMaxOrderVolume
  • ReqQryOrder
  • OnRspQryOrder

未开发

  • GetApiVersion
  • GetTradingDay
  • RegisterFensUserInfo
  • RegisterNameServer
  • RegisterUserSystemInfo
  • ReqBatchOrderAction
  • ReqCombActionInsert
  • ReqExecOrderAction
  • ReqExecOrderInsert
  • ReqForQuoteInsert
  • ReqFromBankToFutureByFuture
  • ReqFromFutureToBankByFuture
  • ReqGenUserCaptcha
  • ReqGenUserText
  • ReqOptionSelfCloseAction
  • ReqOptionSelfCloseInsert
  • ReqParkedOrderAction
  • ReqParkedOrderInsert
  • ReqQryAccountregister
  • ReqQryBrokerTradingAlgos
  • ReqQryBrokerTradingParams
  • ReqQryCFMMCTradingAccountKey
  • ReqQryClassifiedInstrument
  • ReqQryCombAction
  • ReqQryCombInstrumentGuard
  • ReqQryCombPromotionParam
  • ReqQryContractBank
  • ReqQryDepthMarketData
  • ReqQryEWarrantOffset
  • ReqQryExchange
  • ReqQryExchangeMarginRate
  • ReqQryExchangeMarginRateAdjust
  • ReqQryExchangeRate
  • ReqQryExecOrder
  • ReqQryForQuote
  • ReqQryInstrumentCommissionRate
  • ReqQryInstrumentMarginRate
  • ReqQryInstrumentOrderCommRate
  • ReqQryInvestUnit
  • ReqQryInvestor
  • ReqQryInvestorPosition
  • ReqQryInvestorPositionCombineDetail
  • ReqQryInvestorPositionDetail
  • ReqQryInvestorProductGroupMargin
  • ReqQryMMInstrumentCommissionRate
  • ReqQryMMOptionInstrCommRate
  • ReqQryNotice
  • ReqQryOptionInstrCommRate
  • ReqQryOptionInstrTradeCost
  • ReqQryOptionSelfClose
  • ReqQryParkedOrder
  • ReqQryParkedOrderAction
  • ReqQryProduct
  • ReqQryProductExchRate
  • ReqQryProductGroup
  • ReqQryQuote
  • ReqQryRiskSettleInvstPosition
  • ReqQryRiskSettleProductStatus
  • ReqQrySecAgentACIDMap
  • ReqQrySecAgentCheckMode
  • ReqQrySecAgentTradeInfo
  • ReqQrySecAgentTradingAccount
  • ReqQrySettlementInfo
  • ReqQrySettlementInfoConfirm
  • ReqQryTrade
  • ReqQryTraderOffer
  • ReqQryTradingAccount
  • ReqQryTradingCode
  • ReqQryTradingNotice
  • ReqQryTransferBank
  • ReqQryTransferSerial
  • ReqQueryBankAccountMoneyByFuture
  • ReqQueryCFMMCTradingAccountToken
  • ReqQuoteAction
  • ReqQuoteInsert
  • ReqRemoveParkedOrder
  • ReqRemoveParkedOrderAction
  • ReqSettlementInfoConfirm
  • ReqTradingAccountPasswordUpdate
  • ReqUserAuthMethod
  • ReqUserLoginWithCaptcha
  • ReqUserLoginWithOTP
  • ReqUserLoginWithText
  • ReqUserLogout
  • SubmitUserSystemInfo
  • SubscribePrivateTopic
  • SubscribePublicTopic

  • OnErrRtnBankToFutureByFuture
  • OnErrRtnBatchOrderAction
  • OnErrRtnCombActionInsert
  • OnErrRtnExecOrderAction
  • OnErrRtnExecOrderInsert
  • OnErrRtnForQuoteInsert
  • OnErrRtnFutureToBankByFuture
  • OnErrRtnOptionSelfCloseAction
  • OnErrRtnOptionSelfCloseInsert
  • OnErrRtnQueryBankBalanceByFuture
  • OnErrRtnQuoteAction
  • OnErrRtnQuoteInsert
  • OnErrRtnRepealBankToFutureByFutureManual
  • OnErrRtnRepealFutureToBankByFutureManual
  • OnHeartBeatWarning
  • OnRspBatchOrderAction
  • OnRspCombActionInsert
  • OnRspError
  • OnRspExecOrderAction
  • OnRspExecOrderInsert
  • OnRspForQuoteInsert
  • OnRspFromBankToFutureByFuture
  • OnRspFromFutureToBankByFuture
  • OnRspGenUserCaptcha
  • OnRspGenUserText
  • OnRspOptionSelfCloseAction
  • OnRspOptionSelfCloseInsert
  • OnRspParkedOrderAction
  • OnRspParkedOrderInsert
  • OnRspQryAccountregister
  • OnRspQryBrokerTradingAlgos
  • OnRspQryBrokerTradingParams
  • OnRspQryCFMMCTradingAccountKey
  • OnRspQryClassifiedInstrument
  • OnRspQryCombAction
  • OnRspQryCombInstrumentGuard
  • OnRspQryCombPromotionParam
  • OnRspQryContractBank
  • OnRspQryDepthMarketData
  • OnRspQryEWarrantOffset
  • OnRspQryExchange
  • OnRspQryExchangeMarginRate
  • OnRspQryExchangeMarginRateAdjust
  • OnRspQryExchangeRate
  • OnRspQryExecOrder
  • OnRspQryForQuote
  • OnRspQryInstrumentCommissionRate
  • OnRspQryInstrumentMarginRate
  • OnRspQryInstrumentOrderCommRate
  • OnRspQryInvestUnit
  • OnRspQryInvestor
  • OnRspQryInvestorPosition
  • OnRspQryInvestorPositionCombineDetail
  • OnRspQryInvestorPositionDetail
  • OnRspQryInvestorProductGroupMargin
  • OnRspQryMMInstrumentCommissionRate
  • OnRspQryMMOptionInstrCommRate
  • OnRspQryNotice
  • OnRspQryOptionInstrCommRate
  • OnRspQryOptionInstrTradeCost
  • OnRspQryOptionSelfClose
  • OnRspQryParkedOrder
  • OnRspQryParkedOrderAction
  • OnRspQryProduct
  • OnRspQryProductExchRate
  • OnRspQryProductGroup
  • OnRspQryQuote
  • OnRspQryRiskSettleInvstPosition
  • OnRspQryRiskSettleProductStatus
  • OnRspQrySecAgentACIDMap
  • OnRspQrySecAgentCheckMode
  • OnRspQrySecAgentTradeInfo
  • OnRspQrySecAgentTradingAccount
  • OnRspQrySettlementInfo
  • OnRspQrySettlementInfoConfirm
  • OnRspQryTrade
  • OnRspQryTraderOffer
  • OnRspQryTradingAccount
  • OnRspQryTradingCode
  • OnRspQryTradingNotice
  • OnRspQryTransferBank
  • OnRspQryTransferSerial
  • OnRspQueryBankAccountMoneyByFuture
  • OnRspQueryCFMMCTradingAccountToken
  • OnRspQuoteAction
  • OnRspQuoteInsert
  • OnRspRemoveParkedOrder
  • OnRspRemoveParkedOrderAction
  • OnRspSettlementInfoConfirm
  • OnRspTradingAccountPasswordUpdate
  • OnRspUserAuthMethod
  • OnRspUserLogout
  • OnRtnBulletin
  • OnRtnCFMMCTradingAccountToken
  • OnRtnCancelAccountByBank
  • OnRtnChangeAccountByBank
  • OnRtnCombAction
  • OnRtnErrorConditionalOrder
  • OnRtnExecOrder
  • OnRtnForQuoteRsp
  • OnRtnFromBankToFutureByBank
  • OnRtnFromBankToFutureByFuture
  • OnRtnFromFutureToBankByBank
  • OnRtnFromFutureToBankByFuture
  • OnRtnInstrumentStatus
  • OnRtnOpenAccountByBank
  • OnRtnOptionSelfClose
  • OnRtnOrder
  • OnRtnQueryBankBalanceByFuture
  • OnRtnQuote
  • OnRtnRepealFromBankToFutureByBank
  • OnRtnRepealFromBankToFutureByFuture
  • OnRtnRepealFromBankToFutureByFutureManual
  • OnRtnRepealFromFutureToBankByBank
  • OnRtnRepealFromFutureToBankByFuture
  • OnRtnRepealFromFutureToBankByFutureManual
  • OnRtnTrade
  • OnRtnTradingNotice

[feature] demo in python

您好,
请问有没有可能在这个项目里用python做一个简单的demo? 最好包括登录,获取合约信息,获取用户信息之类的。
非常感谢

添加报单相关以及口令更新的API和SPI方法

关联单#5

///用户口令更新请求
virtual int ReqUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, int nRequestID) = 0;
///报单录入请求
virtual int ReqOrderInsert(CThostFtdcInputOrderField *pInputOrder, int nRequestID) = 0;
///报单操作请求
virtual int ReqOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, int nRequestID) = 0;
///查询最大报单数量请求
virtual int ReqQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, int nRequestID) = 0;
///请求查询报单
virtual int ReqQryOrder(CThostFtdcQryOrderField *pQryOrder, int nRequestID) = 0;

添加启动脚本

添加各个平台的启动脚本,方便一键启动分为如下几个脚本

# Windows
webctp_md.ps1 -c configure_file
webctp_td.ps1 -c configure_file
# Linux
webctp_md.sh -c configure_file
webctp_td.sh -c configure_file
# MacOS
webctp_md.sh -c configure_file
webctp_td.sh -c configure_file

通过pypi进行发布

通过pip install webctp进行安装,用户可以引用webctp中的app进行自定义的启动。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.