import sys
import os

#没有融券
def decode_atx_side(side):
    f_side = 0
    if side in [1,5]:
        return 1
    elif side == 2:
        return 2

def decode_atx_status(status):
    new_status = ""
    if status == 0:
        new_status = 'active'
    elif status == 2:
        new_status = 'filled'
    elif status == 4:
        new_status = 'canceled'
    return new_status

def side_to_target_type(side):
    target_type = ""
    if side in [1,5]:
        target_type = "buy"
    elif side == 2:
        target_type = "sell"
    return target_type

def decode_exchange_id(str_exchange):
    exchange = 0
    if str_exchange == 'SH':
        exchange = 101        #EXCHANGE_SSE
    elif str_exchange == 'SZ':
        exchange = 102        #EXCHANGE_SZE

    return exchange

def decode_ordtype(order_type:str):
    ord_type = -1
    mapping = {
        'kf_twap_plus': 101,
        'kf_vwap_plus': 102,
        'kf_twap_core': 103,
        'kf_vwap_core': 104,
        'kf_pov_core': 105,
        'kf_t0': 106,
        'kf_auction': 107,
        'kf_passthru': 201
    }
    ord_type = mapping.get(order_type, -1)
    return ord_type