Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kraken not parsing stop price correctly #14109

Open
aely-aronoff opened this issue Jun 29, 2022 · 0 comments
Open

Kraken not parsing stop price correctly #14109

aely-aronoff opened this issue Jun 29, 2022 · 0 comments
Assignees
Labels

Comments

@aely-aronoff
Copy link

  • OS: Ubuntu 20.04
  • Programming Language version: Python 3.8.10
  • CCXT version: 1.89.19

Code:

exch = ccxt.kraken({
    "enableRateLimit": True,
    "apiKey": key,
    "secret": secret,
})
o = exch.create_order(
    symbol="ETH/USD", 
    type="stop-loss-limit", 
    side="buy", 
    amount=0.01, 
    price=1160,
    params={"price2": 1170},
)
o = exch.fetch_order(o["id"])
print("Order info:", o["info"]["descr"]["order"])
print("Stop price (Should be 1160):", o["stopPrice"])
print("Limit price (Should be 1170):", o["price"])

Output:

Order info: buy 0.01000000 ETHUSD @ stop loss 1160.00 -> limit 1170.00
Stop price (Should be 1160): 0.0
Limit price (Should be 1170): 1160.0

I've tracked down where the issue is occurring in the exchange source code. Initially, it actually gets the correct stop price from the order description:
https://github.com/ccxt/ccxt/blob/master/python/ccxt/kraken.py#L1343
A few lines down though, it overwrites that value with 0:
https://github.com/ccxt/ccxt/blob/master/python/ccxt/kraken.py#L1389

Below is the full order returned from calling exch.fetch_order(id):

{
    'info': {
        'id': '',
        'refid': None,
        'userref': '0',
        'status': 'open',
        'opentm': '1656542790.9874883',
        'starttm': '0',
        'expiretm': '0',
        'descr': {
            'pair': 'ETHUSD',
            'type': 'buy',
            'ordertype': 'stop-loss-limit',
            'price': '1160.00',
            'price2': '1170.00',
            'leverage': 'none',
            'order': 'buy 0.01000000 ETHUSD @ stop loss 1160.00 -> limit 1170.00',
            'close': ''
        },
        'vol': '0.01000000',
        'vol_exec': '0.00000000',
        'cost': '0.00000',
        'fee': '0.00000',
        'price': '0.00000',
        'stopprice': '0.00000',
        'limitprice': '0.00000',
        'misc': '',
        'oflags': 'fciq',
        'reason': None
    },
    'id': '',
    'clientOrderId': '0',
    'timestamp': 1656542790987,
    'datetime': '2022-06-29T22:46:30.987Z',
    'lastTradeTimestamp': None,
    'status': 'open',
    'symbol': 'ETH/USD',
    'type': 'stop-loss-limit',
    'timeInForce': None,
    'postOnly': None,
    'side': 'buy',
    'price': 1160.0,
    'stopPrice': 0.0,
    'cost': 0.0,
    'amount': 0.01,
    'filled': 0.0,
    'average': None,
    'remaining': 0.01,
    'fee': {'cost': 0.0, 'rate': None, 'currency': 'USD'},
    'trades': [],
    'fees': [{'cost': 0.0, 'rate': None, 'currency': 'USD'}]
}

You can see that although the order description states "stop loss 1160.00", it also inexplicably has 'stopprice': '0.00000'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants