Exemplo n.º 1
0
def cancel_order(order_id: str,
                 exchange: str = CRYPTO_EXCHANGE,
                 api_key: str = CRYPTO_API_KEY,
                 api_secret: str = CRYPTO_API_SECRET,
                 exchange_password: Any = CRYPTO_API_PASSWORD,
                 exchange_uid: Any = CRYPTO_API_UID,
                 test_mode: bool = False) -> Any:
    """Cancel a specific order"""
    try:
        if test_mode == True:
            url = CRYPTO_URL_TEST
        else:
            url = CRYPTO_URL_LIVE
        payload = {'order_id': order_id}
        response = requests.post('{}/cancel_order/{}'.format(url, exchange),
                                 headers=crypto_get_headers(
                                     api_key, api_secret, exchange_password,
                                     exchange_uid),
                                 json=payload)
        if response:
            return response.json()
        if response.status_code == 400:
            logger.error('Oops! An error Occurred ⚠️')
            raise BadRequest(response.text)
        if response.status_code == 401:
            logger.error('Oops! An error Occurred ⚠️')
            raise InvalidCredentials(response.text)
    except Exception as exception:
        logger.error('Oops! An error Occurred ⚠️')
        raise exception
Exemplo n.º 2
0
def user_positions(exchange: str = CRYPTO_EXCHANGE,
                   api_key: str = CRYPTO_API_KEY,
                   api_secret: str = CRYPTO_API_SECRET,
                   exchange_password: Any = CRYPTO_API_PASSWORD,
                   exchange_uid: Any = CRYPTO_API_UID,
                   test_mode: bool = False) -> Any:
    """get your positions"""
    try:
        if test_mode == True:
            url = CRYPTO_URL_TEST
        else:
            url = CRYPTO_URL_LIVE
        response = requests.post('{}/positions/{}'.format(url, exchange),
                                 headers=crypto_get_headers(
                                     api_key, api_secret, exchange_password,
                                     exchange_uid))
        if response:
            return response.json()
        if response.status_code == 400:
            logger.error('Oops! An error Occurred ⚠️')
            raise BadRequest(response.text)
        if response.status_code == 401:
            logger.error('Oops! An error Occurred ⚠️')
            raise InvalidCredentials(response.text)
    except Exception as exception:
        logger.error('Oops! An error Occurred ⚠️')
        raise exception
Exemplo n.º 3
0
def user_withdrawls(currency_code: str,
                    exchange: str = CRYPTO_EXCHANGE,
                    api_key: str = CRYPTO_API_KEY,
                    api_secret: str = CRYPTO_API_SECRET,
                    exchange_password: Any = CRYPTO_API_PASSWORD,
                    exchange_uid: Any = CRYPTO_API_UID,
                    test_mode: bool = False) -> Any:
    """Not in docs yet. Needs to be tested.Get your withdrawls"""
    try:
        if test_mode == True:
            url = CRYPTO_URL_TEST
        else:
            url = CRYPTO_URL_LIVE
        payload = {'currency_code': currency_code}
        response = requests.post('{}/withdrawls/{}'.format(url, exchange),
                                 headers=crypto_get_headers(
                                     api_key, api_secret, exchange_password,
                                     exchange_uid),
                                 json=payload)
        if response:
            return response.json()
        if response.status_code == 400:
            logger.error('Oops! An error Occurred ⚠️')
            raise BadRequest(response.text)
        if response.status_code == 401:
            logger.error('Oops! An error Occurred ⚠️')
            raise InvalidCredentials(response.text)
    except Exception as exception:
        logger.error('Oops! An error Occurred ⚠️')
        raise exception
Exemplo n.º 4
0
def user_orders(symbol: str,
                exchange: str = CRYPTO_EXCHANGE,
                api_key: str = CRYPTO_API_KEY,
                api_secret: str = CRYPTO_API_SECRET,
                exchange_password: Any = CRYPTO_API_PASSWORD,
                exchange_uid: Any = CRYPTO_API_UID,
                test_mode: bool = False) -> Any:
    """Get all of your orders"""
    try:
        if test_mode == True:
            url = CRYPTO_URL_TEST
        else:
            url = CRYPTO_URL_LIVE
        payload = {'symbol': symbol.upper(), 'start': "", 'end': ""}
        response = requests.post('{}/get_orders/{}'.format(url, exchange),
                                 headers=crypto_get_headers(
                                     api_key, api_secret, exchange_password,
                                     exchange_uid),
                                 json=payload)
        if response:
            return response.json()
        if response.status_code == 400:
            logger.error('Oops! An error Occurred ⚠️')
            raise BadRequest(response.text)
        if response.status_code == 401:
            logger.error('Oops! An error Occurred ⚠️')
            raise InvalidCredentials(response.text)
    except Exception as exception:
        logger.error('Oops! An error Occurred ⚠️')
        raise exception
Exemplo n.º 5
0
def sell(symbol: str,
         quantity: Any,
         order_type: str = "market",
         price: Any = None,
         exchange: str = CRYPTO_EXCHANGE,
         api_key: str = CRYPTO_API_KEY,
         api_secret: str = CRYPTO_API_SECRET,
         exchange_password: Any = CRYPTO_API_PASSWORD,
         exchange_uid: Any = CRYPTO_API_UID,
         test_mode: bool = False) -> Any:
    """Create a sell order"""
    try:
        if test_mode == True:
            url = CRYPTO_URL_TEST
        else:
            url = CRYPTO_URL_LIVE
        payload = {
            'symbol': symbol.upper(),
            'quantity': quantity,
            'order_type': order_type,
            'limitPrice': price
        }
        response = requests.post('{}/sell/{}'.format(url, exchange),
                                 headers=crypto_get_headers(
                                     api_key, api_secret, exchange_password,
                                     exchange_uid),
                                 json=payload)
        if response:
            return response.json()
        if response.status_code == 400:
            logger.error('Oops! An error Occurred ⚠️')
            raise BadRequest(response.text)
        if response.status_code == 401:
            logger.error('Oops! An error Occurred ⚠️')
            raise InvalidCredentials(response.text)
    except Exception as exception:
        logger.error('Oops! An error Occurred ⚠️')
        raise exception