xtquant.xttype
1#coding=utf-8 2from . import xtconstant 3 4""" 5定义Python的数据结构,给Python策略使用 6包含股票+信用 7""" 8 9class StockAccount(object): 10 """ 11 定义证券账号类, 用于证券账号的报撤单等 12 """ 13 def __new__(cls, account_id, account_type = 'STOCK'): 14 """ 15 :param account_id: 资金账号 16 :return: 若资金账号不为字符串,返回类型错误 17 """ 18 if not isinstance(account_id, str): 19 return u"资金账号必须为字符串类型" 20 return super(StockAccount, cls).__new__(cls) 21 22 def __init__(self, account_id, account_type = 'STOCK'): 23 """ 24 :param account_id: 资金账号 25 """ 26 account_type = account_type.upper() 27 if(account_type == "STOCK"): 28 self.account_type = xtconstant.SECURITY_ACCOUNT 29 elif(account_type == "CREDIT"): 30 self.account_type = xtconstant.CREDIT_ACCOUNT 31 elif(account_type == "FUTURE"): 32 self.account_type = xtconstant.FUTURE_ACCOUNT 33 elif(account_type == "HUGANGTONG"): 34 self.account_type = xtconstant.HUGANGTONG_ACCOUNT 35 elif(account_type == "SHENGANGTONG"): 36 self.account_type = xtconstant.SHENGANGTONG_ACCOUNT 37 else: 38 self.account_type = xtconstant.SECURITY_ACCOUNT 39 self.account_id = account_id 40 41 42class XtAsset(object): 43 """ 44 迅投股票账号资金结构 45 """ 46 def __init__(self, account_id, cash, frozen_cash, market_value, total_asset): 47 """ 48 :param account_id: 资金账号 49 :param cash: 可用 50 :param frozen_cash: 冻结 51 :param market_value: 持仓市值 52 :param total_asset: 总资产 53 """ 54 self.account_type = xtconstant.SECURITY_ACCOUNT 55 self.account_id = account_id 56 self.cash = cash 57 self.frozen_cash = frozen_cash 58 self.market_value = market_value 59 self.total_asset = total_asset 60 61 62class XtOrder(object): 63 """ 64 迅投股票委托结构 65 """ 66 def __init__(self, account_id, stock_code, 67 order_id, order_sysid, order_time, order_type, order_volume, 68 price_type, price, traded_volume, traded_price, 69 order_status, status_msg, strategy_name, order_remark): 70 """ 71 :param account_id: 资金账号 72 :param stock_code: 证券代码, 例如"600000.SH" 73 :param order_id: 委托编号 74 :param order_sysid: 柜台编号 75 :param order_time: 报单时间 76 :param order_type: 委托类型, 23:买, 24:卖 77 :param order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位 78 :param price_type: 报价类型, 详见帮助手册 79 :param price: 报价价格,如果price_type为指定价, 那price为指定的价格,否则填0 80 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 81 :param traded_price: 成交均价 82 :param order_status: 委托状态 83 :param status_msg: 委托状态描述, 如废单原因 84 :param strategy_name: 策略名称 85 :param order_remark: 委托备注 86 """ 87 self.account_type = xtconstant.SECURITY_ACCOUNT 88 self.account_id = account_id 89 self.stock_code = stock_code 90 self.order_id = order_id 91 self.order_sysid = order_sysid 92 self.order_time = order_time 93 self.order_type = order_type 94 self.order_volume = order_volume 95 self.price_type = price_type 96 self.price = price 97 self.traded_volume = traded_volume 98 self.traded_price = traded_price 99 self.order_status = order_status 100 self.status_msg = status_msg 101 self.strategy_name = strategy_name 102 self.order_remark = order_remark 103 104 105class XtTrade(object): 106 """ 107 迅投股票成交结构 108 """ 109 def __init__(self, account_id, stock_code, 110 order_type, traded_id, traded_time, traded_price, traded_volume, traded_amount, 111 order_id, order_sysid, strategy_name, order_remark): 112 """ 113 :param account_id: 资金账号 114 :param stock_code: 证券代码, 例如"600000.SH" 115 :param order_type: 委托类型 116 :param traded_id: 成交编号 117 :param traded_time: 成交时间 118 :param traded_price: 成交均价 119 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 120 :param traded_amount: 成交金额 121 :param order_id: 委托编号 122 :param order_sysid: 柜台编号 123 :param strategy_name: 策略名称 124 :param order_remark: 委托备注 125 """ 126 self.account_type = xtconstant.SECURITY_ACCOUNT 127 self.account_id = account_id 128 self.order_type = order_type 129 self.stock_code = stock_code 130 self.traded_id = traded_id 131 self.traded_time = traded_time 132 self.traded_price = traded_price 133 self.traded_volume = traded_volume 134 self.traded_amount = traded_amount 135 self.order_id = order_id 136 self.order_sysid = order_sysid 137 self.strategy_name = strategy_name 138 self.order_remark = order_remark 139 140 141class XtPosition(object): 142 """ 143 迅投股票持仓结构 144 """ 145 def __init__(self, account_id, stock_code, 146 volume, can_use_volume, open_price, market_value, 147 frozen_volume, on_road_volume, yesterday_volume): 148 """ 149 :param account_id: 资金账号 150 :param stock_code: 证券代码, 例如"600000.SH" 151 :param volume: 持仓数量,股票以'股'为单位, 债券以'张'为单位 152 :param can_use_volume: 可用数量, 股票以'股'为单位, 债券以'张'为单位 153 :param open_price: 平均建仓成本 154 :param market_value: 市值 155 :param frozen_volume: 冻结数量 156 :param on_road_volume: 在途股份 157 :param yesterday_volume: 昨夜拥股 158 """ 159 self.account_type = xtconstant.SECURITY_ACCOUNT 160 self.account_id = account_id 161 self.stock_code = stock_code 162 self.volume = volume 163 self.can_use_volume = can_use_volume 164 self.open_price = open_price 165 self.market_value = market_value 166 self.frozen_volume = frozen_volume 167 self.on_road_volume = on_road_volume 168 self.yesterday_volume = yesterday_volume 169 170 171class XtOrderError(object): 172 """ 173 迅投股票委托失败结构 174 """ 175 def __init__(self, account_id, order_id, 176 error_id=None, error_msg=None, 177 strategy_name=None, order_remark=None): 178 """ 179 :param account_id: 资金账号 180 :param order_id: 订单编号 181 :param error_id: 报单失败错误码 182 :param error_msg: 报单失败具体信息 183 :param strategy_name: 策略名称 184 :param order_remark: 委托备注 185 """ 186 self.account_type = xtconstant.SECURITY_ACCOUNT 187 self.account_id = account_id 188 self.order_id = order_id 189 self.error_id = error_id 190 self.error_msg = error_msg 191 self.strategy_name = strategy_name 192 self.order_remark = order_remark 193 194 195class XtCancelError(object): 196 """ 197 迅投股票委托撤单失败结构 198 """ 199 def __init__(self, account_id, order_id, market, order_sysid, 200 error_id=None, error_msg=None): 201 """ 202 :param account_id: 资金账号 203 :param order_id: 订单编号 204 :param market: 交易市场 0:上海 1:深圳 205 :param order_sysid: 柜台委托编号 206 :param error_id: 撤单失败错误码 207 :param error_msg: 撤单失败具体信息 208 """ 209 self.account_type = xtconstant.SECURITY_ACCOUNT 210 self.account_id = account_id 211 self.order_id = order_id 212 self.market = market 213 self.order_sysid = order_sysid 214 self.error_id = error_id 215 self.error_msg = error_msg 216 217 218class XtOrderResponse(object): 219 """ 220 迅投异步下单接口对应的委托反馈 221 """ 222 def __init__(self, account_id, order_id, strategy_name, order_remark, error_msg, seq): 223 """ 224 :param account_id: 资金账号 225 :param order_id: 订单编号 226 :param strategy_name: 策略名称 227 :param order_remark: 委托备注 228 :param seq: 下单请求序号 229 """ 230 self.account_type = xtconstant.SECURITY_ACCOUNT 231 self.account_id = account_id 232 self.order_id = order_id 233 self.strategy_name = strategy_name 234 self.order_remark = order_remark 235 self.error_msg = error_msg 236 self.seq = seq 237 238class XtAppointmentResponse(object): 239 """ 240 迅投异步约券接口对应的委托反馈 241 """ 242 def __init__(self, account_id, order_id, error_id, error_msg, seq): 243 """ 244 :param account_id: 资金账号 245 :param order_sysid: 订单编号 246 :param error_id: 错误编号 247 :param error_msg: 错误信息 248 :param seq: 下单请求序号 249 """ 250 if error_id == 0: 251 self.order_sysid = error_msg 252 self.error_msg = '' 253 else: 254 self.order_sysid = str(order_id) 255 self.error_msg = error_msg 256 257 self.account_id = account_id 258 self.error_id = error_id 259 self.seq = seq 260 261class XtCancelOrderResponse(object): 262 """ 263 迅投异步委托撤单请求返回结构 264 """ 265 def __init__(self, account_id, cancel_result, order_id, order_sysid, seq): 266 """ 267 :param account_id: 资金账号 268 :param cancel_result: 撤单结果 269 :param order_id: 订单编号 270 :param order_sysid: 柜台委托编号 271 :param seq: 撤单请求序号 272 """ 273 self.account_type = xtconstant.SECURITY_ACCOUNT 274 self.account_id = account_id 275 self.cancel_result = cancel_result 276 self.order_id = order_id 277 self.order_sysid = order_sysid 278 self.seq = seq 279 280 281class XtCreditOrder(XtOrder): 282 """ 283 迅投信用委托结构 284 """ 285 def __init__(self, account_id, stock_code, 286 order_id, order_time, order_type, order_volume, 287 price_type, price, traded_volume, traded_price, 288 order_status, status_msg, order_remark, contract_no): 289 """ 290 :param account_id: 资金账号 291 :param stock_code: 证券代码, 例如"600000.SH" 292 :param order_id: 委托编号 293 :param order_time: 报单时间 294 :param order_type: 委托类型, 23:买, 24:卖 295 :param order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位 296 :param price_type: 报价类型, 详见帮助手册 297 :param price: 报价价格,如果price_type为指定价, 那price为指定的价格,否则填0 298 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 299 :param traded_price: 成交均价 300 :param order_status: 委托状态 301 :param status_msg: 委托状态描述, 如废单原因 302 :param order_remark: 委托备注 303 :param contract_no: 两融合同编号 304 """ 305 self.account_type = xtconstant.CREDIT_ACCOUNT 306 self.account_id = account_id 307 self.stock_code = stock_code 308 self.order_id = order_id 309 self.order_time = order_time 310 self.order_type = order_type 311 self.order_volume = order_volume 312 self.price_type = price_type 313 self.price = price 314 self.traded_volume = traded_volume 315 self.traded_price = traded_price 316 self.order_status = order_status 317 self.status_msg = status_msg 318 self.order_remark = order_remark 319 self.contract_no = contract_no 320 321 322class XtCreditDeal(object): 323 """ 324 迅投信用成交结构 325 """ 326 def __init__(self, account_id, stock_code, 327 traded_id, traded_time, traded_price, 328 traded_volume, order_id, contract_no): 329 """ 330 :param account_id: 资金账号 331 :param stock_code: 证券代码, 例如"600000.SH" 332 :param traded_id: 成交编号 333 :param traded_time: 成交时间 334 :param traded_price: 成交均价 335 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 336 :param order_id: 委托编号 337 :param contract_no: 两融合同编号 338 """ 339 self.account_type = xtconstant.CREDIT_ACCOUNT 340 self.account_id = account_id 341 self.stock_code = stock_code 342 self.traded_id = traded_id 343 self.traded_time = traded_time 344 self.traded_price = traded_price 345 self.traded_volume = traded_volume 346 self.order_id = order_id 347 self.contract_no = contract_no 348 349class XtAccountStatus(object): 350 """ 351 迅投账号状态结构 352 """ 353 def __init__(self, account_id, account_type, status): 354 """ 355 :param account_id: 资金账号 356 :param account_type: 账号状态 357 :param status: 账号状态,详细见账号状态定义 358 """ 359 self.account_type = account_type 360 self.account_id = account_id 361 self.status = status
class
StockAccount:
10class StockAccount(object): 11 """ 12 定义证券账号类, 用于证券账号的报撤单等 13 """ 14 def __new__(cls, account_id, account_type = 'STOCK'): 15 """ 16 :param account_id: 资金账号 17 :return: 若资金账号不为字符串,返回类型错误 18 """ 19 if not isinstance(account_id, str): 20 return u"资金账号必须为字符串类型" 21 return super(StockAccount, cls).__new__(cls) 22 23 def __init__(self, account_id, account_type = 'STOCK'): 24 """ 25 :param account_id: 资金账号 26 """ 27 account_type = account_type.upper() 28 if(account_type == "STOCK"): 29 self.account_type = xtconstant.SECURITY_ACCOUNT 30 elif(account_type == "CREDIT"): 31 self.account_type = xtconstant.CREDIT_ACCOUNT 32 elif(account_type == "FUTURE"): 33 self.account_type = xtconstant.FUTURE_ACCOUNT 34 elif(account_type == "HUGANGTONG"): 35 self.account_type = xtconstant.HUGANGTONG_ACCOUNT 36 elif(account_type == "SHENGANGTONG"): 37 self.account_type = xtconstant.SHENGANGTONG_ACCOUNT 38 else: 39 self.account_type = xtconstant.SECURITY_ACCOUNT 40 self.account_id = account_id
定义证券账号类, 用于证券账号的报撤单等
StockAccount(account_id, account_type='STOCK')
23 def __init__(self, account_id, account_type = 'STOCK'): 24 """ 25 :param account_id: 资金账号 26 """ 27 account_type = account_type.upper() 28 if(account_type == "STOCK"): 29 self.account_type = xtconstant.SECURITY_ACCOUNT 30 elif(account_type == "CREDIT"): 31 self.account_type = xtconstant.CREDIT_ACCOUNT 32 elif(account_type == "FUTURE"): 33 self.account_type = xtconstant.FUTURE_ACCOUNT 34 elif(account_type == "HUGANGTONG"): 35 self.account_type = xtconstant.HUGANGTONG_ACCOUNT 36 elif(account_type == "SHENGANGTONG"): 37 self.account_type = xtconstant.SHENGANGTONG_ACCOUNT 38 else: 39 self.account_type = xtconstant.SECURITY_ACCOUNT 40 self.account_id = account_id
Parameters
- account_id: 资金账号
class
XtAsset:
43class XtAsset(object): 44 """ 45 迅投股票账号资金结构 46 """ 47 def __init__(self, account_id, cash, frozen_cash, market_value, total_asset): 48 """ 49 :param account_id: 资金账号 50 :param cash: 可用 51 :param frozen_cash: 冻结 52 :param market_value: 持仓市值 53 :param total_asset: 总资产 54 """ 55 self.account_type = xtconstant.SECURITY_ACCOUNT 56 self.account_id = account_id 57 self.cash = cash 58 self.frozen_cash = frozen_cash 59 self.market_value = market_value 60 self.total_asset = total_asset
迅投股票账号资金结构
XtAsset(account_id, cash, frozen_cash, market_value, total_asset)
47 def __init__(self, account_id, cash, frozen_cash, market_value, total_asset): 48 """ 49 :param account_id: 资金账号 50 :param cash: 可用 51 :param frozen_cash: 冻结 52 :param market_value: 持仓市值 53 :param total_asset: 总资产 54 """ 55 self.account_type = xtconstant.SECURITY_ACCOUNT 56 self.account_id = account_id 57 self.cash = cash 58 self.frozen_cash = frozen_cash 59 self.market_value = market_value 60 self.total_asset = total_asset
Parameters
- account_id: 资金账号
- cash: 可用
- frozen_cash: 冻结
- market_value: 持仓市值
- total_asset: 总资产
class
XtOrder:
63class XtOrder(object): 64 """ 65 迅投股票委托结构 66 """ 67 def __init__(self, account_id, stock_code, 68 order_id, order_sysid, order_time, order_type, order_volume, 69 price_type, price, traded_volume, traded_price, 70 order_status, status_msg, strategy_name, order_remark): 71 """ 72 :param account_id: 资金账号 73 :param stock_code: 证券代码, 例如"600000.SH" 74 :param order_id: 委托编号 75 :param order_sysid: 柜台编号 76 :param order_time: 报单时间 77 :param order_type: 委托类型, 23:买, 24:卖 78 :param order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位 79 :param price_type: 报价类型, 详见帮助手册 80 :param price: 报价价格,如果price_type为指定价, 那price为指定的价格,否则填0 81 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 82 :param traded_price: 成交均价 83 :param order_status: 委托状态 84 :param status_msg: 委托状态描述, 如废单原因 85 :param strategy_name: 策略名称 86 :param order_remark: 委托备注 87 """ 88 self.account_type = xtconstant.SECURITY_ACCOUNT 89 self.account_id = account_id 90 self.stock_code = stock_code 91 self.order_id = order_id 92 self.order_sysid = order_sysid 93 self.order_time = order_time 94 self.order_type = order_type 95 self.order_volume = order_volume 96 self.price_type = price_type 97 self.price = price 98 self.traded_volume = traded_volume 99 self.traded_price = traded_price 100 self.order_status = order_status 101 self.status_msg = status_msg 102 self.strategy_name = strategy_name 103 self.order_remark = order_remark
迅投股票委托结构
XtOrder( account_id, stock_code, order_id, order_sysid, order_time, order_type, order_volume, price_type, price, traded_volume, traded_price, order_status, status_msg, strategy_name, order_remark)
67 def __init__(self, account_id, stock_code, 68 order_id, order_sysid, order_time, order_type, order_volume, 69 price_type, price, traded_volume, traded_price, 70 order_status, status_msg, strategy_name, order_remark): 71 """ 72 :param account_id: 资金账号 73 :param stock_code: 证券代码, 例如"600000.SH" 74 :param order_id: 委托编号 75 :param order_sysid: 柜台编号 76 :param order_time: 报单时间 77 :param order_type: 委托类型, 23:买, 24:卖 78 :param order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位 79 :param price_type: 报价类型, 详见帮助手册 80 :param price: 报价价格,如果price_type为指定价, 那price为指定的价格,否则填0 81 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 82 :param traded_price: 成交均价 83 :param order_status: 委托状态 84 :param status_msg: 委托状态描述, 如废单原因 85 :param strategy_name: 策略名称 86 :param order_remark: 委托备注 87 """ 88 self.account_type = xtconstant.SECURITY_ACCOUNT 89 self.account_id = account_id 90 self.stock_code = stock_code 91 self.order_id = order_id 92 self.order_sysid = order_sysid 93 self.order_time = order_time 94 self.order_type = order_type 95 self.order_volume = order_volume 96 self.price_type = price_type 97 self.price = price 98 self.traded_volume = traded_volume 99 self.traded_price = traded_price 100 self.order_status = order_status 101 self.status_msg = status_msg 102 self.strategy_name = strategy_name 103 self.order_remark = order_remark
Parameters
- account_id: 资金账号
- stock_code: 证券代码, 例如"600000.SH"
- order_id: 委托编号
- order_sysid: 柜台编号
- order_time: 报单时间
- order_type: 委托类型, 23:买, 24: 卖
- order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位
- price_type: 报价类型, 详见帮助手册
- price: 报价价格,如果price_type为指定价, 那price为指定的价格,否则填0
- traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位
- traded_price: 成交均价
- order_status: 委托状态
- status_msg: 委托状态描述, 如废单原因
- strategy_name: 策略名称
- order_remark: 委托备注
class
XtTrade:
106class XtTrade(object): 107 """ 108 迅投股票成交结构 109 """ 110 def __init__(self, account_id, stock_code, 111 order_type, traded_id, traded_time, traded_price, traded_volume, traded_amount, 112 order_id, order_sysid, strategy_name, order_remark): 113 """ 114 :param account_id: 资金账号 115 :param stock_code: 证券代码, 例如"600000.SH" 116 :param order_type: 委托类型 117 :param traded_id: 成交编号 118 :param traded_time: 成交时间 119 :param traded_price: 成交均价 120 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 121 :param traded_amount: 成交金额 122 :param order_id: 委托编号 123 :param order_sysid: 柜台编号 124 :param strategy_name: 策略名称 125 :param order_remark: 委托备注 126 """ 127 self.account_type = xtconstant.SECURITY_ACCOUNT 128 self.account_id = account_id 129 self.order_type = order_type 130 self.stock_code = stock_code 131 self.traded_id = traded_id 132 self.traded_time = traded_time 133 self.traded_price = traded_price 134 self.traded_volume = traded_volume 135 self.traded_amount = traded_amount 136 self.order_id = order_id 137 self.order_sysid = order_sysid 138 self.strategy_name = strategy_name 139 self.order_remark = order_remark
迅投股票成交结构
XtTrade( account_id, stock_code, order_type, traded_id, traded_time, traded_price, traded_volume, traded_amount, order_id, order_sysid, strategy_name, order_remark)
110 def __init__(self, account_id, stock_code, 111 order_type, traded_id, traded_time, traded_price, traded_volume, traded_amount, 112 order_id, order_sysid, strategy_name, order_remark): 113 """ 114 :param account_id: 资金账号 115 :param stock_code: 证券代码, 例如"600000.SH" 116 :param order_type: 委托类型 117 :param traded_id: 成交编号 118 :param traded_time: 成交时间 119 :param traded_price: 成交均价 120 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 121 :param traded_amount: 成交金额 122 :param order_id: 委托编号 123 :param order_sysid: 柜台编号 124 :param strategy_name: 策略名称 125 :param order_remark: 委托备注 126 """ 127 self.account_type = xtconstant.SECURITY_ACCOUNT 128 self.account_id = account_id 129 self.order_type = order_type 130 self.stock_code = stock_code 131 self.traded_id = traded_id 132 self.traded_time = traded_time 133 self.traded_price = traded_price 134 self.traded_volume = traded_volume 135 self.traded_amount = traded_amount 136 self.order_id = order_id 137 self.order_sysid = order_sysid 138 self.strategy_name = strategy_name 139 self.order_remark = order_remark
Parameters
- account_id: 资金账号
- stock_code: 证券代码, 例如"600000.SH"
- order_type: 委托类型
- traded_id: 成交编号
- traded_time: 成交时间
- traded_price: 成交均价
- traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位
- traded_amount: 成交金额
- order_id: 委托编号
- order_sysid: 柜台编号
- strategy_name: 策略名称
- order_remark: 委托备注
class
XtPosition:
142class XtPosition(object): 143 """ 144 迅投股票持仓结构 145 """ 146 def __init__(self, account_id, stock_code, 147 volume, can_use_volume, open_price, market_value, 148 frozen_volume, on_road_volume, yesterday_volume): 149 """ 150 :param account_id: 资金账号 151 :param stock_code: 证券代码, 例如"600000.SH" 152 :param volume: 持仓数量,股票以'股'为单位, 债券以'张'为单位 153 :param can_use_volume: 可用数量, 股票以'股'为单位, 债券以'张'为单位 154 :param open_price: 平均建仓成本 155 :param market_value: 市值 156 :param frozen_volume: 冻结数量 157 :param on_road_volume: 在途股份 158 :param yesterday_volume: 昨夜拥股 159 """ 160 self.account_type = xtconstant.SECURITY_ACCOUNT 161 self.account_id = account_id 162 self.stock_code = stock_code 163 self.volume = volume 164 self.can_use_volume = can_use_volume 165 self.open_price = open_price 166 self.market_value = market_value 167 self.frozen_volume = frozen_volume 168 self.on_road_volume = on_road_volume 169 self.yesterday_volume = yesterday_volume
迅投股票持仓结构
XtPosition( account_id, stock_code, volume, can_use_volume, open_price, market_value, frozen_volume, on_road_volume, yesterday_volume)
146 def __init__(self, account_id, stock_code, 147 volume, can_use_volume, open_price, market_value, 148 frozen_volume, on_road_volume, yesterday_volume): 149 """ 150 :param account_id: 资金账号 151 :param stock_code: 证券代码, 例如"600000.SH" 152 :param volume: 持仓数量,股票以'股'为单位, 债券以'张'为单位 153 :param can_use_volume: 可用数量, 股票以'股'为单位, 债券以'张'为单位 154 :param open_price: 平均建仓成本 155 :param market_value: 市值 156 :param frozen_volume: 冻结数量 157 :param on_road_volume: 在途股份 158 :param yesterday_volume: 昨夜拥股 159 """ 160 self.account_type = xtconstant.SECURITY_ACCOUNT 161 self.account_id = account_id 162 self.stock_code = stock_code 163 self.volume = volume 164 self.can_use_volume = can_use_volume 165 self.open_price = open_price 166 self.market_value = market_value 167 self.frozen_volume = frozen_volume 168 self.on_road_volume = on_road_volume 169 self.yesterday_volume = yesterday_volume
Parameters
- account_id: 资金账号
- stock_code: 证券代码, 例如"600000.SH"
- volume: 持仓数量,股票以'股'为单位, 债券以'张'为单位
- can_use_volume: 可用数量, 股票以'股'为单位, 债券以'张'为单位
- open_price: 平均建仓成本
- market_value: 市值
- frozen_volume: 冻结数量
- on_road_volume: 在途股份
- yesterday_volume: 昨夜拥股
class
XtOrderError:
172class XtOrderError(object): 173 """ 174 迅投股票委托失败结构 175 """ 176 def __init__(self, account_id, order_id, 177 error_id=None, error_msg=None, 178 strategy_name=None, order_remark=None): 179 """ 180 :param account_id: 资金账号 181 :param order_id: 订单编号 182 :param error_id: 报单失败错误码 183 :param error_msg: 报单失败具体信息 184 :param strategy_name: 策略名称 185 :param order_remark: 委托备注 186 """ 187 self.account_type = xtconstant.SECURITY_ACCOUNT 188 self.account_id = account_id 189 self.order_id = order_id 190 self.error_id = error_id 191 self.error_msg = error_msg 192 self.strategy_name = strategy_name 193 self.order_remark = order_remark
迅投股票委托失败结构
XtOrderError( account_id, order_id, error_id=None, error_msg=None, strategy_name=None, order_remark=None)
176 def __init__(self, account_id, order_id, 177 error_id=None, error_msg=None, 178 strategy_name=None, order_remark=None): 179 """ 180 :param account_id: 资金账号 181 :param order_id: 订单编号 182 :param error_id: 报单失败错误码 183 :param error_msg: 报单失败具体信息 184 :param strategy_name: 策略名称 185 :param order_remark: 委托备注 186 """ 187 self.account_type = xtconstant.SECURITY_ACCOUNT 188 self.account_id = account_id 189 self.order_id = order_id 190 self.error_id = error_id 191 self.error_msg = error_msg 192 self.strategy_name = strategy_name 193 self.order_remark = order_remark
Parameters
- account_id: 资金账号
- order_id: 订单编号
- error_id: 报单失败错误码
- error_msg: 报单失败具体信息
- strategy_name: 策略名称
- order_remark: 委托备注
class
XtCancelError:
196class XtCancelError(object): 197 """ 198 迅投股票委托撤单失败结构 199 """ 200 def __init__(self, account_id, order_id, market, order_sysid, 201 error_id=None, error_msg=None): 202 """ 203 :param account_id: 资金账号 204 :param order_id: 订单编号 205 :param market: 交易市场 0:上海 1:深圳 206 :param order_sysid: 柜台委托编号 207 :param error_id: 撤单失败错误码 208 :param error_msg: 撤单失败具体信息 209 """ 210 self.account_type = xtconstant.SECURITY_ACCOUNT 211 self.account_id = account_id 212 self.order_id = order_id 213 self.market = market 214 self.order_sysid = order_sysid 215 self.error_id = error_id 216 self.error_msg = error_msg
迅投股票委托撤单失败结构
XtCancelError( account_id, order_id, market, order_sysid, error_id=None, error_msg=None)
200 def __init__(self, account_id, order_id, market, order_sysid, 201 error_id=None, error_msg=None): 202 """ 203 :param account_id: 资金账号 204 :param order_id: 订单编号 205 :param market: 交易市场 0:上海 1:深圳 206 :param order_sysid: 柜台委托编号 207 :param error_id: 撤单失败错误码 208 :param error_msg: 撤单失败具体信息 209 """ 210 self.account_type = xtconstant.SECURITY_ACCOUNT 211 self.account_id = account_id 212 self.order_id = order_id 213 self.market = market 214 self.order_sysid = order_sysid 215 self.error_id = error_id 216 self.error_msg = error_msg
Parameters
- account_id: 资金账号
- order_id: 订单编号
- market: 交易市场 0:上海 1: 深圳
- order_sysid: 柜台委托编号
- error_id: 撤单失败错误码
- error_msg: 撤单失败具体信息
class
XtOrderResponse:
219class XtOrderResponse(object): 220 """ 221 迅投异步下单接口对应的委托反馈 222 """ 223 def __init__(self, account_id, order_id, strategy_name, order_remark, error_msg, seq): 224 """ 225 :param account_id: 资金账号 226 :param order_id: 订单编号 227 :param strategy_name: 策略名称 228 :param order_remark: 委托备注 229 :param seq: 下单请求序号 230 """ 231 self.account_type = xtconstant.SECURITY_ACCOUNT 232 self.account_id = account_id 233 self.order_id = order_id 234 self.strategy_name = strategy_name 235 self.order_remark = order_remark 236 self.error_msg = error_msg 237 self.seq = seq
迅投异步下单接口对应的委托反馈
XtOrderResponse(account_id, order_id, strategy_name, order_remark, error_msg, seq)
223 def __init__(self, account_id, order_id, strategy_name, order_remark, error_msg, seq): 224 """ 225 :param account_id: 资金账号 226 :param order_id: 订单编号 227 :param strategy_name: 策略名称 228 :param order_remark: 委托备注 229 :param seq: 下单请求序号 230 """ 231 self.account_type = xtconstant.SECURITY_ACCOUNT 232 self.account_id = account_id 233 self.order_id = order_id 234 self.strategy_name = strategy_name 235 self.order_remark = order_remark 236 self.error_msg = error_msg 237 self.seq = seq
Parameters
- account_id: 资金账号
- order_id: 订单编号
- strategy_name: 策略名称
- order_remark: 委托备注
- seq: 下单请求序号
class
XtAppointmentResponse:
239class XtAppointmentResponse(object): 240 """ 241 迅投异步约券接口对应的委托反馈 242 """ 243 def __init__(self, account_id, order_id, error_id, error_msg, seq): 244 """ 245 :param account_id: 资金账号 246 :param order_sysid: 订单编号 247 :param error_id: 错误编号 248 :param error_msg: 错误信息 249 :param seq: 下单请求序号 250 """ 251 if error_id == 0: 252 self.order_sysid = error_msg 253 self.error_msg = '' 254 else: 255 self.order_sysid = str(order_id) 256 self.error_msg = error_msg 257 258 self.account_id = account_id 259 self.error_id = error_id 260 self.seq = seq
迅投异步约券接口对应的委托反馈
XtAppointmentResponse(account_id, order_id, error_id, error_msg, seq)
243 def __init__(self, account_id, order_id, error_id, error_msg, seq): 244 """ 245 :param account_id: 资金账号 246 :param order_sysid: 订单编号 247 :param error_id: 错误编号 248 :param error_msg: 错误信息 249 :param seq: 下单请求序号 250 """ 251 if error_id == 0: 252 self.order_sysid = error_msg 253 self.error_msg = '' 254 else: 255 self.order_sysid = str(order_id) 256 self.error_msg = error_msg 257 258 self.account_id = account_id 259 self.error_id = error_id 260 self.seq = seq
Parameters
- account_id: 资金账号
- order_sysid: 订单编号
- error_id: 错误编号
- error_msg: 错误信息
- seq: 下单请求序号
class
XtCancelOrderResponse:
262class XtCancelOrderResponse(object): 263 """ 264 迅投异步委托撤单请求返回结构 265 """ 266 def __init__(self, account_id, cancel_result, order_id, order_sysid, seq): 267 """ 268 :param account_id: 资金账号 269 :param cancel_result: 撤单结果 270 :param order_id: 订单编号 271 :param order_sysid: 柜台委托编号 272 :param seq: 撤单请求序号 273 """ 274 self.account_type = xtconstant.SECURITY_ACCOUNT 275 self.account_id = account_id 276 self.cancel_result = cancel_result 277 self.order_id = order_id 278 self.order_sysid = order_sysid 279 self.seq = seq
迅投异步委托撤单请求返回结构
XtCancelOrderResponse(account_id, cancel_result, order_id, order_sysid, seq)
266 def __init__(self, account_id, cancel_result, order_id, order_sysid, seq): 267 """ 268 :param account_id: 资金账号 269 :param cancel_result: 撤单结果 270 :param order_id: 订单编号 271 :param order_sysid: 柜台委托编号 272 :param seq: 撤单请求序号 273 """ 274 self.account_type = xtconstant.SECURITY_ACCOUNT 275 self.account_id = account_id 276 self.cancel_result = cancel_result 277 self.order_id = order_id 278 self.order_sysid = order_sysid 279 self.seq = seq
Parameters
- account_id: 资金账号
- cancel_result: 撤单结果
- order_id: 订单编号
- order_sysid: 柜台委托编号
- seq: 撤单请求序号
282class XtCreditOrder(XtOrder): 283 """ 284 迅投信用委托结构 285 """ 286 def __init__(self, account_id, stock_code, 287 order_id, order_time, order_type, order_volume, 288 price_type, price, traded_volume, traded_price, 289 order_status, status_msg, order_remark, contract_no): 290 """ 291 :param account_id: 资金账号 292 :param stock_code: 证券代码, 例如"600000.SH" 293 :param order_id: 委托编号 294 :param order_time: 报单时间 295 :param order_type: 委托类型, 23:买, 24:卖 296 :param order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位 297 :param price_type: 报价类型, 详见帮助手册 298 :param price: 报价价格,如果price_type为指定价, 那price为指定的价格,否则填0 299 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 300 :param traded_price: 成交均价 301 :param order_status: 委托状态 302 :param status_msg: 委托状态描述, 如废单原因 303 :param order_remark: 委托备注 304 :param contract_no: 两融合同编号 305 """ 306 self.account_type = xtconstant.CREDIT_ACCOUNT 307 self.account_id = account_id 308 self.stock_code = stock_code 309 self.order_id = order_id 310 self.order_time = order_time 311 self.order_type = order_type 312 self.order_volume = order_volume 313 self.price_type = price_type 314 self.price = price 315 self.traded_volume = traded_volume 316 self.traded_price = traded_price 317 self.order_status = order_status 318 self.status_msg = status_msg 319 self.order_remark = order_remark 320 self.contract_no = contract_no
迅投信用委托结构
XtCreditOrder( account_id, stock_code, order_id, order_time, order_type, order_volume, price_type, price, traded_volume, traded_price, order_status, status_msg, order_remark, contract_no)
286 def __init__(self, account_id, stock_code, 287 order_id, order_time, order_type, order_volume, 288 price_type, price, traded_volume, traded_price, 289 order_status, status_msg, order_remark, contract_no): 290 """ 291 :param account_id: 资金账号 292 :param stock_code: 证券代码, 例如"600000.SH" 293 :param order_id: 委托编号 294 :param order_time: 报单时间 295 :param order_type: 委托类型, 23:买, 24:卖 296 :param order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位 297 :param price_type: 报价类型, 详见帮助手册 298 :param price: 报价价格,如果price_type为指定价, 那price为指定的价格,否则填0 299 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 300 :param traded_price: 成交均价 301 :param order_status: 委托状态 302 :param status_msg: 委托状态描述, 如废单原因 303 :param order_remark: 委托备注 304 :param contract_no: 两融合同编号 305 """ 306 self.account_type = xtconstant.CREDIT_ACCOUNT 307 self.account_id = account_id 308 self.stock_code = stock_code 309 self.order_id = order_id 310 self.order_time = order_time 311 self.order_type = order_type 312 self.order_volume = order_volume 313 self.price_type = price_type 314 self.price = price 315 self.traded_volume = traded_volume 316 self.traded_price = traded_price 317 self.order_status = order_status 318 self.status_msg = status_msg 319 self.order_remark = order_remark 320 self.contract_no = contract_no
Parameters
- account_id: 资金账号
- stock_code: 证券代码, 例如"600000.SH"
- order_id: 委托编号
- order_time: 报单时间
- order_type: 委托类型, 23:买, 24: 卖
- order_volume: 委托数量, 股票以'股'为单位, 债券以'张'为单位
- price_type: 报价类型, 详见帮助手册
- price: 报价价格,如果price_type为指定价, 那price为指定的价格,否则填0
- traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位
- traded_price: 成交均价
- order_status: 委托状态
- status_msg: 委托状态描述, 如废单原因
- order_remark: 委托备注
- contract_no: 两融合同编号
Inherited Members
class
XtCreditDeal:
323class XtCreditDeal(object): 324 """ 325 迅投信用成交结构 326 """ 327 def __init__(self, account_id, stock_code, 328 traded_id, traded_time, traded_price, 329 traded_volume, order_id, contract_no): 330 """ 331 :param account_id: 资金账号 332 :param stock_code: 证券代码, 例如"600000.SH" 333 :param traded_id: 成交编号 334 :param traded_time: 成交时间 335 :param traded_price: 成交均价 336 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 337 :param order_id: 委托编号 338 :param contract_no: 两融合同编号 339 """ 340 self.account_type = xtconstant.CREDIT_ACCOUNT 341 self.account_id = account_id 342 self.stock_code = stock_code 343 self.traded_id = traded_id 344 self.traded_time = traded_time 345 self.traded_price = traded_price 346 self.traded_volume = traded_volume 347 self.order_id = order_id 348 self.contract_no = contract_no
迅投信用成交结构
XtCreditDeal( account_id, stock_code, traded_id, traded_time, traded_price, traded_volume, order_id, contract_no)
327 def __init__(self, account_id, stock_code, 328 traded_id, traded_time, traded_price, 329 traded_volume, order_id, contract_no): 330 """ 331 :param account_id: 资金账号 332 :param stock_code: 证券代码, 例如"600000.SH" 333 :param traded_id: 成交编号 334 :param traded_time: 成交时间 335 :param traded_price: 成交均价 336 :param traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位 337 :param order_id: 委托编号 338 :param contract_no: 两融合同编号 339 """ 340 self.account_type = xtconstant.CREDIT_ACCOUNT 341 self.account_id = account_id 342 self.stock_code = stock_code 343 self.traded_id = traded_id 344 self.traded_time = traded_time 345 self.traded_price = traded_price 346 self.traded_volume = traded_volume 347 self.order_id = order_id 348 self.contract_no = contract_no
Parameters
- account_id: 资金账号
- stock_code: 证券代码, 例如"600000.SH"
- traded_id: 成交编号
- traded_time: 成交时间
- traded_price: 成交均价
- traded_volume: 成交数量, 股票以'股'为单位, 债券以'张'为单位
- order_id: 委托编号
- contract_no: 两融合同编号
class
XtAccountStatus:
350class XtAccountStatus(object): 351 """ 352 迅投账号状态结构 353 """ 354 def __init__(self, account_id, account_type, status): 355 """ 356 :param account_id: 资金账号 357 :param account_type: 账号状态 358 :param status: 账号状态,详细见账号状态定义 359 """ 360 self.account_type = account_type 361 self.account_id = account_id 362 self.status = status
迅投账号状态结构
XtAccountStatus(account_id, account_type, status)
354 def __init__(self, account_id, account_type, status): 355 """ 356 :param account_id: 资金账号 357 :param account_type: 账号状态 358 :param status: 账号状态,详细见账号状态定义 359 """ 360 self.account_type = account_type 361 self.account_id = account_id 362 self.status = status
Parameters
- account_id: 资金账号
- account_type: 账号状态
- status: 账号状态,详细见账号状态定义