ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.53k stars 7.47k forks source link

Phemex TE trigger price too small, invalid order #19940

Open Nitrix321 opened 10 months ago

Nitrix321 commented 10 months ago

Operating System

Windows 10

Programming Languages

Python

CCXT Version

4.1.51

Description

Hi,

if in position with symbol: SOL/USDT:USDT, the following error occurs:

InvalidOrder: phemex {"code":11046,"msg":"TE_TRIGGER_PRICE_TOO_SMALL","data":null}

I use exactly the same code with symbol: BTC/USD:USD and it's working fine.

Code

import ccxt
import pandas as pd
import numpy as np
import phemconfig
from datetime import date, datetime, timezone, tzinfo
import time, schedule
import plotly.express as px

phemex = ccxt.phemex({
    'enableRateLimit': True,
    'apiKey': phemconfig.api_key,
    'secret': phemconfig.api_secret})
  
symbol = 'SOL/USDT:USDT'
pos_size = 1

params2 = {"type":"swap","code":"USDT"}

phemex_pos=phemex.fetch_positions([symbol], params2)
#print(phemex_pos)
open_position = phemex_pos[0]
entry_price = float(open_position['entryPrice'])

print('Entry Price: ' , entry_price)

stop_price = (entry_price * 10000)

# I also tried without *10000   
# like this   -->  stop_price = entry_price 

stop_trigger2b = stop_price - 2   
# (above I tried with several different entries but always error Message Trigger Price too small, DATA NULL)

print(stop_trigger2b)

sl_params2ETH = {
        'clOrdID': 'stop-loss-order-then-market',
        'side': 'Sell',
        'ordType': 'Stop',
        'triggerType': 'ByLastPrice',
        'stopPxEp': stop_trigger2b,
        'priceEp': stop_price,
        'orderQty': pos_size,
        'reduceOnly': True,
        'closeOnTrigger': True}

phemex.create_order(symbol, type='market', side='sell', amount=pos_size, price=stop_price, params=sl_params2ETH)
vatsalm30 commented 9 months ago

Hey I also have a similar error, do you have any updates on the situation?