#coding=utf-8


"""
常量定义模块
"""


"""
账号类型
"""
# 期货
FUTURE_ACCOUNT = 1
# 股票
SECURITY_ACCOUNT = 2
# 信用
CREDIT_ACCOUNT = 3
# 期货期权
FUTURE_OPTION_ACCOUNT = 5
# 股票期权
STOCK_OPTION_ACCOUNT = 6
# 沪港通
HUGANGTONG_ACCOUNT = 7
# 深港通
SHENGANGTONG_ACCOUNT = 11

"""
委托类型
"""
#/ *期货六键风格 * /
FUTURE_OPEN_LONG = 0 # 开多
FUTURE_CLOSE_LONG_HISTORY = 1 # 平昨多
FUTURE_CLOSE_LONG_TODAY = 2 # 平今多
FUTURE_OPEN_SHORT = 3 # 开空
FUTURE_CLOSE_SHORT_HISTORY = 4 # 平昨空
FUTURE_CLOSE_SHORT_TODAY = 5 # 平今空
# / *期货四键风格 * /
FUTURE_CLOSE_LONG_TODAY_FIRST = 6 # 平多，优先平今
FUTURE_CLOSE_LONG_HISTORY_FIRST = 7 # 平多，优先平昨
FUTURE_CLOSE_SHORT_TODAY_FIRST = 8 # 平空，优先平今
FUTURE_CLOSE_SHORT_HISTORY_FIRST = 9 # 平空，优先平昨

# / *期货两键风格 * /
FUTURE_CLOSE_LONG_TODAY_HISTORY_THEN_OPEN_SHORT = 10 # 卖出，如有多仓，优先平仓，优先平今，如有余量，再开空
FUTURE_CLOSE_LONG_HISTORY_TODAY_THEN_OPEN_SHORT = 11 # 卖出，如有多仓，优先平仓，优先平昨，如有余量，再开空
FUTURE_CLOSE_SHORT_TODAY_HISTORY_THEN_OPEN_LONG = 12 # 买入，如有空仓，优先平仓，优先平今，如有余量，再开多
FUTURE_CLOSE_SHORT_HISTORY_TODAY_THEN_OPEN_LONG = 13 # 买入，如有空仓，优先平仓，优先平昨，如有余量，再开多
FUTURE_OPEN = 14 # 买入，不优先平仓
FUTURE_CLOSE = 15 # 卖出，不优先平仓

# / *期货 - 跨商品套利 * /
FUTURE_ARBITRAGE_OPEN = 16 # 开仓
FUTURE_ARBITRAGE_CLOSE_HISTORY_FIRST = 17 # 平, 优先平昨
FUTURE_ARBITRAGE_CLOSE_TODAY_FIRST = 18 # 平, 优先平今

# / *期货展期 * /
FUTURE_RENEW_LONG_CLOSE_HISTORY_FIRST = 19 # 看多, 优先平昨
FUTURE_RENEW_LONG_CLOSE_TODAY_FIRST = 20 # 看多，优先平今
FUTURE_RENEW_SHORT_CLOSE_HISTORY_FIRST = 21 # 看空，优先平昨
FUTURE_RENEW_SHORT_CLOSE_TODAY_FIRST = 22 # 看空，优先平今

# / *股票期权 * /
STOCK_OPTION_BUY_OPEN = 48 # 买入开仓，以下用于个股期权交易业务
STOCK_OPTION_SELL_CLOSE = 49 # 卖出平仓
STOCK_OPTION_SELL_OPEN = 50 # 卖出开仓
STOCK_OPTION_BUY_CLOSE = 51 # 买入平仓
STOCK_OPTION_COVERED_OPEN = 52 # 备兑开仓
STOCK_OPTION_COVERED_CLOSE = 53 # 备兑平仓
STOCK_OPTION_CALL_EXERCISE = 54 # 认购行权
STOCK_OPTION_PUT_EXERCISE = 55 # 认沽行权
STOCK_OPTION_SECU_LOCK = 56 # 证券锁定
STOCK_OPTION_SECU_UNLOCK = 57 # 证券解锁

# /*期货期权*/
OPTION_FUTURE_OPTION_EXERCISE = 100 # 期货期权行权

STOCK_BUY = 23
STOCK_SELL = 24
CREDIT_BUY = 23    #担保品买入
CREDIT_SELL = 24   #担保品卖出
CREDIT_FIN_BUY = 27 #融资买入
CREDIT_SLO_SELL  = 28 #融券卖出
CREDIT_BUY_SECU_REPAY = 29 #买券还券
CREDIT_DIRECT_SECU_REPAY = 30 #直接还券
CREDIT_SELL_SECU_REPAY  = 31 #卖券还款
CREDIT_DIRECT_CASH_REPAY = 32 #直接还款
CREDIT_FIN_BUY_SPECIAL = 40 #专项融资买入
CREDIT_SLO_SELL_SPECIAL  = 41 #专项融券卖出
CREDIT_BUY_SECU_REPAY_SPECIAL = 42 #专项买券还券
CREDIT_DIRECT_SECU_REPAY_SPECIAL = 43 #专项直接还券
CREDIT_SELL_SECU_REPAY_SPECIAL  = 44 #专项卖券还款
CREDIT_DIRECT_CASH_REPAY_SPECIAL = 45 #专项直接还款

ORDER_TYPE_SET = {
    STOCK_BUY
    , STOCK_SELL
    , CREDIT_BUY
    , CREDIT_SELL
    , CREDIT_FIN_BUY
    , CREDIT_SLO_SELL
    , CREDIT_BUY_SECU_REPAY
    , CREDIT_DIRECT_SECU_REPAY
    , CREDIT_SELL_SECU_REPAY
    , CREDIT_DIRECT_CASH_REPAY
    , CREDIT_FIN_BUY_SPECIAL
    , CREDIT_SLO_SELL_SPECIAL
    , CREDIT_BUY_SECU_REPAY_SPECIAL
    , CREDIT_DIRECT_SECU_REPAY_SPECIAL
    , CREDIT_SELL_SECU_REPAY_SPECIAL
    , CREDIT_DIRECT_CASH_REPAY_SPECIAL
}

"""
报价类型
"""
# 最新价
LATEST_PRICE = 5
# 指定价/限价
FIX_PRICE = 11
# 最优五档即时成交剩余撤销[上交所][股票]
MARKET_SH_CONVERT_5_CANCEL = 42
# 最优五档即时成交剩转限价[上交所][股票]
MARKET_SH_CONVERT_5_LIMIT = 43
# 对手方最优价格委托[上交所[股票]][深交所[股票][期权]]
MARKET_PEER_PRICE_FIRST = 44
# 本方最优价格委托[上交所[股票]][深交所[股票][期权]]
MARKET_MINE_PRICE_FIRST = 45
# 即时成交剩余撤销委托[深交所][股票][期权]
MARKET_SZ_INSTBUSI_RESTCANCEL = 46
# 最优五档即时成交剩余撤销[深交所][股票][期权]
MARKET_SZ_CONVERT_5_CANCEL = 47
# 全额成交或撤销委托[深交所][股票][期权]
MARKET_SZ_FULL_OR_CANCEL = 48


"""
市场类型
"""
# 上海市场
SH_MARKET = 0
# 深圳市场
SZ_MARKET = 1


"""
委托状态
"""
# 未报
ORDER_UNREPORTED = 48
# 待报
ORDER_WAIT_REPORTING = 49
# 已报
ORDER_REPORTED = 50
# 已报待撤
ORDER_REPORTED_CANCEL = 51
# 部成待撤
ORDER_PARTSUCC_CANCEL = 52
# 部撤
ORDER_PART_CANCEL = 53
# 已撤
ORDER_CANCELED = 54
# 部成
ORDER_PART_SUCC = 55
# 已成
ORDER_SUCCEEDED = 56
# 废单
ORDER_JUNK = 57
# 未知
ORDER_UNKNOWN = 255


"""
账号状态
"""
#无效
ACCOUNT_STATUS_INVALID = -1
#正常
ACCOUNT_STATUS_OK = 0
#连接中
ACCOUNT_STATUS_WAITING_LOGIN = 1
#登陆中
ACCOUNT_STATUSING = 2
#失败
ACCOUNT_STATUS_FAIL = 3
#初始化中
ACCOUNT_STATUS_INITING = 4
#数据刷新校正中
ACCOUNT_STATUS_CORRECTING = 5
#收盘后
ACCOUNT_STATUS_CLOSED = 6
#穿透副链接断开 
ACCOUNT_STATUS_ASSIS_FAIL = 7
#系统停用（总线使用-密码错误超限）
ACCOUNT_STATUS_DISABLEBYSYS = 8
#用户停用（总线使用）
ACCOUNT_STATUS_DISABLEBYUSER = 9