Place Order

About 14 min

place_order Place Order

TradeClient.place_order():

Description

Interface for placing order. This method allows you to set order types, quantity, buy/sell, of you choice, please see below for more information. **Please read the Introduction section of this documentation, as well as FAQ-Trade-Supported Order Types section,to make sure that the order types involved in your program are actually allowed ** If this method returns an error, or that your order gets canceled by the system, it is recommended that you refer to FAQ-Trade section for a quick inspection yourself.

When a order is successfully placed, the id attribute in Order object will be filled (order.id). This id can be used to identify a unique order and thus can be used to modify or cancel an order.

  • Market Order(MKT)and Stop Order(STP)do not support pre-market and post-market transactions. When placing the order, you need to set 'outside_rth' to false

  • For the symbol that can be shorted, the lock-up function is not currently supported, so it is impossible to hold long and short positions of the same symbol at the same time

  • Attached Order currently only supports limit orders

  • Market Order(MKT) and the paper trade account,GTC is not supported for 'time_in_force' parameter

  • The paper trade account currently does not support warrants and CBBC orders

Order Status Explanation

  • How can I determine the partial fulfillment status of my Prime or Paper accounts?

When the order status is not FILLED (may be NEW, CANCELLED, EXPIRED, REJECTED one of them), it may be a partially filled status, which can be judged by whether the number of orders filled is greater than 0.

  • How to determine the partial transaction status of Global Account?

The order status is FILLED, and the order quantity is greater than 0

Order Status Flow

Order Status Flow

Other Information

  • Trading of ETF options that expire on Wednesdays and are based on the underlying assets of the three ETFs, namely 【IWM/SPY/QQQ】, is supported. Other index options that do not expire on Fridays are not supported.
  • Directly opening a reverse position is not allowed. For example, selling 200 shares when holding 100 shares is not permitted. The position must be closed first.

Parameters

Order Object (tigeropen.trade.domain.order.Order)

You can construct an Order Object using the functions defined in tigeropen.common.util.order_utils, such as limit_order() or market_order(). Please see Order Object - Construction for details. Another construction method is to use TradeClient.create_order() to request an order_id to create an order object (deprecated)

ParameterTypeDescriptionMarket Order (Quantity)Market Order (Cash)Limit OrderLimit Order with LegsStop OrderStop Limit OrderTrailing Stop OrderAuction Market OrderAuction Limit OrderAlgorithmic OrderOCA Order
accountstrThe account to which the order belongs
idlongGlobal order ID
order_idintAccount auto-increment order number (deprecated)
parent_idlongParent order ID, currently only used for attached orders in the TigerTrade App
order_timeintOrder time, a 13-digit timestamp in milliseconds
trade_timeintOrder status update time.
Completed orders: completion time
Canceled orders: Successful cancellation time
The timestamp is in milliseconds with 13 digits
update_timeintOrder update time given in milliseconds with 13 digits
expire_timeintGTD (Good Till Date) order expiration time, in milliseconds with a 13-digit timestamp
reasonstrUpon failure, the description of the reason for the failure will be returned
actionstrTrade direction: 'BUY' / 'SELL'
quantityintOrder quantity
quantity_scaleintThe offset of the order quantity, defaulting to 0. For fractional share orders, the combination of quantity and quantity_scale represents the actual order quantity. For example, if quantity=111 and quantity_scale=2, the real quantity would be 111 * 10^(-2) = 1.11
total_cash_amountfloatThe total order amount, which is None when the order is placed by number of shares
filled_cash_amountfloatThe total amount executed, which is None when the order is placed by number of shares
refund_cash_amountfloatThe returned amount, which equals the total order amount minus the executed amount. It is None when the order is placed by number of shares or if the order is not finalized
filledintExecuted Quantity
avg_fill_pricefloatAverage Execution Price Excluding Commission
commissionfloatIncludes commission, stamp duty, securities regulatory fees, and other related charges
gstfloatGoods and Service Tax
realized_pnlfloatRealized profit and loss
trail_stop_pricefloatTrailing stop price
limit_pricefloatLimit order price
aux_pricefloatStop-loss order: price at which the stop-loss order is triggered
Trailing stop order: price difference being tracked.
trailing_percentfloatTrailing stop order - Percentage, with a value range from 0 to 100
percent_offsetfloat<This field is not used>
order_typestrOrder type:
'MKT': Market Order'
LMT': Limit Order
'STP': Stop Order
'STP_LMT': Stop Limit Order
'TRAIL': Trailing Stop Order
time_in_forcestrValidity:
'DAY': Valid for the day
'GTC': Valid untill cancelled
'GTD': Valid until a specified date (requires expire_time)
outside_rthboolSupports pre-market and after-market trading, exclusive to US stocks
trading_session_typestrNight trading
contractContracttigeropen.trade.domain.contract.Contract Contract Object
statusOrderStatustigeropen.common.consts.OrderStatus OrderStatus Enum
remainingintUnfilled quantity
sub_idslist[int]List of sub-order IDs for attached orders (this field will only have a value when attaching an order)
adjust_limitfloatPrice adjustment range (default 0 means no adjustment, positive number means adjust upward, negative number means adjust downward). The price will be automatically adjusted to a valid price. For example, 0.001 means adjusting upward with a range not exceeding 0.1%; -0.001 means adjusting downward with a range not exceeding 0.1%. Default 0 means no adjustment
user_markstrUser-defined remarks
latest_pricefloatMarket price at the time of placing the order
chargestigeropen.trade.domain.order.ChargeOrder commission and other fee details (only available for individual order queries via TradeClient.get_order). See below for specifics
  • Order Leg Parameters
  • Order Leg refers to an order that can have a take-profit or stop-loss effect on the main order through an attached sub-order. Stop loss order (can be used to stop loss). Additional orders can be achieved by adding the following parameters
ParameterTypeDescriptionAdditional Stop LossAdditional Take ProfitLIMIT/STOP/STOP_LIMIT (Only for One-Cancels-All)
leg_typestrAdditional order type: PROFIT - Take Profit order type, LOSS - Stop Loss order type; LMT / STP / STP_LMT are only supported for OCA (One-Cancels-All) orders
pricefloatTrigger price for the additional order
time_in_forcestrValidity period
'DAY': Valid for the current day
'GTC': Good till cancel
'GTD': Good till date
optionaloptionaloptional
outside_rthboolWhether pre-market and after-hours trading are allowed (US stocks only)optionaloptionaloptional
limit_pricefloatLimit order pricenot fillednot filled
trailing_percentfloatTrailing stop loss order-stop loss percentage, when trailing stop loss order, one of the stop loss percentage (stopLossTrailingPercent) and stop loss amount (stopLossTrailingAmount) must be filled in, if both are filled, the stop loss percentage will be used as the parameteroptionalnot fillednot filled
trailing_amountfloatTrailing stop loss order-stop loss amount, when trailing stop loss order, one of stop loss percentage (stopLossTrailingPercent) and stop loss amount (stopLossTrailingAmount) must be filled in, if both are filled, the stop loss percentage will be used as parameteroptionalnot fillednot filled
quantityintOrder quantity

Response

If the order is successfully placed, the function will return True,otherwise it will throw an exception If the order is successfully placed, The 'id' attribute of the Order object will be filled in with the actual order

Build Contract

Contract

from tigeropen.common.util.contract_utils import stock_contract, option_contract, option_contract_by_symbol,
    future_contract, war_contract_by_symbol, iopt_contract_by_symbol

# US stock
contract = stock_contract(symbol='TIGR', currency='USD')

# HK stock
contract = stock_contract(symbol='00700', currency='HKD')

# US option
contract = option_contract(identifier='AAPL  190118P00160000')
contract = option_contract_by_symbol('JD', expiry='20211015', strike=45.0, put_call='PUT', currency='USD')

# Futures
contract = future_contract(symbol='CL', currency='USD', expiry='20190328', multiplier=1.0, exchange='SGX')

# HK warrant
contract = war_contract_by_symbol('01810', '20221116', 14.52, 'CALL', local_symbol='14759', multiplier=2000,
                                  currency='HKD')
# HK CBBC
contract = iopt_contract_by_symbol('02318', '20200420', 87.4, 'CALL', local_symbol='63379', currency='HKD')

Limit Order (LMT)

limit_order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import limit_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate stock contracts
contract = stock_contract(symbol='AAPL', currency='USD')
# generate order object
order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=0.1, quantity=1)

# order
oid = trade_client. place_order(order)

print(order)
# Order({'account': '111111', 'id': 249891111111111111, 'order_id': None, 'parent_id': None, 'order_time': None, 'reason': None, 'trade_time': None , 'action': 'BUY', 'quantity': 1, 'filled': 0, 'avg_fill_price': 0, 'commission': None, 'realized_pnl': None, 'trail_stop_price': None, 'limit_price': 0.1 , 'aux_price': None, 'trailing_percent': None, 'percent_offset': None, 'order_type': 'LMT', 'time_in_force': None, 'outside_rth': None, 'order_legs': None, 'algo_params': None , 'secret_key': None, 'contract': AAPL/STK/USD, 'status': 'NEW', 'remaining': 1})
print(order.status) # order status
print(order.reason) # If the order fails, reason is the reason for the failure

# If the order is placed successfully, order.id is the id of the order, and you can use this id to query the order or cancel the order
my_order = trade_client.get_order(id=order.id)
oid = trade_client.cancel_order(id=order.id)
# Or operate the order object to modify the order
trade_client.modify_order(order, limit_price=190.5)

Market Order (MKT)

market_order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import market_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate stock contracts
contract = stock_contract(symbol='AAPL', currency='USD')
# generate order object
order = market_order(account=client_config.account, contract=contract, action='BUY', quantity=1)

# order
oid = trade_client.place_order(order)

Market Order by Amount(MKT)

market_order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import market_order_by_amount
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate stock contracts
contract = stock_contract(symbol='AAPL', currency='USD')
# generate order object
order = market_order_by_amount(account=client_config.account, contract=contract, action='BUY', amount =100)

# order
oid = trade_client.place_order(order)

Stop Loss Order (STP)

stop_order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import stop_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate stock contracts
contract = stock_contract(symbol='AAPL', currency='USD')
# generate order object
order = stop_order(account=client_config.account, contract=contract, action='SELL', aux_price=1, quantity=1)

# order
oid = trade_client.place_order(order)

Stop Limit Order (STP_LMT)

stop_limit_order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import stop_limit_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate stock contracts
contract = stock_contract(symbol='AAPL', currency='USD')
# generate order object
order = stop_limit_order(account=client_config.account, contract=contract, action='SELL', limit_price=200.0, aux_price=180.0, quantity=1)

# order
oid = trade_client.place_order(order)

Trailing Stop Order (TRAIL)

trail_order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import trail_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate stock contracts
contract = stock_contract(symbol='AAPL', currency='USD')
# generate order object
order = trail_order(account=client_config.account, contract=contract, action='SELL', quantity=1, trailing_percent=8.0, )

# order
oid = trade_client.place_order(order)

Additional Orders

order_leg

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import limit_order, limit_order_with_legs, order_leg, algo_order_params, \
     algo_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

contract = stock_contract(symbol='AAPL', currency='USD')
# Limit order + additional order (additional orders are only supported when the main order is a limit order)
stop_loss_order_leg = order_leg('LOSS', 8.0, time_in_force='GTC',outside_rth=False) # additional stop loss
stop_loss_order_leg1 = order_leg('LOSS', 8.0, limit_price=7.5,outside_rth=False) # additional stop loss limit order
stop_loss_order_leg2 = order_leg('LOSS', 8.0, trailing_percent=0.8,outside_rth=False) # Additional stop loss trailing order (proportional)
stop_loss_order_leg3 = order_leg('LOSS', 8.0, trailing_amount=2.0,outside_rth=False) # Additional stop loss trailing order (by amount)

profit_taker_order_leg = order_leg('PROFIT', 12.0, time_in_force='GTC',outside_rth=False) # additional take profit
main_order = limit_order_with_legs(account=client_config.account, contract=contract, action='BUY', quantity=100, limit_price=10.0,
order_legs=[profit_taker_order_leg, stop_loss_order_leg])
oid = trade_client. place_order(main_order)
# Query the additional orders associated with the main order
order_legs = trade_client.get_open_orders(account=client_config.account, parent_id=main_order.id)
print(order_legs)

OCA order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import order_leg, oca_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

contract = stock_contract(symbol='BILI', currency=Currency.USD)
# stop_loss_order_leg = order_leg('STP', price=8.0)
stop_loss_order_leg = order_leg('STP_LMT', price=8.0, limit_price=7.5,outside_rth=False)
profit_taker_order_leg = order_leg('LMT', limit_price=30.0,outside_rth=False)
my_oca_order = oca_order(client_config.account, contract, 'BUY',
                                   order_legs=[stop_loss_order_leg, profit_taker_order_leg],
                                   quantity=1000)
trade_client.place_order(my_oca_order)

Algorithmic order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import limit_order, limit_order_with_legs, order_leg, algo_order_params, \
     algo_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)
    
# Algorithmic order
contract = stock_contract(symbol='AAPL', currency='USD')
params = algo_order_params(start_time='2022-01-19 23:00:00', end_time='2022-11-19 23:50:00', no_take_liq=True,
                            allow_past_end_time=True, participation_rate=0.1)
order = algo_order(account, contract, 'BUY', 1000, 'VWAP', algo_params=params, limit_price=100.0)
oid = trade_client. place_order(order)

Auction order

auction_limit_order auction limit orderauction_market_order auction market order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import market_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate stock contracts
contract = stock_contract(symbol='01810', currency='HKD')
# Auction limit order, time_in_force is set to OPG means to participate in the pre-market auction, and the intraday time that has not been traded before the market will continue to be placed, and will not participate in the after-hours auction; set to DAY means it is only valid after the market
order = auction_limit_order(account=client_config.account, contract=contract, action='BUY', quantity=200,
                             limit_price='10', time_in_force='OPG')
# Auction market order
# order = auction_market_order(account=client_config.account, contract=contract, action='BUY', quantity=200, time_in_force='OPG')

# order
oid = trade_client. place_order(order)

Overnight/Full-time order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import limit_order
from tigeropen.common.consts import TradingSessionType
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

contract = stock_contract(symbol='AAPL', currency='USD')
order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=120, quantity=1)

# Overnight trading
# order.trading_session_type = TradingSessionType.OVERNIGHT

# Full-time trading
order.trading_session_type = TradingSessionType.FULL

# order
oid = trade_client.place_order(order)

Other examples

Place an order for Hong Kong stocks When placing an order for Hong Kong stocks, the order quantity needs to match the lot size of the stock. For example, the lot size of 00700 is 100, then the order size can only be integer multiples of 100, 200, 500, etc. You can use QuoteClient.get_trade_metas to get the number of shares per lot of a stock in advance.

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.order_utils import limit_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)
quote_client = QuoteClient(client_config)

symbol = '00700'

# Get the number of shares per lot
metas = quote_client. get_trade_metas([symbol])
lot_size = int(metas['lot_size'].iloc[0])

# generate stock contracts
contract = stock_contract(symbol=symbol, currency='HKD')
# generate order object
order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=400.0, quantity=2 * log_size)
# order
oid = trade_client. place_order(order)

Order Futures

from tigeropen.common.util.contract_utils import future_contract
from tigeropen.common.util.order_utils import limit_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate futures contract
contract = future_contract(symbol='CL', currency='USD')
# generate order object
order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=0.1, quantity=1)
# order
oid = trade_client. place_order(order)

Order Options

from tigeropen.common.consts import ComboType
from tigeropen.common.util.contract_utils import option_contract, option_contract_by_symbol
from tigeropen.common.util.order_utils import combo_order, contract_leg, limit_order
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)



# order single option
contract = option_contract(identifier='AAPL  190118P00160000')
# or
contract = option_contract_by_symbol('AAPL', '20200110', strike=280.0, put_call='PUT', currency='USD')

order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=0.1, quantity=1)
oid = trade_client.place_order(order)


# order option combination
contract_leg1 = contract_leg(symbol='TSLA', sec_type='OPT', expiry='20230616', strike=220, put_call='CALL',
                            action='BUY', ratio=1)
contract_leg2 = contract_leg(symbol='TSLA', sec_type='OPT', expiry='20230616', strike=225, put_call='CALL',
                            action='SELL', ratio=1)

order = combo_order(client_config.account, [contract_leg1, contract_leg2], combo_type=ComboType.VERTICAL,
                    action='BUY', quantity=1, order_type='LMT', limit_price=1.0)
res = trade_client.place_order(order)
print(res)

Check the contract and place an order

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# Get stock contracts (not recommended)
contract = trade_client.get_contract('AAPL', sec_type=SecurityType.STK)
# Get the order object (not recommended)
order = trade_client.create_order(account=client_config.account, contract=contract, action='SELL', order_type='LMT', quantity=1, limit_price=200.0)
# order
oid = trade_client. place_order(order)

Set order attributes An example of using unusual attributes of orders. Such as user_mark

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# generate stock contracts
contract = stock_contract(symbol='AAPL', currency='USD')
# generate order object
order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=0.1, quantity=1)
# Modify order custom remarks (Global account needs to contact the platform in advance to enable this function)
order.user_mark = 'my-custom-remark'

# Modify the order validity period to GTC
#order.time_in_force = 'GTC'

# Modify the order to GTD (good till date, valid until the specified date)
#order.time_in_force = 'GTD'
#order.expire_time = 1700496000000 # must specify the expiration time


# order
trade_client. place_order(order)
my_order = trade_client.get_order(id=order.id)
print(my_order. user_mark)

Correction order price Use contract information and PriceUtil to correct the order price. When the contract price is in different gears, there will be different precision. When specifying a price with inappropriate precision as the order price, an error will be returned. Here, the queried contract tick specification data is used to correct the price with tools.

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.common.util.price_util import PriceUtil
from tigeropen.common.consts import SecurityType
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)

# get stock contracts
contract = trade_client.get_contract(symbol='AAPL', sec_type=SecurityType.STK)
limit_price = 150.173

# Check if the price meets the contract's tick specification
is_price_ok = PriceUtil.match_tick_size(price, contract.tick_sizes)

# Correct the price (if the is_up parameter is set to True, the price will be adjusted upwards. Default False, the price will be adjusted downwards)
# If the contract price is 1~1000, the tick specification is 0.01, then 150.173 is adjusted to 150.17; after upward adjustment, it is 150.18
limit_price = PriceUtil.fix_price_by_tick_size(price, contract.tick_sizes)

# generate order object
order = limit_order(account=client_config.account, contract=contract, action='BUY', limit_price=limit_price, quantity=1)

# order
trade_client. place_order(order)

create_order Request to create an order

TradeClient.create_order(account, contract, action, order_type, quantity, limit_price=None, aux_price=None, trail_stop_price=None, trailing_percent=None, percent_offset=None, time_in_force=None, outside_rth=None, order_legs=None, algo_params=None, **kwargs):

Description

Request an order number and create an order object. It is recommended to use the utility functions under tigeropen.common.util.order_utils to create orders locally, such as limit_order, market_order.

Parameters

ParameterTypeDescriptionMarket OrderLimit OrderStop OrderStop Limit OrderTrailing Stop OrderAuction Limit OrderAuction Market Order
accountstrAccount id, If not passed, all associated accounts will be returnedoptionaloptionaloptionaloptionaloptionaloptionaloptional
contractContractContract object
actionstrBusiness direction, 'BUY': buy, 'SELL': sell
order_typestrorder type, 'MKT' market order/ 'LMT' limit order/ 'STP' stop loss order/ 'STP_LMT' stop loss limit order/ 'TRAIL' trailing stop orderMKTLMTSTPSTP_LMTTRAILALAM
quantityintorder quantity, an integer greater than 0
limit_pricefloatlimit order price, required when the order type is LMT or STP_LMT or AL
aux_pricefloatIndicates the stop loss price in the stop loss order; indicates the price difference in the trailing stop loss orderoptionaloptionaloptional
trail_stop_pricefloatTrailing stop order--the price that triggers the stop loss order
trailing_percentfloatTrailing stop loss order--percentage (fill in at least one of trailing stop loss order aux_price and trailing_percent)optional
time_in_forcestrThe validity period of the order can only be DAY (valid on the day) and GTC (valid before cancellation), the default is DAY.(Hong Kong stock auction order Pre-orders need to be set to OPG, after-hours needs to be DAY)optionaloptionaloptionaloptionaloptionaloptionaloptional
outside_rthboolTrue: Allow pre-market and after-hours trading (exclusive to US stocks), False: Not allowed, the default is True. (The market order is only valid in the intraday, and the outside_rth parameter will be ignored)optionaloptionaloptional
order_legsobjectadditional order list, example above the parametersoptionaloptionaloptionaloptionaloptional
algo_paramsobjectAlgo order parameters, refer to the example aboveoptionaloptionaloptionaloptionaloptional

example

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)


contract = stock_contract(symbol='AAPL', currency='USD')
order = openapi_client.create_order(account, contract, 'BUY', 'LMT', 100, limit_price=5.0)

trade_client. place_order(order)


place_forex_order

TradeClient.place_forex_order(seg_type, source_currency, target_currency, source_amount)

Description

Currency exchange order, return Order object

Parameters

ParameterTypeDescription
seg_typeSegmentTypeAccount segment. Available: SegmentType.SEC for Securities; SegmentType.FUT for Commodities, can be imported from tigeropen.common.consts.SegmentType
source_currencyCurrencyCurrency to be converted
target_currencyCurrencyCurrency to be received after conversion
source_amountFloatAmount of source_currency to convert

example

from tigeropen.common.util.contract_utils import stock_contract
from tigeropen.trade.trade_client import TradeClient
from tigeropen.tiger_open_config import get_client_config
client_config = get_client_config(private_key_path='private key path', tiger_id='your tiger id', account='your account')
trade_client = TradeClient(client_config)


order = trade_client.place_forex_order(seg_type='FUT', source_currency='USD', target_currency='HKD',
                                        source_amount=50)
print(order)

Response Example

Order({'account': '11111', 'id': 30323340487950336, 'order_id': 1447, 'parent_id': None, 'order_time': 1680247928000, 'reason': '', 'trade_time': 1680247928000, 'action': 'SELL', 'quantity': 50, 'filled': 0, 'avg_fill_price': 0.0, 'commission': 0.0, 'realized_pnl': 0.0, 'trail_stop_price': None, 'limit_price': 7.74991, 'aux_price': None, 'trailing_percent': None, 'percent_offset': None, 'order_type': 'LMT', 'time_in_force': 'DAY', 'outside_rth': False, 'order_legs': None, 'algo_params': None, 'algo_strategy': 'LMT', 'secret_key': None, 'liquidation': False, 'discount': 0.0, 'attr_desc': None, 'source': 'OpenApi', 'adjust_limit': None, 'sub_ids': None, 'user_mark': '', 'update_time': 1680247928000, 'expire_time': None, 'can_modify': True, 'contract': USD.HKD/FOREX/HKD, 'status': 'NEW', 'remaining': 50})
Last update: