Skip to content
Robot de trading
Docs d'OctoBot script
Créer des ordres

Créer des ordres de trading

La traduction française de cette page est en cours.

Orders can be created using the following keywords:

  • market
  • limit
  • stop_loss
  • trailing_market

Montant

Each order accept the following optional arguments:

  • amount: for spot and futures trading
  • target_position: futures trading only: create the associated order to update to position size to the given value. Uses the same format as the order amount.

To specify the amount per order, use the following syntax:

  • 0.1 to trade 0.1 BTC on BTC/USD
  • 2% to trade 2% of the total portfolio value
  • 12%a to trade 12% of the available holdings
# create a buy market order using 10% of the total portfolio
await obs.market(ctx, "buy", amount="10%")

Prix

Orders set their price using the offset argument.

To specify the order price, use the following syntax:

  • 10 to set the price 10 USD above the current BTC/USD market price
  • 2% to set the price 2% USD above the current BTC/USD market price
  • @15555 to set the price at exactly 15555 USD regardless of the current BTC/USD market price
# create a buy limit order of 0.2 units (BTC when trading BTC/USD) 
# with a price at 1% below the current price
await obs.limit(ctx, "buy", amount="0.2", offset="-1%")

Note: market orders do not accept the offset argument.

Take profit et stop losses automatisés

When creating orders, it is possible to automate the associated stop loss and / or take profits. When doing to, the associated take profit/stop loss will have the same amount as the initial order.

Their price can be set according to the same rules as the initial order price (the offset argument) using the following optional argument:

  • stop_loss_offset: automate a stop loss creation when the initial order is filled and set the stop loss price
  • take_profit_offset: automate a take profit creation when the initial order is filled and set the take profit price
# create a buy limit order of 0.2 units (BTC when trading BTC/USD) with: 
# - price at 1% below the current price
# - stop loss at 10% loss
# - take profit at 15% profit
await obs.limit(ctx, "buy", amount="0.2", offset="-1%", stop_loss_offset="-10%", take_profit_offset="15%")

When using both stop_loss_offset and take_profit_offset, two orders will be created after the initial order fill. Those two orders will be grouped together, meaning that if one is cancelled or filled, the other will be cancelled.

Trader des futures

Ouvrir une position

Use regular orders to open a position. When the order is filled, the associated position will be created, updated or closed.

A sell order will open a short position if your balance becomes negative after filling this order.

Clôturer une position

Set the position size to 0 to close it. You can do it either by:

  • Filling an order with the same amount as the position size and an opposite side
  • Or using target_position=0 as order parameters

Changer le levier

Use set_leverage to update the current leverage value when trading futures.

await obs.set_leverage(ctx, 5)