Main Content

Create Order Using Real-Time Snapshot WDS Data

This example shows how to connect toWind Data Feed Services (WDS), retrieve real-time snapshot data, and perform simple data analysis to make an investment decision. The example then shows how to log in to the WDS order management system, create an order, and query information about the order. This example requires that you open and log in to the Wind Financial Terminal.

Connect to WDS

c =风;

Retrieve Snapshot Data

Format output data for currency.

formatbank

Using the600000.SHsecurity and the WDS connection, retrieve real-time snapshot data for the last price and volume fields.

s ='600000.SH'; f = {'rt_last','rt_vol'}; d = realtime(c,s,f)
d = 1×3 timetable Time Codes RT_LAST RT_VOL ____________________ ___________ _______ ____________ 05-Dec-2017 12:33:50 '600000.SH' 13.17 123796797.00

dis a timetable that contains a row for the security with the time and these variables:

  • Security

  • Last price

  • Volume

Analyze Snapshot Price

Assume a price threshold of 12, specified in the CNY currency. Compare the snapshot price to the threshold. The sell indicator contains the logical value1.

sellnow = (d.RT_LAST > 12);

Set the direction of the order by using the sell indicator.

if(sellnow) direction ='Sell';elsedirection ='Buy';end

Create WDS Order

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、密码accttype);

Create a sell order of 100 shares of the600000.SHsecurity using the WDS connection. Sell shares with the order price13.17, specified in the CNY currency. Use the'LogonID'name-value pair argument to specify the login identifier. Use the'TradePassword'name-value pair argument to specify the password.

price ='13.17'; 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' 'SELL' '13.17' '100' '1' 0 'Sending ...'

dis a table with these variables:

  • Request identifier

  • Security code

  • Direction

  • Order price

  • Order volume

  • Login identifier

  • Error code

  • Error message

Query for the status of the executed order and display the status. The order status'Normal'印度语的ates successful order execution.

d = query(c,“秩序”); d.OrderStatus
d = 'Normal'

Close WDS Connection

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

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

Close the WDS connection.

close(c)

See Also

||||||

相关的顶部ics

External Websites