Place Order
place_oder Place Order
TradeClient.place_order():
Description
Interface for placing order. This method alllows 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 sucessfully 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
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.
Argument
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)
Parameter | Type | Description | Market Order | Limit Order | Stop Order | Stop Limit Order | Trailing Stop Order |
---|---|---|---|---|---|---|---|
account | str | User authorization account: 402901 | |||||
order_id | int | The order number, which is used to prevent repeated orders. It can be obtained through the order number interface. If you pass 0, the server will automatically generate an order number. When you pass 0, you cannot prevent repeated orders. Please choose carefully | optional | optional | optional | optional | optional |
symbol | str | Stock code such as: AAPL; (when sec_typ is warrant CBBC, the 5 digits below the name in the app warrant/CBBC list) | |||||
sec_type | str | contract type (STK stock OPT US stock option WAR Hong Kong stock warrant IOPT Hong Kong stock CBBC FUT futures) | |||||
action | str | trading direction BUY/SELL | |||||
order_type | str | order type. MKT (market order), LMT (limit order), STP (stop loss order), STP_LMT (stop loss limit order), TRAIL (trailing stop loss order) | MKT | LMT | STP | STP_LMT | TRAIL |
quantity | int | Order quantity (Hong Kong stocks, Shanghai-Hong Kong Stock Connect, warrants, CBBCs have a minimum quantity limit) | |||||
quantity_scale | int | The offset of the order quantity, default is 0. The combination of 'totalQuantity' and 'totalQuantityScale' of odd lot orders represents the actual order quantity. For example, totalQuantity=111 totalQuantityScale=2, then the real quantity=111*10^(-2)=1.11 | |||||
limit_price | float | limit price, this parameter is required when order_type is LMT, STP_LMT | |||||
aux_price | float | Stock order stop loss trigger price. The meaning is the price difference, and it is covered by trailing_percent when it exists with trailing_percent. When the order_type is STP, STP_LMT, this parameter is required; when the order_type is TRAIL, it is the tracking amount | optional | ||||
trailing_percent | float | Trailing stop order - stop loss percentage. When the order_type is TRAIL, aux_price and trailing_percent are mutually exclusive, and trailing_percent is used preferentially | optional | ||||
outside_rth | boolean | true: Allow pre-market and after-hours trading (exclusive to US stocks), false: Not allowed, the default is allowed. (Market order, stop loss order, and trailing stop order are only valid in the intraday, and the outside_rth parameter will be ignored) | optional | optional | optional | ||
adjust_limit | float | Price fine-tuning range (default is 0 means no adjustment, positive number means upward adjustment, negative number means downward adjustment), and the incoming price is automatically adjusted to the legal price. For example: 0.001 is an upward adjustment of up to 0.1%; -0.001 is a downward adjustment of up to 0.1%. Default 0 means no adjustment | optional | optional | optional | optional | |
market | str | market (US stocks US Hong Kong stocks HK Shanghai-Hong Kong Stock Connect CN) | optional | optional | optional | optional | optional |
currency | str | currency (US stocks USD Hong Kong stocks HKD Shanghai-Hong Kong Stock Connect CNH) | optional | optional | optional | optional | optional |
time_in_force | str | The validity period of the order can only be DAY (valid on the current day), GTC (valid before cancellation, the longest valid time is 180 days), GTD (valid before the specified time), the default is DAY | optional | optional | optional | optional | optional |
expire_time | long | The valid deadline of the order,13-bit timestamp, accurate to the second (required when time_in_force is GTD, invalid for other types) | optional | optional | optional | ||
exchange | str | Exchange (US Stocks SMART Hong Kong Stocks SEHK Shanghai-Hong Kong Stock Connect SEHKNTL Shenzhen-Hong Kong Stock Connect SEHKSZSE) No | optional | optional | optional | optional | optional |
expiry | str | expiry date (option, warrant, CBBC exclusive) | optional | optional | optional | optional | optional |
strike | str | underlying price (option, warrant, CBBC exclusive) | optional | optional | optional | optional | optional |
right | str | option direction PUT/CALL (option, warrant, CBBC exclusive) | optional | optional | optional | optional | optional |
multiplier | float | 1 lot unit (option, warrant, CBBC exclusive) | optional | optional | optional | optional | optional |
local_symbol | str | Warrant CBBC This field is required, the 5 digits below the name in the app warrant/CBBC list | optional | optional | optional | optional | optional |
secret_key | str | Dedicated to institutional users, trader key | optional | optional | optional | optional | optional |
user_mark | str | order note information, cannot be modified after order is placed, userMark information will be returned when querying an order | optional | optional | optional | optional | optional |
- attached order parameter
- Attached Order (Attached Order) 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
Parameter | Type | Description | Additional Stop Loss | Additional Take Profit | Additional Trailing Stop | Additional Parentheses |
---|---|---|---|---|---|---|
attach_type | str | Attachment order type, required when attaching an order. (order_type should be LMT): PROFIT-take-profit order, LOSS-stop-loss order, BRACKETS-bracket order (including take-profit order and stop-loss order, the comprehensive account does not support additional bracket orders at the moment, that is, it does not support the addition of stop loss and stop loss orders at the same time Take profit order) | ||||
profit_taker_order_id | int | Take profit order ID, which can be obtained through the order ID interface. If 0 is passed, the server will automatically generate a take profit order number | optional | optional | optional | |
profit_taker_price | float | Take profit order price, required when placing a take profit order | ||||
profit_taker_tif | str | Same as the time_in_force field, the order validity period can only be DAY (valid on the day) and GTC (valid before cancellation), required when placing a take profit order | ||||
profit_taker_rth | boolean | Same as outside_rth field | ||||
stop_loss_order_id | int | Stop loss order ID, which can be obtained through the order ID interface. If 0 is passed, the server will automatically generate a stop loss order number | ||||
stop_loss_price | float | Stop loss order price (stop loss order trigger price), required when placing a stop loss order | ||||
stop_loss_limit_price | float | Execution limit price of stop loss order (only valid for integrated account temporarily). If the limit price of the stop loss order is not filled in, it is an additional stop loss market order; when filled in, it is an additional stop loss limit order. When the main order transaction direction is BUY, it needs to meet stop_loss_price > stop_loss_limit_price, otherwise the main order transaction direction is SELL. stop_loss_price < stop_loss_limit_price | optional | optional | ||
stop_loss_tif | str | Same as the time_in_force field, the order validity period can only be DAY (valid on the day) and GTC (valid before cancellation), required when placing a stop loss order | ||||
stop_loss_trailing_percent | float | Trailing 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 parameter. | optional | optional | ||
stop_loss_trailing_amount | float | Trailing 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 parameter. | optional | optional |
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 acutal order
Build 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)
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)
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)
Stop Loss Order (STP)
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)
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)
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
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)
# 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') # additional stop loss
stop_loss_order_leg1 = order_leg('LOSS', 8.0, limit_price=7.5) # additional stop loss limit order
stop_loss_order_leg2 = order_leg('LOSS', 8.0, trailing_percent=0.8) # Additional stop loss trailing order (proportional)
stop_loss_order_leg3 = order_leg('LOSS', 8.0, trailing_amount=2.0) # Additional stop loss trailing order (by amount)
profit_taker_order_leg = order_leg('PROFIT', 12.0, time_in_force='GTC') # additional take profit
main_order = limit_order_with_legs(account, contract, 'BUY', 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, 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)
profit_taker_order_leg = order_leg('LMT', limit_price=30.0)
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)
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():
illustrate
Request an order number and create an order object. It is not recommended to use, 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
parameter | type | description | market order | limit order | stop order | stop limit order | trailing stop order | auction limit order | auction market order |
---|---|---|---|---|---|---|---|---|---|
account | str | Account id, If not passed, all associated accounts will be returned | optional | optional | optional | optional | optional | optional | optional |
contract | Contract | Contract object | |||||||
action | str | Business direction, 'BUY': buy, 'SELL': sell | |||||||
order_type | str | order type, 'MKT' market order/ 'LMT' limit order/ 'STP' stop loss order/ 'STP_LMT' stop loss limit order/ 'TRAIL' trailing stop order | MKT | LMT | STP | STP_LMT | TRAIL | AL | AM |
quantity | int | order quantity, an integer greater than 0 | |||||||
limit_price | float | limit order price, required when the order type is LMT or STP_LMT or AL | |||||||
aux_price | float | Indicates the stop loss price in the stop loss order; indicates the price difference in the trailing stop loss order | optional | optional | optional | ||||
trail_stop_price | float | Trailing stop order--the price that triggers the stop loss order | |||||||
trailing_percent | float | Trailing stop loss order--percentage (fill in at least one of trailing stop loss order aux_price and trailing_percent) | optional | ||||||
adjust_limit | float | Price fine-tuning range (default is 0 means no adjustment, positive number means upward adjustment, negative number means downward adjustment), and the incoming price is automatically adjusted to the legal price. For example: 0.001 is an upward adjustment of up to 0.1%; -0.001 is a downward adjustment of up to 0.1%. Default 0 means no adjustment | optional | optional | optional | optional | |||
time_in_force | str | The 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) | optional | optional | optional | optional | optional | optional | optional |
outside_rth | bool | True: 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) | optional | optional | optional | ||||
order_legs | object | additional order list, example above the parameters | optional | optional | optional | optional | optional | ||
algo_params | object | Algo order parameters, refer to the example above | optional | optional | optional | optional | optional | ||
secret_key | str | Institutional users only, trader key | optional | optional | optional | optional | optional | optional | optional |
user_mark | str | Remark information for order, cannot be modified after order is placed, userMark information will be returned when querying the order (global account needs to configure developer personal information) | optional | optional | optional | optional | optional | optional | optional |
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
illustrate
Currency exchange order, return Order object
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)