• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

AlgoPlus: AlgoPlus 2.0是使用c++语言开发的用于全市场交易的SDK,提供c++/python/jav ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

AlgoPlus

开源软件地址:

https://gitee.com/AlgoPlus/AlgoPlus

开源软件介绍:

官网

http://algo.plus


股票现货API

  • 安装方法

pip install AlgoPlusTORAStockV3x

操作系统:win_amd64,linux

Python版本:>=3.7,<3.9

如果无法安装,可以下载安装包,然后尝试离线安装:

https://pypi.tuna.tsinghua.edu.cn/simple/algoplustorastockv3x/

  • 业务柜台

AlgoPlusTORAStockV3x封装的是华鑫证券奇点柜台的API。对在N视界官网(http://n-sight.com.cn)注册的现货仿真交易账户开放测试,支持普通股债交易、查询等业务。

  • 仿真交易测试
  1. 同步仿真环境
TraderFrontAddress = "tcp://210.14.72.11:4400"MdFrontAddress = "tcp://210.14.72.11:4402"
  1. 7*24仿真环境
TraderFrontAddress = "tcp://210.14.72.15:4400"MdFrontAddress = "tcp://210.14.72.15:4402"
  • 客户端

下载链接: https://pan.baidu.com/s/1jQCjl3eGAUf41HO4lPyD5g 提取码: 6aye


期货API

  • 安装方法

pip install AlgoPlusCTPV6315

操作系统:win_amd64,linux

Python版本:>=3.7,<3.9

如果无法安装,可以下载安装包,然后尝试离线安装:

https://pypi.tuna.tsinghua.edu.cn/simple/algoplusctpv6315/

  • 业务柜台

AlgoPlusCTPV6315封装的是上期技术CTP柜台的API。对在N视界(http://n-sight.com.cn)和SimNow(http://simnow.com.cn)注册的期货仿真交易账户开放测试,支持期货交易、查询等相关业务。

  • 仿真交易测试
  1. NSight同步仿真环境
BrokerID = "10010"TraderFrontAddress = "tcp://210.14.72.15:4600"MdFrontAddress = "tcp://210.14.72.15:4602"AppID = ""AuthCode = ""
  1. SimNow同步仿真环境
BrokerID = "9999"TraderFrontAddress = "tcp://180.168.146.187:10201"MdFrontAddress = "tcp://180.168.146.187:10211"AppID = "simnow_client_test"AuthCode = "0000000000000000"
  1. SimNow同步仿真环境
BrokerID = "9999"TraderFrontAddress = tcp://180.168.146.187:10202MdFrontAddress = 180.168.146.187:10212AppID = "simnow_client_test"AuthCode = "0000000000000000"
  1. SimNow同步仿真环境
BrokerID = "9999"TraderFrontAddress = "tcp://218.202.237.33:10203"MdFrontAddress = "tcp://218.202.237.33:10213"AppID = "simnow_client_test"AuthCode = "0000000000000000"
  1. SimNow7*24仿真环境
BrokerID = "9999"TraderFrontAddress = "tcp://180.168.146.187:10130"MdFrontAddress = "tcp://180.168.146.187:10131"AppID = "simnow_client_test"AuthCode = "0000000000000000"
  • 客户端

下载链接: https://pan.baidu.com/s/1VSza3McX-Dyy33YLr8pBMg 提取码:f5ni


方法列表

/// 版本号const char* getVersion();/// 初始化CBaseTrader* init(int nRunID, CAPLoginField* pLoginField, PyObject* pOrderEventCallback = Py_None, PyObject* pFlexibleEventCallback = Py_None, PyObject* pLoopEventCallback = Py_None, PyObject* pSnapDataEventCallback = Py_None);/// 查询初始化错误int getInitError();/// 查询错误信息const char* getMessageByErrorID(TAPErrorIDType nErrorID);/// 轮询void loop();/// 设置运行模式。默认Debug模式:将事件相关结构体转为字符串,调用EventTextProcessor处理。int setRunMode(TAPRunModeType chRunMode);/// 设置处理事件字符串的方法。默认输出到屏幕。int setEventTextProcessor(PyObject* pTextProcessor);/// 订阅行情int subscribeOne(CBaseTrader* pAPTrader, const char* szStandardID, const char* szExchangeID = NULL);/// 批量订阅行情int subscribe(CBaseTrader* pAPTrader, char** ppStandardID, int nCount, const char* szExchangeID = NULL);/// 退订行情int unsubscribeOne(CBaseTrader* pAPTrader, const char* szStandardID, const char* szExchangeID = NULL);/// 批量退订行情int unsubscribe(CBaseTrader* pAPTrader, char** ppStandardID, int nCount, const char* szExchangeID = NULL);/// 买开数量CAPOrderField* buyOpen(CBaseTrader* pAPTrader, const char* szStandardID, int nOrderVolume, char chOrderType, double dOrderPrice, const char* szExchangeID = NULL, char chDirection = ENUM_Direction_Buy);/// 卖平数量CAPOrderField* sellClose(CBaseTrader* pAPTrader, const char* szStandardID, int nOrderVolume, char chOrderType, double dOrderPrice, const char* szExchangeID = NULL, char chDirection = ENUM_Direction_Sell, char chOffsetFlag = '\0', const char* szCreditDebtID = NULL);/// 卖开数量CAPOrderField* sellOpen(CBaseTrader* pAPTrader, const char* szStandardID, int nOrderVolume, char chOrderType, double dOrderPrice, const char* szExchangeID = NULL, char chDirection = '\0', char chCreditQuotaType = '\0');/// 买平数量CAPOrderField* buyClose(CBaseTrader* pAPTrader, const char* szStandardID, int nOrderVolume, char chOrderType, double dOrderPrice, const char* szExchangeID = NULL, char chDirection = '\0', char chOffsetFlag = '\0', const char* szCreditDebtID = NULL);/// 报单CAPOrderField* insertOrder(CBaseTrader* pAPTrader, const char* szExchangeID, const char* szStandardID, char chDirection, char chOffsetFlag, int nVolume, const char* szCombineOrderType, double dPrice, char chCreditQuotaType = '\0', const char* szCreditDebtID = NULL);/// 撤单int cancelOrder(CBaseTrader* pAPTrader, const char* szExchangeID, const char* szStandardID, const char* szOrderSysID, int nOrderID, int nFrontID = 0, int nSessionID = 0);/// 撤单int cancelOrderByOrderID(CBaseTrader* pAPTrader, int nOrderID);/// 以标的撤单int cancelOrderByStandardID(CBaseTrader* pAPTrader, const char* szExchangeID = NULL, const char* szStandardID = NULL);/// 划转资金CAPTransferAssetField* transferCash(CBaseTrader* pAPTrader, char chTransferFlag, double dAmount, const char* szAccountPassword, const char* szBankID, const char* szBankPassword, const char* szNodeID = NULL, const char* szCreditDebtID = NULL);/// 划转持仓CAPTransferAssetField* transferPosition(CBaseTrader* pAPTrader, char chTransferFlag, int nVolume, const char* szStandardID, const char* szNodeID = NULL, const char* szCreditDebtID = NULL, const char* szExchangeID = NULL);/// 查询银行卡余额TAPErrorIDType queryBankAccountCash(CBaseTrader* pAPTrader, const char* szAccountPassword, const char* szBankID, const char* szBankPassword);/// 修改密码TAPErrorIDType updatePassword(CBaseTrader* pAPTrader, char chPasswordFlag, const char* szOldPassword, const char* szNewPassword);/// 添加任务int addTask(CBaseTrader* pAPTrader, TAPEventIDType nEventID, CAPQueryCommandField* pQueryCommandField = NULL, int nMaxExecuteCount = 1, TAPTimeAnchorType nExecuteGap = -1, TAPTimeAnchorType nFailedGap = -1, bool bRefuseError = false, TAPTimeAnchorType nExecuteTimeout = -1);/// 退出void exitX(CBaseTrader* pAPTrader = NULL);/// 事件响应结构体域名const char* getFields(TAPEventIDType nEventID, void* pEventStruct);/// 事件响应结构体转字符串const char* toText(TAPEventIDType nEventID, void* pEventStruct, bool bWithFieldName = false, const char* szSeparator = ",", int nPrecision = 2);/// 设置时间锚long long setTimeAnchor();/// 计算时间差long long getTimeElapse(TAPTimeAnchorType nTimeAnchor = 0);

回调函数类型

/// 切片行情事件回调typedef void(*FAPSnapDataEventCallbackType)(TAPEventIDType, CAPMarketDataField*);/// 订单事件回调typedef void(*FAPOrderEventCallbackType)(TAPEventIDType, CAPOrderField*);/// 其他事件回调typedef void(*FAPFlexibleEventCallbackType)(TAPEventIDType, void*, bool, TAPErrorIDType, const char*, const char*);/// 线程轮询事件回调typedef void(*FAPLoopEventCallbackType)();

结构体

class APLoginField:    _fields_ = [        ('License', ctypes.c_char*256), #///许可证        ('UserType', ctypes.c_int), #///客户类型        ('UserID', ctypes.c_char*16), #///客户号        ('Password', ctypes.c_char*41), #///密码        ('InvestorID', ctypes.c_char*16), #///投资者代码,如果未设置则使用UserID        ('AccountID', ctypes.c_char*21), #///资金账户,无需设置        ('DepartmentID', ctypes.c_char*11), #///部门代码,无需设置        ('TraderFrontType', ctypes.c_int), #///交易前置类型        ('TraderFrontAddress', ctypes.c_char*32), #///交易前置地址(tcp://127.0.0.1:22222)        ('MdFrontType', ctypes.c_int), #///行情前置类型        ('MdFrontAddress', ctypes.c_char*32), #///行情前置地址(tcp://127.0.0.1:22222)        ('ConnectTimeout', ctypes.c_longlong), #///初始化超时退出(微秒)        ('TaskExecuteGap', ctypes.c_longlong), #///账户任务执行间隔(微秒)        ('TaskFailedGap', ctypes.c_longlong), #///任务失败执行间隔(微秒)        ('TaskExecuteTimeout', ctypes.c_longlong), #///账户任务执行超时(微秒),未设置或者小于10秒时以10秒阈值        ('LoopGap', ctypes.c_longlong), #///Loop线程间隔(微秒)        ('IDRange', ctypes.c_int), #///管理标识        ('BasePath', ctypes.c_char*128), #///文件路径        ('BrokerID', ctypes.c_char*11), #///BrokerID(期货专用)        ('AppID', ctypes.c_char*33), #///AppID(期货专用)        ('AuthCode', ctypes.c_char*17), #///AuthCode(期货专用)        ('HDSerial', ctypes.c_char*33), #///硬盘序列号        ('MacAddress', ctypes.c_char*21), #///Mac地址        ('OuterIPAddress', ctypes.c_char*16), #///公网IP地址        ('OuterPort', ctypes.c_int), #///公网IP端口号        ('InnerIPAddress', ctypes.c_char*16), #///内网IP地址        ('UserProductInfo', ctypes.c_char*11), #///产品信息        ('TerminalInfo', ctypes.c_char*256), #///终端信息    ]class APMarketDataField:    _fields_ = [        ('TradingDay', ctypes.c_char*9), #///交易日        ('ExchangeID', ctypes.c_char*9), #///交易所        ('StandardID', ctypes.c_char*81), #///标准交易代码        ('MarketDataStatus', ctypes.c_char*1), #///行情状态        ('UpdateTime', ctypes.c_char*9), #///更新时间        ('UpdateMillisec', ctypes.c_int), #///更新毫秒        ('LastPrice', ctypes.c_double), #///最新价        ('PreClosePrice', ctypes.c_double), #///昨收盘价        ('PreSettlementPrice', ctypes.c_double), #///昨结算价        ('OpenPrice', ctypes.c_double), #///今开盘价        ('HighestPrice', ctypes.c_double), #///最高价        ('LowestPrice', ctypes.c_double), #///最低价        ('BidPrice1', ctypes.c_double), #///买1价        ('BidVolume1', ctypes.c_int), #///买1量        ('AskPrice1', ctypes.c_double), #///卖1价        ('AskVolume1', ctypes.c_int), #///卖1量        ('UpperLimitPrice', ctypes.c_double), #///涨停价        ('LowerLimitPrice', ctypes.c_double), #///跌停价        ('OpenInterest', ctypes.c_double), #///持仓量        ('PreOpenInterest', ctypes.c_double), #///昨持仓量        ('Volume', ctypes.c_longlong), #///成交量        ('Turnover', ctypes.c_double), #///成交金额        ('AveragePrice', ctypes.c_double), #///当日均价        ('BidPrice2', ctypes.c_double), #///买2价        ('BidVolume2', ctypes.c_int), #///买2量        ('AskPrice2', ctypes.c_double), #///卖2价        ('AskVolume2', ctypes.c_int), #///卖2量        ('BidPrice3', ctypes.c_double), #///买3价        ('BidVolume3', ctypes.c_int), #///买3量        ('AskPrice3', ctypes.c_double), #///卖3价        ('AskVolume3', ctypes.c_int), #///卖3量        ('BidPrice4', ctypes.c_double), #///买4价        ('BidVolume4', ctypes.c_int), #///买4量        ('AskPrice4', ctypes.c_double), #///卖4价        ('AskVolume4', ctypes.c_int), #///卖4量        ('BidPrice5', ctypes.c_double), #///买5价        ('BidVolume5', ctypes.c_int), #///买5量        ('AskPrice5', ctypes.c_double), #///卖5价        ('AskVolume5', ctypes.c_int), #///卖5量    ]class APOrderField:    _fields_ = [        ('TradingDay', ctypes.c_char*9), #///交易日        ('UserID', ctypes.c_char*16), #///客户号        ('ShareholderID', ctypes.c_char*11), #///股东账户代码        ('SessionID', ctypes.c_int), #///会话号        ('FrontID', ctypes.c_int), #///前置号        ('OrderID', ctypes.c_int), #///报单引用        ('OrderMark', ctypes.c_int), #///订单备注        ('ExchangeID', ctypes.c_char*9), #///交易所        ('StandardID', ctypes.c_char*81), #///标准交易代码        ('Direction', ctypes.c_char*1), #///订单方向        ('OffsetFlag', ctypes.c_char*1), #///开平标志        ('OrderType', ctypes.c_char*1), #///订单类型        ('IsBuyFromMarket', ctypes.c_bool), #///是否是买入        ('IsLimitOrder', ctypes.c_bool), #///是否是限价单        ('CombineOrderType', ctypes.c_char*5),        ('CreditQuotaType', ctypes.c_char*1), #///头寸类型(两融专用)        ('CreditDebtID', ctypes.c_char*21), #///信用负债编号(两融专用)        ('OriginalVolume', ctypes.c_int), #///报单数量        ('OriginalPrice', ctypes.c_double), #///报单价格        ('OrderLocalTime', ctypes.c_longlong), #///本地报单时间        ('OrderSysID', ctypes.c_char*21), #///系统编号        ('InsertTime', ctypes.c_char*9), #///申报时间        ('UpdateTime', ctypes.c_char*9), #///交易所接收时间        ('OrderStatus', ctypes.c_char*1), #///订单状态        ('TradedVolumeChange', ctypes.c_int), #///成交数量变化        ('TradedVolume', ctypes.c_int), #///全部成交数量        ('CanceledVolume', ctypes.c_int), #///全部撤单数量        ('LastTradedPrice', ctypes.c_double), #///最近一次成交价        ('TradedVolumeChangeOfTurnover', ctypes.c_int), #///与成交额对应的成交数量变化        ('TradedVolumeOfTurnover', ctypes.c_int), #///与成交额对应的全部成交数量        ('TurnoverChange', ctypes.c_double), #///成交额        ('Turnover', ctypes.c_double), #///成交额        ('AverageCost', ctypes.c_double), #///平均成本        ('UsableVolume', ctypes.c_int), #///可用持仓        ('UseableCash', ctypes.c_double), #///可用资金        ('ErrorID', ctypes.c_int), #///错误代码        ('Message', ctypes.c_char*256), #///信息    ]class APTransferAssetField:    _fields_ = [        ('TradingDay', ctypes.c_char*9), #///交易日        ('UserID', ctypes.c_char*16), #///客户号        ('TransferID', ctypes.c_int), #///资产划转编号        ('TransferStatus', ctypes.c_char*1), #///转移状态        ('TransferFlag', ctypes.c_char*1
                      

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
smart-city: 智慧城市 智慧社区 saas 多租户 SpringCloud发布时间:2022-03-25
下一篇:
gee-task: 一个极简的敏捷项目管理系统。发布时间:2022-03-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap