createorder

Create WDS order

Syntax

d = createorder(c,s,direction,price,quantity)
d = createorder(c,s,direction,price,quantity,Name,Value)
[d,e] = createorder(___)

Description

example

d = createorder(c,s,direction,price,quantity) returns order information after sending an order to the Wind Data Feed Services (WDS) order management system using the WDS connection. Specify the security, trade side, order price, and quantity of shares for the order.

example

d = createorder(c,s,direction,price,quantity,Name,Value) specifies additional options using one or more name-value pair arguments. For example, 'TradePassword',"abcdefghi" specifies the password for the WDS order management system.

[d,e] = createorder(___) also returns the WDS error identifier using any of the input argument combinations in the previous syntaxes. For troubleshooting, contact Wind Information Co., Ltd.

Examples

collapse all

Using a WDS connection, log in to the order management system and create a buy order of a single security.

Create a WDS connection.

c = wind;

Log in to the WDS order management system using the WDS connection. Specify the broker, branch, user name, password, and account type.

broker = "0000";
branch = "0";
capitalaccount = "1234567891011";
password = "abcdefghi";
accttype = "SHSZ";
dlogin = tradelogin(c,broker,branch, ...
    capitalaccount,password,accttype);

Create a buy order of 100 shares of the 600000.SH security using the WDS connection. Buy shares with the order price 12.0, specified in the CNY currency.

s = '600000.SH';
direction = 'buy';
price = '12.0';
quantity = '100';
d = createorder(c,s,direction,price,quantity)
d =

  1×8 table

    RequestID    SecurityCode    TradeSide    OrderPrice    OrderVolume    LogonID    ErrorCode      ErrorMsg   
    _________    ____________    _________    __________    ___________    _______    _________    _____________

       20        '600000.sh'       'BUY'        '12.0'         '100'         '1'          0        'Sending ...'

d is a table with these variables:

  • Request identifier

  • Security code

  • Trade side

  • Order price

  • Order volume

  • Login identifier

  • Error code

  • Error message

Query for the order status of the executed order and display the status. The order status 'Normal' indicates a successful order execution.

d = query(c,'Order');
d.OrderStatus
d =

  'Normal'

This result assumes that the WDS order management system contains only one valid order execution.

Log out from the WDS order management system using the login identifier returned by the tradelogin function.

logonid = dlogin.LogonID;
d = tradelogout(c,logonid);

Close the WDS connection.

close(c)

Using a WDS connection, log in to the order management system and create a buy order of a single security. Use name-value pair arguments to specify the login identifier and password.

Create a WDS connection.

c = wind;

Log in to the WDS order management system using the WDS connection. Specify the broker, branch, user name, password, and account type.

broker = "0000";
branch = "0";
capitalaccount = "1234567891011";
password = "abcdefghi";
accttype = "SHSZ";
dlogin = tradelogin(c,broker,branch, ...
    capitalaccount,password,accttype);

Create a buy order of 100 shares of the 600000.SH security using the WDS connection. Buy shares with the order price 12.0, specified in the CNY currency. Use the 'LogonID' and 'TradePassword' name-value pair arguments to specify the login identifier and password.

s = '600000.SH';
direction = 'buy';
price = '12.0';
quantity = '100';
logonid = '1';
password = "abcdefghi";
d = createorder(c,s,direction,price,quantity, ...
    'LogonID',logonid,'TradePassword',password)
d =

  1×8 table

    RequestID    SecurityCode    TradeSide    OrderPrice    OrderVolume    LogonID    ErrorCode      ErrorMsg   
    _________    ____________    _________    __________    ___________    _______    _________    _____________

       20        '600000.sh'       'BUY'        '12.0'         '100'         '1'          0        'Sending ...'

d is a table with these variables:

  • Request identifier

  • Security code

  • Trade side

  • Order price

  • Order volume

  • Login identifier

  • Error code

  • Error message

Query for the order status of the executed order and display the status. The order status 'Normal' indicates a successful order execution.

d = query(c,'Order');
d.OrderStatus

This result assumes that the WDS order management system contains only one valid order execution.

d =

  'Normal'

Log out from the WDS order management system using the login identifier returned by the tradelogin function.

logonid = dlogin.LogonID;
d = tradelogout(c,logonid);

Close the WDS connection.

close(c)

Input Arguments

collapse all

WDS connection, specified as a connection object created with the wind function.

Security, specified as a character vector or string scalar.

Example: '0001.HK'

Data Types: char | string

Trade side of the order, specified as one of these values:

  • 'Buy'

  • 'BuyCollateral'

  • 'Cover'

  • 'CoverCovered'

  • 'CoverToday'

  • 'Merge'

  • 'Redemption'

  • 'Sell'

  • 'SellCollateral'

  • 'SellToday'

  • 'Short'

  • 'ShortCovered'

  • 'Split'

  • 'Subscription'

The values for the direction input argument depend on the instrument type.

Instrument TypeValues
Stocks'Buy' or 'Sell' — Buy or sell stocks
Futures and options
  • 'Buy' — Buy long

  • 'Sell' — Sell long

  • 'Short' — Buy short

  • 'Cover' — Sell short

SHF futures only
  • 'Buy' — Buy long

  • 'Sell' — Sell long position yesterday or before

  • 'SellToday' — Sell long position today

  • 'Short' — Buy short

  • 'Cover' — Sell short position yesterday or before

  • 'CoverToday' — Sell short position today

SHO options only
  • 'Buy' — Buy long

  • 'Sell' — Sell long

  • 'Short' — Buy short

  • 'ShortCovered' — Buy short with frozen underlying stock (not frozen margin)

  • 'Cover' — Sell short

  • 'CoverCovered' — Sell short covered

Short margin
  • 'Buy' — Margin purchase

  • 'Sell' — Repayment

  • 'Short' — Short sale

  • 'Cover' — Return stock

  • 'BuyCollateral' — Buy collateral

  • 'SellCollateral' — Sell collateral

Funds and split-capital funds
  • 'Buy' — Buy fund in floor trading

  • 'Sell' — Sell fund in floor trading

  • 'Subscription' — Buy fund in OTC

  • 'Redemption' — Sell fund in OTC

Split-capital funds only
  • 'Merge' — SCT merge to Fund of Funds

  • 'Split' — Fund of Funds split to SCT

Order price, specified as a character vector or string scalar. Specify the price of the order in the CNY currency.

Example: '12.0'

Data Types: char | string

Order quantity, specified as a character vector or string scalar. Specify the number of shares for the order transaction.

Example: '100'

Data Types: char | string

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: d = createorder(c,'600000.SH','buy','12.0','100','OrderType','LMT') returns order information after sending a limit order of the 600000.SH security to the WDS order management system. This order buys 100 shares of the security with an order price of 12, specified in CNY currency.

Order type, specified as the comma-separated pair consisting of 'OrderType' and one of these values.

ValueDescription

'LMT'

Limit

'BOC'

Best of counterparty

'BOP'

Best of party

'ITC'

Immediately then cancel

'B5TC'

Best 5 then cancel

'FOK'

Fill or kill

'B5TL'

Best 5 then limit

For details about these values, contact Wind Information Co., Ltd.

Hedge type, specified as the comma-separated pair consisting of 'HedgeType' and 'SPEC' for speculation or 'HEDG' for hedging (when trading futures).

For details about these values, contact Wind Information Co., Ltd.

Login identifier, specified as the comma-separated pair consisting of 'LogonID' and a character vector or string scalar. Set the value of the 'LogonID' name-value pair argument by using the LogonID variable in the d output argument of the tradelogin function.

Example: '1'

Data Types: char | string

Account password, specified as the comma-separated pair consisting of 'TradePassword' and a character vector or string scalar. For credentials, contact Wind Information Co., Ltd.

Example: "abcdefghi"

Data Types: char | string

Fund type, specified as the comma-separated pair consisting of 'FundsType' and 'ETF'.

For details about this value, contact Wind Information Co., Ltd.

Portfolio number, specified as the comma-separated pair consisting of 'PortfolioNo' and a character vector or string scalar.

Example: '3'

Data Types: char | string

Output Arguments

collapse all

Order information, returned as a table. The variables in the table depend on the specified order.

For details about the variables in the table, contact Wind Information Co., Ltd.

WDS error identifier, returned as a numeric scalar. The value 0 indicates a successful execution of the createorder function. Otherwise, for details about the error, contact Wind Information Co., Ltd.

Introduced in R2018a