Beispiel #1
0
def take_order(request):
    instrument_id = request.GET.get('instrument_id')
    order_type = request.GET.get('order_type')
    type = request.GET.get('type')
    size = request.GET.get('size')
    match_price = request.GET.get('match_price')
    price = request.GET.get('price')
    client_oid = 'crypto' + str(int(time.time()))
    print(client_oid)
    swapAPI = swap.SwapAPI(api_key, secret_key, passphrase, False)
    result = swapAPI.take_order(instrument_id, type, price, size, client_oid,
                                order_type, match_price)
    return HttpResponse(json.dumps(result), content_type="application/json")
Beispiel #2
0
def get_account_info(request):
    account_type = request.GET.get('account_type')
    if account_type == '1':
        spotAPI = spot.SpotAPI(api_key, secret_key, passphrase, False)
        # 币币账户信息 (20次/2s)
        result = spotAPI.get_account_info()
    elif account_type == '3':
        futureAPI = future.FutureAPI(api_key, secret_key, passphrase, False)
        result = futureAPI.get_accounts()
    elif account_type == '6':
        accountAPI = account.AccountAPI(api_key, secret_key, passphrase, False)
        result = accountAPI.get_wallet()
    elif account_type == '8':
        accountAPI = account.AccountAPI(api_key, secret_key, passphrase, False)
        result = accountAPI.get_wallet()
    elif account_type == '9':
        swapAPI = swap.SwapAPI(api_key, secret_key, passphrase, False)
        result = swapAPI.get_accounts()
    elif account_type == '16':
        swapAPI = swap.SwapAPI(api_key, secret_key, passphrase, False)
        result = swapAPI.get_accounts()
    else:
        request = ({})
    return HttpResponse(json.dumps(result), content_type="application/json")
Beispiel #3
0
def get_position_swap(request):
    swapAPI = swap.SwapAPI(api_key, secret_key, passphrase, False)
    result = swapAPI.get_position()
    return HttpResponse(json.dumps(result), content_type="application/json")
Beispiel #4
0
def get_order_list(request):
    swapAPI = swap.SwapAPI(api_key, secret_key, passphrase, False)
    instrument_id = request.GET.get('instrument_id')
    state = request.GET.get('state')
    result = swapAPI.get_order_list(instrument_id, state)
    return HttpResponse(json.dumps(result), content_type="application/json")
Beispiel #5
0
def revoke_order(request):
    client_oid = request.GET.get('client_oid')
    print(client_oid)
    swapAPI = swap.SwapAPI(api_key, secret_key, passphrase, False)
    result = swapAPI.revoke_order('', client_oid)
    return HttpResponse(json.dumps(result), content_type="application/json")