HENG.H
上传用户:bjghjy
上传日期:2007-01-07
资源大小:379k
文件大小:20k
- /* CLIENT.H
- 通用热自助, 自助委托及电话委托请求与应答接口结构定义
- 杭州恒生电子有限公司研发部
- 版权所有, 一切权利保留
- 恒生BTRV5.0研研发组 1997.5
- */
- #if !defined (__CLIENT_H)
- #define __CLIENT_H
- //#define DEBUG
- #define LOCK_RETRY_TIMES 100 //锁不住时重试次数
- #define RETRY_DELAY 10 //锁不住时延时时间
- #define ITEMS 10
- #define ACCOUNT_LEN 11
- #define STOCK_LEN 7
- #define SEAT_LEN 7
- #define BANK_ACCOUNT_LEN 17
- #define CREDIT_CARD_LEN 17
- #define BANK_BRANCH_NO_LEN 9
- #define HK_FARE '0' // '0'-划卡,电话接通费
- #define WT_FARE '1' // '1'-委托
- #define CD_FARE '2' // '2'-撤单
- #define CX_FARE '3' // '3'-查询
- #define CS_FARE '4' // '4'-超时
- #define ZT_FARE '5' // '5'-转托
- #define HQ_FARE '6' // '6'-查行情
- #define REQUESTLEN 50 //须与转换服务器匹配
- #define ANSWERLEN 50 //须与转换服务器匹配
- //修改密码
- typedef struct
- {
- int fund_account; //资金帐号
- int password; //旧密码
- int password_new; //新密码
- } REQUEST_CHANGE_PASSWORD; //12 bytes
- //取股东信息
- typedef struct
- {
- char argment[ACCOUNT_LEN]; //含义由arg_type决定
- char arg_type;
- /*
- '0':fund_account
- '1':card_no
- '2':internal_account
- */
- int password; //密码
- } REQUEST_INQUIRE_ACCOUNT; //16 bytes
- //委托股票
- typedef struct
- {
- char argment[ACCOUNT_LEN]; //同上
- char arg_type;
- char entrust_bs; //'1':买入 '2':卖出
- char internal_code[STOCK_LEN]; //股票内码
- } REQUEST_ENTRUST_CODE; //20 bytes
- //委托确认
- typedef struct
- {
- char exchange_type; //交易所(委托股票时返回)
- char stock_account[ACCOUNT_LEN]; //股东代码
- int password; //密码
- char entrust_bs; //'1':买入 '2':卖出
- char stock_code[STOCK_LEN]; //股票代码
- float entrust_price; //价格
- int entrust_amount; //数量
- char entrust_type;
- /* 委托类别
- '0' -- 限价买卖 '1' -- 市价买卖
- '2' -- 限价撤单 '3' -- 市价撤单
- '4' -- 转托管 '5' -- 转托撤单
- '6' -- 查询
- */
- } REQUEST_ENTRUST_ENTER; //33 bytes
- //批量下单
- typedef struct
- {
- int fund_account;
- int password;
- char entrust_bs;
- char exchange_type;
- char stock_code[STOCK_LEN];
- float entrust_price;
- int entrust_amount;
- char entrust_type;
- /* 委托类别
- '0' -- 限价买卖 '1' -- 市价买卖
- '2' -- 限价撤单 '3' -- 市价撤单
- '4' -- 转托管 '5' -- 转托撤单
- '6' -- 查询
- */
- int start_account_number; //从第几个股东帐号开始
- int entrust_number; //委托笔数
- } REQUEST_BATCH_ENTRUST; //38 bytes
- //委托撤单
- typedef struct
- {
- int fund_account; //资金帐号
- int password; //密码
- int entrust_serial_no; //请撤委托号
- } REQUEST_ENTRUST_CANCEL; //12 bytes
- //查询行情
- typedef struct
- {
- char exchange_type; //交易所
- char stock_code[STOCK_LEN]; //股票内码
- } REQUEST_INQUIRE_PRICE; //12 bytes
- //查询委托
- typedef struct
- {
- char arg_type; //'0':采用fund_account '3':采用exchange_type+stock_account
- int fund_account; //资金帐号
- char exchange_type; //交易所
- char stock_account[ACCOUNT_LEN]; //股东帐号
- char stock_code[STOCK_LEN]; //非空串:指定股票代码 "":不指定股票代码
- //只有当arg_type=='3'时stock_code才可取非空值
- int entrust_serial_no; //委托号
- char inquire_mode; //'0':取委托号相等者 '1':取后序记录 用于多页查询时承前启后
- // char cancel_enable; //'0':无限制 '1':只返回可撤单之委托 97.06.01
- } REQUEST_INQUIRE_ENTRUST; //31 bytes
- //查询成交
- typedef struct
- {
- char arg_type; //'0':fund_account '3':exchange_type+stock_account
- int fund_account; //资金帐号
- char exchange_type; //交易所
- char stock_account[ACCOUNT_LEN]; //股东帐号
- char stock_code[STOCK_LEN]; //非空串:指定股票代码 "":不指定股票代码
- //只有当arg_type=='3'时stock_code才可取非空值
- int serial_no; //取后序记录 用于多页查询时承前启后
- } REQUEST_INQUIRE_REAL; //29 bytes
- //查询股票
- typedef struct
- {
- char arg_type; //'0':fund_account '3':exchange_type+stock_account
- int fund_account;
- char exchange_type;
- char stock_account[ACCOUNT_LEN];
- char stock_code[STOCK_LEN]; //股票代码
- char inquire_mode; //'0':取股票代码相等者 '1':取后序记录 用于多页查询时承前启后
- //取后序记录时,第一次须将excharg_type, stock_account, stock_code 置空,
- //查下页时须置上次请求的最后一条记录的值
- //只有当arg_type=='3'时inquire_mode才可取值'0'
- } REQUEST_INQUIRE_STOCK; //26 bytes
- //查询历史成交
- typedef struct
- {
- char arg_type; //'0':fund_account '3':exchange_type+stock_account
- int fund_account; //资金帐号
- char exchange_type; //交易所
- char stock_account[ACCOUNT_LEN]; //股东帐号
- char stock_code[STOCK_LEN];//非空串:指定股票代码 "":不指定股票代码
- //只有当arg_type=='3'时stock_code才可取非空值
- int date;
- int serial_no; //date+serial_no 取后序记录 用于多页查询时承前启后
- } REQUEST_INQUIRE_DELIVER; //33 bytes
- typedef struct
- {
- int fund_account; //资金帐号
- int date; //日期
- int serial_no; //date+serial_no 取后序记录 用于多页查询时承前启后
- } REQUEST_INQUIRE_FCHISTORY; //查资金历史明细
- typedef struct
- {
- int fund_account; //资金帐号
- int serial_no; //date+serial_no 取后序记录 用于多页查询时承前启后
- } REQUEST_INQUIRE_FC; //查当日资金发生
- typedef struct
- {
- int fund_account; //资金帐号
- char exchange_type; //交易所
- char stock_type; //股票类别
- char fare_type;
- // '0'-划卡,电话接通费
- // '1'-委托
- // '2'-撤单
- // '3'-查询
- // '4'-超时
- // '5'-转托
- short times; //次数
- } REQUEST_FFARE; //9 bytes
- //Following Codes Are Designed For Bank Drawing or Depositing,WangFang Here!
- //存取委托银行帐号检验
- typedef struct
- {
- int fund_account; //资金帐号
- int password; //密码
- char entrust_type; //'1':转入 '2':转出
- char bank_no; //银行号
- }REQUEST_DEPOSIT_CODE; //24 bytes
- //存取委托确认
- typedef struct
- {
- int fund_account; //资金帐号
- int password; //密码
- char bank_no; //银行代码 (可置' '由转换机处理)
- char bank_password[11]; //银行密码(存款时用)
- char entrust_type; /* '1' 存 '2' 取 */
- double entrust_balance;
- }REQUEST_DEPOSIT_ENTER; //29 bytes
- //委托撤单
- typedef struct
- {
- int fund_account;
- int password;
- int entrust_serial_no; //请撤委托号
- }REQUEST_DEPOSIT_CANCEL; //19 bytes
- //查询存取委托
- typedef struct
- {
- int fund_account;
- int entrust_serial_no;
- char inquire_mode; //'0':取委托号相等者 '1':取后序记录 用于多页查询时承前启后
- }REQUEST_INQUIRE_FE; //16 bytes
- typedef union
- {
- REQUEST_CHANGE_PASSWORD r_chg_password;
- REQUEST_INQUIRE_ACCOUNT r_inq_account;
- REQUEST_ENTRUST_CODE r_ent_code;
- REQUEST_ENTRUST_ENTER r_ent_enter;
- REQUEST_BATCH_ENTRUST r_bat_ent;
- REQUEST_ENTRUST_CANCEL r_ent_cancel;
- REQUEST_INQUIRE_PRICE r_inq_price;
- REQUEST_INQUIRE_ENTRUST r_inq_entrust;
- REQUEST_INQUIRE_REAL r_inq_real;
- REQUEST_INQUIRE_STOCK r_inq_stock;
- REQUEST_INQUIRE_DELIVER r_inq_deliver;
- REQUEST_INQUIRE_FCHISTORY r_inq_fchistory;
- REQUEST_INQUIRE_FC r_inq_fc;
- REQUEST_FFARE r_ffare;
- REQUEST_DEPOSIT_CODE r_dep_code;
- REQUEST_DEPOSIT_ENTER r_dep_enter;
- REQUEST_DEPOSIT_CANCEL r_dep_cancel;
- REQUEST_INQUIRE_FE r_inq_fe;
- char reserved[REQUESTLEN]; //保证REQUEST长度
- } REQUEST;
- //注册信息
- typedef struct
- {
- char internal_account_len; //股东内码长度
- char fund_account_len; //资金帐号长度
- char card_no_len; //卡号长度
- char card_len; //交易卡长度
- char card_start_pos; //读卡起始位
- short tel_max_time; //委托使用时间
- char overtake_flag; //委托超时处理标志 '1':退出, '0':收超时费
- } ANSWER_LOGIN; //8 bytes
- //取股东信息
- typedef struct
- {
- char status[4]; //状态 "000"正常
- char exchange_type; //交易所
- char stock_account[ACCOUNT_LEN]; //股东帐号
- int fund_account; //资金帐号
- char customer_name[9]; //姓名
- double begin_balance; //昨日余额
- double current_balance; //当前余额
- double long_frozen; //长期冻结
- double bail_balance; //保证金
- double enable_balance; //可用金额
- double fetch_balance; //可取余额
- double interest; //预计利息
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- } ANSWER_INQUIRE_ACCOUNT; //86 bytes
- //委托股票
- typedef struct
- {
- char stock_account[ACCOUNT_LEN]; //股东帐号
- char alias[9]; //别名(股东户姓名)
- char exchange_type; //交易所代号
- char exchange_name[9]; //交易所名
- char stock_code[STOCK_LEN]; //股票代码
- char stock_name[9]; //股票名称
- int stock_enable_balance; //股票可卖余额(卖出)/股票可买数量(买入)
- char sure_bs; //确认买卖方向
- float last_price; //股票最新价
- char fund_frozen_flag; //资金冻结标志
- //'0':委托价冻结 '1':缺省价冻结
- float default_price; // 缺省价
- short amount_unit; // 数量最小单位
- float price_step; // 价格最小单位
- char trustee_flag; // 0:股票不托管 1:股票托管
- char market_flag; // '0':不允许 '1':允许市价
- double current_balance; //当前余额
- double enable_balance; //可用余额
- double fetch_balance; //可取金额
- char limit_type; //涨跌停标志
- float up_price; //涨停价
- float down_price; //跌停价
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- } ANSWER_ENTRUST_CODE; //60 bytes
- typedef struct
- {
- double current_balance; //当前余额
- double enable_balance; //可用金额
- double fetch_balance; //可取
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- } ANSWER_ENTRUST_ENTER; //24 bytes
- typedef struct
- {
- double current_balance; //(同上)
- double enable_balance;
- double fetch_balance;
- char end_stock_account[ACCOUNT_LEN]; //委托的最后一个股东帐号
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- } ANSWER_BATCH_ENTRUST; //35 bytes
- typedef struct
- {
- double current_balance; //(同上)
- double enable_balance;
- double fetch_balance;
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- } ANSWER_ENTRUST_CANCEL; //24 bytes
- //查询行情
- typedef struct
- {
- float index; //指数
- float prev_price; //昨收盘 S3 FZRSP
- float open_price; //今开盘 S4 FJRKP
- float last_price; //最新价 S8 FZJCJ
- float high_price; //最高价 S6 FZGCJ
- float low_price; //最低价 S7 FZDCJ
- double voltoday; //成交金额 S5 FCJJE
- int qtytoday; //成交数量 S11 FCJSS
- float buy1_price; //申买价一 S9 FJW
- float buy2_price; //申买价二 S16
- float buy3_price; //申买价三 S18
- float sale1_price; //申卖价一 S10
- float sale2_price; //申卖价二 S22
- float sale3_price; //申卖价三 S24
- int buy1_qty; //申买量一 S15 FBSL
- int buy2_qty; //申买量二 S17
- int buy3_qty; //申买量三 S19
- int sale1_qty; //申卖量一 S21 FSSL
- int sale2_qty; //申卖量二 S33
- int sale3_qty; //申卖量三 S25
- } ANSWER_INQUIRE_PRICE; //84 bytes
- //查询委托
- typedef struct
- {
- int entrust_serial_no; //用于下一页查询
- // char exchange_name[9]; //交易名称
- char stock_name[9]; //股票名称
- char stock_account[ACCOUNT_LEN]; //股东帐号
- char stock_code[STOCK_LEN]; //股票代码
- char entrust_bs; //'1':买入 '2':卖出
- float entrust_price; //价格
- int entrust_amount; //数量
- char entrust_type;
- /*
- '0' -- 限价买卖
- '1' -- 市价买卖
- '2' -- 限价撤单
- '3' -- 市价撤单
- '4' -- 转托管
- '5' -- 转托撤单
- '6' -- 查询
- */
- char entrust_status;
- /*
- '0' -- 未报
- '1' -- 待报
- '2' --
- '3' -- 已报
- '4' -- 请撤
- '5' -- 部撤
- '6' -- 已撤
- '7' -- 部成
- '8' -- 已成
- '9' -- 废单
- */
- } ANSWER_INQUIRE_ENTRUST; //42 bytes
- //查询成交
- typedef struct
- {
- int serial_no; //用于下一页查询
- char exchange_type; //交易所
- // char exchange_name[9]; //交易名称 970922. modify
- char stock_name[9]; //股票名称
- char stock_account[ACCOUNT_LEN]; //股东帐号
- char stock_code[STOCK_LEN]; //股票代码
- char bs; //'1':买入 '2':卖出
- float business_price; //价格
- int business_amount; //数量
- char real_status; //'0' -- 买卖 '1' -- 撤单 '2' -- 废单
- int business_time; //成交时间
- } ANSWER_INQUIRE_REAL; //46 bytes
- //查询股票
- typedef struct
- {
- char exchange_type; //交易所
- char stock_account[ACCOUNT_LEN]; //股东帐号
- char stock_code[STOCK_LEN]; //股票代码
- //exchange_type+stock_account+stock_code 用于下一页查询
- // char exchange_name[9]; //交易所名
- char stock_name[9]; //股票名称 97.09.21修改
- int begin_balance; //昨日余额
- int current_balance; //当前余额
- int enable_balance; //可卖数量
- float last_price; //最新价
- //jjs added 1997.07.14
- float hold_price; //买入均价
- int value_balance; //市值余额
- // double value;
- } ANSWER_INQUIRE_STOCK; //52 bytes
- typedef struct
- {
- int date; //日期
- int serial_no; //流水号(无其他用途)
- //date+serial_no 用于下一页查询
- char exchange_type; //交易所
- // char exchange_name[9]; //97.09.24 modify
- char stock_name[9]; //股票名称
- char stock_account[ACCOUNT_LEN]; //股东帐号
- char stock_code[STOCK_LEN]; //股票代码
- char bs; //'1':买入 '2':卖出 '3':回购拆入 '4':回购拆出 '5'拆入购回 '6'拆出购回
- float business_price; //价格
- int business_amount; //数量
- double clear_balance; //清算资金
- } ANSWER_INQUIRE_DELIVER; //53 bytes
- typedef struct
- {
- int date;
- int serial_no; //流水号
- //date+serial_no 用于下一页查询
- double occur; //发生金额
- double post_balance; //资金后余额
- char detail[29]; //备注信息
- } ANSWER_INQUIRE_FCHISTORY; //53 bytes
- typedef struct
- {
- int serial_no; //同上
- //serial_no 用于下一页查询
- double occur;
- double post_balance;
- char detail[33];
- } ANSWER_INQUIRE_FC; //53 bytes
- typedef struct
- {
- double current_balance;
- double enable_balance;
- double fetch_balance;
- double fare;
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- } ANSWER_FFARE; //32 bytes
- //The Following Structures Are Designed For Bank Depositing Or Drawing
- typedef struct
- {
- double current_balance;
- double fetch_balance; //资金可取金额
- double enable_balance;
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- }ANSWER_DEPOSIT_CODE; //24 bytes
- typedef struct
- {
- double current_balance;
- double enable_balance;
- double fetch_balance;
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- }ANSWER_DEPOSIT_ENTER; //24 bytes
- typedef struct
- {
- double current_balance;
- double enable_balance;
- double fetch_balance;
- double real_back_buy; //当日买入成交
- double real_back_sale; //当日卖出成交
- }ANSWER_DEPOSIT_CANCEL; //24 bytes
- //查询存取委托
- typedef struct
- {
- int entrust_serial_no; //用于下一页查询
- char entrust_type; //'1':存入 '2':取出 '3':撤消
- double entrust_balance; //金额
- char entrust_status;
- /*
- '0' //待确认(未报)
- '1' //银行确认
- '2' //银行否认
- '3' //被撤单
- '4' //已入帐
- '5' //人工确认
- '6' //人工否认
- '7' //正在处理
- */
- char bank_no;
- char bank_account[BANK_ACCOUNT_LEN];
- //add. 970917
- char error_message[11]; //可能将有所改动
- }ANSWER_INQUIRE_FE; //43 bytes
- typedef union
- {
- ANSWER_LOGIN a_login;
- ANSWER_INQUIRE_ACCOUNT a_inq_account;
- ANSWER_ENTRUST_CODE a_ent_code;
- ANSWER_ENTRUST_ENTER a_ent_enter;
- ANSWER_BATCH_ENTRUST a_bat_ent;
- ANSWER_ENTRUST_CANCEL a_ent_cancel;
- ANSWER_INQUIRE_PRICE a_inq_price;
- ANSWER_INQUIRE_ENTRUST a_inq_entrust[ITEMS];
- ANSWER_INQUIRE_REAL a_inq_real[ITEMS];
- ANSWER_INQUIRE_STOCK a_inq_stock[ITEMS];
- ANSWER_INQUIRE_DELIVER a_inq_deliver[ITEMS];
- ANSWER_INQUIRE_FCHISTORY a_inq_fchistory[ITEMS];
- ANSWER_INQUIRE_FC a_inq_fc[ITEMS];
- ANSWER_FFARE a_ffare;
- ANSWER_DEPOSIT_CODE a_dep_code;
- ANSWER_DEPOSIT_ENTER a_dep_ent;
- ANSWER_DEPOSIT_CANCEL a_dep_cancel;
- ANSWER_INQUIRE_FE a_inq_fe[ITEMS];
- char a_errormessage[50];
- } ANSWER;
- //以上定义与client.c无关
- typedef struct
- {
- unsigned char command;
- /*
- 0.空闲 1.注册 2.修改密码
- 3.请求股东资料 4.委托代码 5.委托确认
- 6.委托撤单 7.查行情 8.查委托
- 9.查成交 10.查股票 11.查历史
- 12.批量下单 13.查资金历史 14.查当日资金流水
- 15.前台收费 16.检验银行帐号 17.银行转帐请求
- 18.银行转帐取消 19.银行转帐查询
- */
- unsigned char status; //' 01':请求应答 ' 02':完成应答
- unsigned char entrust_way;
- /*
- '0' -- 自助委托 '1' -- 电话委托
- '2' -- 驻留委托 '3' -- 远程委托
- '4' -- 柜台委托 '5' -- 漫游委托
- '6' -- 分支委托
- */
- int error;
- /*
- <-50: 应答返回错误代码
- -50..-1: 系统保留
- >= 0: 成功应答
- 需返回流水号时为流水号
- 或返回应答库中有效应答数
- 批量下单成功笔数
- */
- #ifdef __SERVER_CCR
- REQUEST request;
- #else
- char detail[REQUESTLEN];
- #endif
- } REQUEST_BUFFER;
- extern unsigned int jack_flag; //电话委托内外线
- extern short inquire_line; //可查询的线数
- /* 对电话委托: 0..inquire_line线,既委托又查询
- inquire_line..line_number只能委托,不可查询
- 对刷卡委托: 0:只能委托,不可查询 否则既委托又查询
- */
- extern short ClientInit(char entrust_way, short line_num, void (*handlerror)(char *message));
- extern void ClientClose(void);
- extern short ClientSendRequest(short line, char command, char *buffer, short size);
- extern int ClientTestResult(short line);
- extern short ClientGetAnswer(short line, char *buffer, short size);
- #endif