# Trading Definitions
# Account Risk Control Level
CltRiskLevel
NONEUnknown
SAFESafe
WARNINGWarning
DANGERDanger
ABSOLUTE_SAFEAbsolutely safe
OPT_DANGERDanger
Tips
- It is recommanded to use risk_status field to get risk status of futures account, see CltRiskStatus
# Currency Type
Currency
NONEUnknown currency
HKDHK dollar
USDUS dollar
CNHOffshore RMB
JPYJapanese Yen
SGDSG dollar
AUDAustralian dollar
CADCanadian dollar
MYRMalaysian Ringgit
# TrailType
TrailType
NONEUnknown
RATIOTrailing ratio
AMOUNTTrailing amount
# Modify Order Operation
ModifyOrderOp
NONEUnknown operation
NORMALModify order
CANCELCancel
DISABLEDisable
ENABLEEnable
DELETEDelete
# Transaction Status
DealStatus
OKTransaction success
CANCELLEDTransaction cancelled
CHANGEDTransaction changed
# Order Status
OrderStatus
NONEUnknown status
WAITING_SUBMITQueued
SUBMITTINGSubmitting
SUBMITTEDWorking
FILLED_PARTPartially filled
FILLED_ALLFully filled
CANCELLED_PARTPartially cancelled
CANCELLED_ALLFully cancelled
FAILEDFailed. Rejected by server.
DISABLEDDeactivated
DELETEDDeleted, only unfilled orders can be deleted
# Order Type
Tips
- Order types supported in live trading.
- Paper trade only supports limit orders (NORMAL) and market orders (MARKET).
OrderType
NONEUnknown type.
NORMALLimit orders.
MARKETMarket orders.
ABSOLUTE_LIMITAbsolute limit orders.
AUCTIONAt-auction market orders.
AUCTION_LIMITAt-auction limit orders.
SPECIAL_LIMITSpecial limit orders.
SPECIAL_LIMIT_ALLAON special limit orders.
STOPStop orders.
STOP_LIMITStop Limit orders.
MARKET_IF_TOUCHEDMarket if Touched orders.
LIMIT_IF_TOUCHEDLimit if Touched orders.
TRAILING_STOPTrailing Stop orders.
TRAILING_STOP_LIMITTrailing Stop Limit orders.
TWAP_LIMITTime Weighted Average Price Limit orders (HK and US securities only).
TWAPTime Weighted Average Price Market orders (US securities only).
VWAP_LIMITVolume Weighted Average Price Limit orders (HK and US securities only).
VWAPVolume Weighted Average Price Market orders (US securities only).
# Position Direction
PositionSide
NONEUnknown position
LONGLong position, by default
SHORTShort position
# Account Type
TrdAccType
NONEUnknown type
CASHCash account
MARGINMargin Account
# Trading Environment
TrdEnv
SIMULATESimulated environment
REALReal environment
# Transaction Market
TrdMarket
NONEUnknown market
HKHong Kong market
USUS market
CNA-share market
HKCCHKCC market
FUTURESFutures market
FUTURES_SIMULATE_USUS futures simulated market
FUTURES_SIMULATE_HKHong Kong futures simulated market
FUTURES_SIMULATE_SGSingapore futures simulated market
FUTURES_SIMULATE_JPJapan futures simulated market
HKFUNDHK fund market
USFUNDUS fund market
SGSG market
JPJP market
AUAU market
MYMY market
CACA market
# Account Status
TrdAccStatus
ACTIVEActive account
DISABLEDDisabled account
# Transaction Securities Market
# Transaction Direction
TrdSide
NONEUnknown direction
BUYBuy
SELLSell
SELL_SHORTSell short
BUY_BACKBuy back
Tips
It is recommanded that only use Buy or Sell as the input parameter of direction of place_order interface.
BuyBack and SellShort is only used as the display field for Get Order List , Get History Order List, Orders Push Callback, Get Today's Deals, Get Historical Deals and Deals Push Callback interface.
# Order Validity Period
TimeInForce
DAYGood for the day
GTCGood until cancel
# Securities Firm to Which the Account Belongs
SecurityFirm
NONEUnknown
FUTUSECURITIESFUTU HK
FUTUINCMoomoo US
FUTUSGMoomoo SG
FUTUAUMoomoo AU
# Simulate Account Type
SimAccType
NONEUnknown
STOCKStock simulation account
OPTIONOption simulation account
FUTURESFutures simulation account
# Account Risk Control Status
CltRiskStatus
NONEUnknown
LEVEL1Very Safe
LEVEL2Safe
LEVEL3Safe
LEVEL4Low Risk
LEVEL5Medium Risk
LEVEL6High Risk
LEVEL7Warning
LEVEL8Margin Call
LEVEL9Margin Call
# Day-trading Status
DtStatus
NONEUnknown
UnlimitedUnlimited
EM_CallEM-Call
DT_CallDT-Call
# Cash Flow Direction
CashFlowDirection
NONEUnknown
INCash Inflow
OUTCash Outflow
# Transaction Category
TrdCategory
enum TrdCategory
{
TrdCategory_Unknown = 0; //Unknown
TrdCategory_Security = 1; //Securities
TrdCategory_Future = 2; //Futures
}
2
3
4
5
6
# Account Cash Information
AccCashInfo
message AccCashInfo
{
optional int32 currency = 1; //Currency type, refer to Currency
optional double cash = 2; //Cash balance
optional double availableBalance = 3; //Available cash withdrawal amount
optional double netCashPower = 4; // Net cash power
}
2
3
4
5
6
7
# Account Assets Information by Market
AccMarketInfo
message AccCashInfo
{
optional int32 trdMarket = 1; // Trading market, refer to TrdMarket
optional double assets = 2; // Account assets information by market
}
2
3
4
5
# Transaction Protocol Public Header
TrdHeader
message TrdHeader
{
required int32 trdEnv = 1; //Trading environment, refer to the enumeration definition of TrdEnv
required uint64 accID = 2; //Trading account, trading account should match to trading environment and market permissions, otherwise an error will be returned
required int32 trdMarket = 3; //Trading market, refer to the enumeration definition of TrdMarket
}
2
3
4
5
6
# Trading Account
TrdAcc
message TrdAcc
{
required int32 trdEnv = 1; //Trading environment, refer to the enumeration definition of TrdEnv
required uint64 accID = 2; //Trading account
repeated int32 trdMarketAuthList = 3; //The trading market permissions supported by the trading account, can have multiple trading market permissions, currently only a single, refer to the enumeration definition of TrdMarket
optional int32 accType = 4; //Account type, refer to TrdAccType
optional string cardNum = 5; //card number
optional int32 securityFirm = 6; //security firm,refer to SecurityFirm
optional int32 simAccType = 7; //simulate account type, see SimAccType
optional string uniCardNum = 8; //Universal account number
optional int32 accStatus = 9; //Account status,refer to TrdAccStatus
}
2
3
4
5
6
7
8
9
10
11
12
# Account Funds
Funds
message Funds
{
required double power = 1; //Maximum Buying Power (Minimum OpenD version requirements: 5.0.1310. This field is the approximate value calculated according to the marginable initial margin of 50%. But in fact, this ratio of each financial contract is not the same. We recommend using Buy on Margin, returned by Query the Maximum Quantity that Can be Bought or Sold, to get the maximum quantity can buy.)
required double totalAssets = 2; //Net Assets
required double cash = 3; //Cash (Only Single market accounts use this field. If your account is an universial account, please use cashInfoList to get cash for each currency.)
required double marketVal = 4; //Securities Market Value (only applicable to securities accounts)
required double frozenCash = 5; //Funds on Hold
required double debtCash = 6; //Interest Charged Amount (Minimum OpenD version requirements: 5.0.1310)
required double avlWithdrawalCash = 7; //Withdrawable Cash (Only Single market accounts use this field. If your account is an universial account, please use cashInfoList to get withdrawalbe cash for each currency.)
optional int32 currency = 8; //The currency used for this query (only applicable to universal securities accounts and futures accounts). See Currency
optional double availableFunds = 9; //Available funds (only applicable to futures accounts)
optional double unrealizedPL = 10; //Unrealized gain or loss (only applicable to futures accounts)
optional double realizedPL = 11; //Realized gain or loss (only applicable to futures accounts)
optional int32 riskLevel = 12; //Risk control level (only applicable to futures accounts), See CltRiskLevel. It is recommanded to use riskStatus field to get the risk status of securities accounts or futures accounts.
optional double initialMargin = 13; //Initial Margin (only applicable to futures accounts, minimum OpenD version requirements: 5.0.1310)
optional double maintenanceMargin = 14; //Maintenance Margin (Minimum OpenD version requirements: 5.0.1310)
repeated AccCashInfo cashInfoList = 15; //Cash information by currency (only applicable to futures accounts)
optional double maxPowerShort = 16; //Short Buying Power (Minimum OpenD version requirements: 5.0.1310. This field is the approximate value calculated according to the shortable initial margin of 60%. But in fact, this ratio of each financial contract is not the same. We recommend using the Short sell field, returned by the API of Query the Maximum Quantity that Can be Bought or Sold, to get the maximum quantity can be shorted.)
optional double netCashPower = 17; //Cash Buying Power (Only Single market accounts use this field. If your account is an universial account, please use cashInfoList to get cash buying power for each currency.)
optional double longMv = 18; //Long Market Value (Minimum OpenD version requirements: 5.0.1310)
optional double shortMv = 19; //Short Market Value (Minimum OpenD version requirements: 5.0.1310)
optional double pendingAsset = 20; //Asset in Transit (Minimum OpenD version requirements: 5.0.1310)
optional double maxWithdrawal = 21; //Maximum Withdrawal (only applicable to securities accounts, minimum OpenD version requirements: 5.0.1310)
optional int32 riskStatus = 22; //Risk status (only applicable to securities accounts, minimum OpenD version requirements: 5.0.1310), divided into 9 grades, LEVEL1 is the safest and LEVEL9 is the most dangerous. See CltRiskStatus
optional double marginCallMargin = 23; //Margin-call Margin (Minimum OpenD version requirements: 5.0.1310)
optional bool isPdt = 24; //Is it marked as a PDT. True: It is a PDT. False: Not a PDT. Only applicable to securities accounts of moomoo US. Minimum OpenD version requirements: 5.8.2008.
optional string pdtSeq = 25; //Day Trades Left. Only applicable to securities accounts of moomoo US. Minimum OpenD version requirements: 5.8.2008.
optional double beginningDTBP = 26; //Beginning DTBP. Only applicable to securities accounts of moomoo US marked as a PDT. Minimum OpenD version requirements: 5.8.2008.
optional double remainingDTBP = 27; //Remaining DTBP. Only applicable to securities accounts of moomoo US marked as a PDT. Minimum OpenD version requirements: 5.8.2008.
optional double dtCallAmount = 28; //Day-trading Call Amount. Only applicable to securities accounts of moomoo US marked as a PDT. Minimum OpenD version requirements: 5.8.2008.
optional int32 dtStatus = 29; //Day-trading Status. Only applicable to securities accounts of moomoo US marked as a PDT. Minimum OpenD version requirements: 5.8.2008.
optional double securitiesAssets = 30; // Net asset value of securities
optional double fundAssets = 31; // Net asset value of fund
optional double bondAssets = 32; // Net asset value of bond
repeated AccMarketInfo marketInfoList = 33; //Account assets information by market
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Account Holding
Position
message Position
{
required uint64 positionID = 1; //Position ID, a unique identifier of a position
required int32 positionSide = 2; //Position direction, refer to the enumeration definition of PositionSide
required string code = 3; //Code
required string name = 4; //Name
required double qty = 5; //Holding quantity, 2 decimal places, the same below
required double canSellQty = 6; //Available quantity. Available quantity = Holding quantity - Frozen quantity. The unit of options and futures is "contract".
required double price = 7; //Market price, 3 decimal places, 2 decimal places for futures
optional double costPrice = 8; //Diluted Cost (for securities account). Average opening price (for futures account). No precision limit for securities. 2 decimal places for futures. If not passed, it means this value is invalid at this time.
required double val = 9; //Market value, 3 decimal places, value of this field for futures is 0
required double plVal = 10; //Amount of profit or loss, 3 decimal places, 2 decimal places for futures
optional double plRatio = 11; //Percentage of profit or loss(under diluted cost price mode), no precision limit, if not passed, it means this value is invalid at this time
optional int32 secMarket = 12; //The market to which the securities belong, refer to enumeration definition of TrdSecMarket
//The following is the statistics of this position today
optional double td_plVal = 21; //Today's profit or loss, 3 decimal places, the same below, 2 decimal places for futures
optional double td_trdVal = 22; //Today's trading volume, not applicable for futures
optional double td_buyVal = 23; //Total value bought today, not applicable for futures
optional double td_buyQty = 24; //Total amount bought today, not applicable for futures
optional double td_sellVal = 25; //Total value sold today, not applicable for futures
optional double td_sellQty = 26; //Total amount sold today, not applicable for futures
optional double unrealizedPL = 28; //Unrealized profit or loss (only applicable to futures accounts)
optional double realizedPL = 29; //Realized profit or loss (only applicable to futures accounts)
optional int32 currency = 30; // Currency type, refer to Currency
optional int32 trdMarket = 31; //Trading market, refer to the enumeration definition of TrdMarket
optional double dilutedCostPrice = 32; //diluted cost price,applicable for securities accounts only
optional double averageCostPrice = 33; //average cost price,not applicable for securities papper trading accounts
optional double averagePlRatio = 34; //Percentage of profit or loss(under average cost price mode), no precision limit, if not passed, it means this value is invalid at this time
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Order
Order
message Order
{
required int32 trdSide = 1; //Trading direction, refer to TrdSide enumeration definition
required int32 orderType = 2; //Order type, refer to enumeration definition of OrderType
required int32 orderStatus = 3; //Order status, refer to enumeration definition of OrderStatus
required uint64 orderID = 4; //Order number
required string orderIDEx = 5; //Extended order number (only for checking the problem)
required string code = 6; //code
required string name = 7; //Name
required double qty = 8; //Order quantity, 3 decimal places, option unit is "Zhang"
optional double price = 9; //Order price, 3 decimal places
required string createTime = 10; //Create time, strictly in accordance with YYYY-MM-DD HH:MM:SS or YYYY-MM-DD HH:MM:SS.MS format
required string updateTime = 11; //The last update time, strictly according to YYYY-MM-DD HH:MM:SS or YYYY-MM-DD HH:MM:SS.MS format
optional double fillQty = 12; //Filled quantity, 2 decimal place accuracy, the option unit is "contract"
optional double fillAvgPrice = 13; //Average price of the fill, no precision limit
optional string lastErrMsg = 14; //The last error description, if there is an error, there will be this description of the reason for the last error, no error is empty
optional int32 secMarket = 15; //The market to which the securities belong, refer to enumeration definition of TrdSecMarket
optional double createTimestamp = 16; //Timestamp for creation
optional double updateTimestamp = 17; //Timestamp for last update
optional string remark = 18; //User remark string, the maximum length is 64 bytes
optional double auxPrice = 21; //Trigger price
optional int32 trailType = 22; //Trailing type, see Trd_Common.TrailType enumeration definition
optional double trailValue = 23; //Trailing amount / ratio
optional double trailSpread = 24; //Specify spread
optional int32 currency = 25; // Currency type, refer to Currency
optional int32 trdMarket = 26; //Trading market, refer to the enumeration definition of TrdMarket
optional int32 session = 27; //Trading session, refer to the enumeration definition of Session
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Order Fee Item
OrderFeeItem
message OrderFeeItem
{
optional string title = 1; //Fee title
optional double value = 2; //Fee Value
}
2
3
4
5
# Order Fee
OrderFee
message OrderFee
{
required string orderIDEx = 1; //Server order id
optional double feeAmount = 2; //Fee amount
repeated OrderFeeItem feeList = 3; //Fee details
}
2
3
4
5
6
# Order Fill
OrderFill
message OrderFill
{
required int32 trdSide = 1; //Trading direction, refer to enumeration definition of TrdSide
required uint64 fillID = 2; //OrderFill ID
required string fillIDEx = 3; //Extended OrderFill ID (only for checking the problem)
optional uint64 orderID = 4; //Order ID
optional string orderIDEx = 5; //Extended order ID (only when checking the problem)
required string code = 6; //code
required string name = 7; //Name
required double qty = 8; //Filled quantity, 2 decimal place accuracy, the option unit is "contract"
required double price = 9; //Price of the fill, 3 decimal places
required string createTime = 10; //Create time (transaction time), in strict accordance with YYYY-MM-DD HH:MM:SS or YYYY-MM-DD HH:MM:SS.MS format
optional int32 counterBrokerID = 11; //Counter Broker ID, valid for Hong Kong stocks
optional string counterBrokerName = 12; //Counter Broker Name, valid for Hong Kong stocks
optional int32 secMarket = 13; //Securities belong to the market, refer to enumeration definition of TrdSecMarket
optional double createTimestamp = 14; //Create a timestamp
optional double updateTimestamp = 15; //last update timestamp
optional int32 status = 16; //Deal status, refer to enumeration definition of OrderFillStatus
optional int32 trdMarket = 17; //Trading market, refer to enumeration definition of TrdMarket
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Maximum Trading Quantity
MaxTrdQtys
message MaxTrdQtys
{
//Due to the current server's implementation, it is required to sell the holding positions before a short selling, and to buy back short positions before a long buying (two steps). Nevertheless a bulish buying can be bought in one step with cash and financing. Please note this difference
required double maxCashBuy = 1; //Buy on cash. (Maximum quantity that can be bought in cash. The unit of options is "contract".Futures accounts are not applicable.)
optional double maxCashAndMarginBuy = 2; //Buy on margin. (Maximum quantity that can be bought on margin. The unit of options is "contract". Futures accounts are not applicable.)
required double maxPositionSell = 3; //Sell on position. (Maximum quantity can be sold. The unit of options is "contract".)
optional double maxSellShort = 4; //Short sell. (Maximum quantity can be shorted. The unit of options is "contract". Futures accounts are not applicable.)
optional double maxBuyBack = 5; //Short positions. (Buyback required quantity to close a position. When holding short positions, you must first buy back the short positions before you can continue to buy long. The unit of options and futures is "contract".)
optional double longRequiredIM = 6; //Initial margin change when buying one contract of an asset. Only futures and options apply. No position: Returns the initial margin needed to buy one contract (a positive value). Long position: Returns the initial margin required to buy one contract (a positive value). Short position: Returns the initial margin released for buying back one contract (a negative value).
optional double shortRequiredIM = 7; //Initial margin change when selling one contract of an asset. Currently only futures and options apply. No position: Returns the initial margin needed to short one contract (a positive value). Long position: Returns the initial margin released for selling one contract (a negative value). Short position: Returns the initial margin needed to short one contract (a positive value).
}
2
3
4
5
6
7
8
9
10
11
# Cash Flow Summary Info
FlowSummaryInfo
message FlowSummaryInfo
{
optional string clearingDate = 1; //clearing date
optional string settlementDate = 2; //settlement date
optional int32 currency = 3; //currency
optional string cashFlowType = 4; //cash flow type
optional int32 cashFlowDirection = 5; //cash flow direction, refer to TrdCashFlowDirection
optional double cashFlowAmount = 6; //amount
optional string cashFlowRemark = 7; //remark
optional uint64 cashFlowID = 8; //cash flow ID
}
2
3
4
5
6
7
8
9
10
11
# Filter Conditions
TrdFilterConditions
message TrdFilterConditions
{
repeated string codeList = 1; //Code filtering, only returns the products for these codes, and this condition is ignored if it is not set
repeated uint64 idList = 2; //ID primary key filter, only returns the products with these IDs, no filtering is not passed, orderID for order, fillID for deal, positionID for position
optional string beginTime = 3; //Start time, strictly in accordance with YYYY-MM-DD HH:MM:SS or YYYY-MM-DD HH:MM:SS.MS format. It is invalid for holding positions, and historical data must be filled in
optional string endTime = 4; //The end time, strictly in accordance with YYYY-MM-DD HH:MM:SS or YYYY-MM-DD HH:MM:SS.MS format. It is invalid for holding positions, and historical data must be filled in
repeated string orderIDExList = 5; // The server order id list, which can be used instead of orderID list, or choose one from orderID list
optional int32 filterMarket = 6; //Trading market filter, refer to enumeration definition of TrdMarket
}
2
3
4
5
6
7
8
9