createorder
Create WDS order
Syntax
Description
Examples
Create Order for Security
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)
Create Order for Security Using Credentials
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
c
— WDS connection
connection object
WDS connection, specified as a connection object created with the wind
function.
s
— Security
character vector | string scalar
Security, specified as a character vector or string scalar.
Example: '0001.HK'
Data Types: char
| string
direction
— Trade side
'Buy'
| 'Short'
| 'Cover'
| ...
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 Type | Values |
---|---|
Stocks | 'Buy' or 'Sell' —
Buy or sell stocks |
Futures and options |
|
SHF futures only |
|
SHO options only |
|
Short margin |
|
Funds and split-capital funds |
|
Split-capital funds only |
|
price
— Order price
character vector | string scalar
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
quantity
— Order quantity
character vector | string scalar
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 Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
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.
OrderType
— Order type
'LMT'
| 'B5TC'
| 'B5TL'
Order type, specified as the comma-separated pair consisting of
'OrderType'
and one of these
values.
Value | Description |
---|---|
| Limit |
| Best of counterparty |
| Best of party |
| Immediately then cancel |
| Best 5 then cancel |
| Fill or kill |
| Best 5 then limit |
For details about these values, contact Wind Information Co., Ltd.
HedgeType
— Hedge type
'SPEC'
| 'HEDG'
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.
LogonID
— Login identifier
character vector | string scalar
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
TradePassword
— Account password
character vector | string scalar
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
FundsType
— Fund type
'ETF'
Fund type, specified as the comma-separated pair consisting of
'FundsType'
and 'ETF'
.
For details about this value, contact Wind Information Co., Ltd.
PortfolioNo
— Portfolio number
character vector | string scalar
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
d
— Order information
table
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.
e
— WDS error identifier
numeric scalar
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.
Version History
Introduced in R2018a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)