question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set market take profit?

See original GitHub issue

The code as follows:

import ccxt
import time
from pprint import pprint
ftx = ccxt.ftx({
    'apiKey': 'my_apikey',
    'secret': 'my_secret',
})

symbol = 'BTC/USD:USD'
ftx.load_markets()
market = ftx.market(symbol)
btc_maket_price = float(market['info']['price'])
btc_amount = 20 / btc_maket_price
create_order = ftx.create_order(symbol, 'market', 'buy', btc_amount)

type = 'takeProfit'
side = 'sell'
rise_btc_price = btc_maket_price + btc_maket_price * 0.015
params = {
    'stopPrice': rise_btc_price,
}
order = ftx.create_order(symbol, type, side, btc_amount, params)

The errors as follows: Traceback (most recent call last): File “C:\Users\fxu50\PycharmProjects\pythonProject1\contract.py”, line 26, in <module> order = ftx.create_order(symbol, type, side, btc_amount, params) File “C:\Users\fxu50\PycharmProjects\pythonProject1\ccxt\ftx.py”, line 1625, in create_order raise InvalidOrder(self.id + ’ createOrder() does not support order type ’ + type + ‘, only limit, market, stop, trailingStop, or takeProfit orders are supported’) ccxt.base.errors.InvalidOrder: ftx createOrder() does not support order type takeProfit, only limit, market, stop, trailingStop, or takeProfit orders are supported

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
qwe231cvbcommented, Jun 15, 2022

@qwe231cvb you’re making a market takeProfit order, so you have to specify price=None or the actual limit price:

import ccxt
from pprint import pprint


print("CCXT Version:", ccxt.__version__)


ftx = ccxt.ftx({
    'apiKey': 'my_apikey',
    'secret': 'my_secret',
})

markets = exchange.load_markets()

# exchange.verbose = True  # uncomment for debugging purposes if necessary, after loading the markets

symbol = 'BTC/USD:USD'
ftx.load_markets()
market = ftx.market(symbol)
btc_maket_price = float(market['info']['price'])
btc_amount = 20 / btc_maket_price
create_order = ftx.create_order(symbol, 'market', 'buy', btc_amount)

type = 'takeProfit'
side = 'sell'
rise_btc_price = btc_maket_price + btc_maket_price * 0.015
params = {
    'stopPrice': rise_btc_price,
}
price = None  # or your takeProfit limit price  # -------- ↓
order = ftx.create_order(symbol, type, side, btc_amount, price, params)

Hope that answers your question.

It is ok now.

1reaction
kroitorcommented, Jun 15, 2022

@qwe231cvb you’re making a market takeProfit order, so you have to specify price=None or the actual limit price:

import ccxt
from pprint import pprint


print("CCXT Version:", ccxt.__version__)


ftx = ccxt.ftx({
    'apiKey': 'my_apikey',
    'secret': 'my_secret',
})

markets = exchange.load_markets()

# exchange.verbose = True  # uncomment for debugging purposes if necessary, after loading the markets

symbol = 'BTC/USD:USD'
ftx.load_markets()
market = ftx.market(symbol)
btc_maket_price = float(market['info']['price'])
btc_amount = 20 / btc_maket_price
create_order = ftx.create_order(symbol, 'market', 'buy', btc_amount)

type = 'takeProfit'
side = 'sell'
rise_btc_price = btc_maket_price + btc_maket_price * 0.015
params = {
    'stopPrice': rise_btc_price,
}
price = None  # or your takeProfit limit price  # -------- ↓
order = ftx.create_order(symbol, type, side, btc_amount, price, params)

Hope that answers your question.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Take Profit Orders Are & How to Set Them as a Pro Trader
One of the best approaches is to use your risk-reward ratio to set your take profit. For example, if you only risk 5%...
Read more >
Take-Profit Order (TP): Definition, Use in Trading, and Example
A take-profit order (T/P) is a limit order that specifies that price at which to exit a position for a profit.
Read more >
How do I set Stop Loss and Take Profit when placing an order?
Take Profits allow the user to maximize profit by exiting a trade as soon as the market is at a favorable price. What...
Read more >
How to Set Stop-Loss & Take-Profit Targets | eToro
A take-profit order closes your open position for a profit once it reaches a predetermined percentage of profit or monetary value. It removes...
Read more >
What Is a Take-Profit Order? - The Balance
A take-profit order is a standing order put in place by traders to maximize their profits. It specifies a certain price above the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found