# Trading Definitions

# Account Risk Control Level

CltRiskLevel

  • NONE

    Unknown

  • SAFE

    Safe

  • WARNING

    Warning

  • DANGER

    Danger

  • ABSOLUTE_SAFE

    Absolutely safe

  • OPT_DANGER

    Danger

Tips

  • It is recommanded to use risk_status field to get risk status of futures account, see CltRiskStatus

# Currency Type

Currency

  • NONE

    Unknown currency

  • HKD

    HK dollar

  • USD

    US dollar

  • CNH

    Offshore RMB

  • JPY

    Japanese Yen

  • SGD

    SG dollar

  • AUD

    Australian dollar

# TrailType

TrailType

  • NONE

    Unknown

  • RATIO

    Trailing ratio

  • AMOUNT

    Trailing amount

# Modify Order Operation

ModifyOrderOp

  • NONE

    Unknown operation

  • NORMAL

    Modify order

  • CANCEL

    Cancel

  • DISABLE

    Disable

  • ENABLE

    Enable

  • DELETE

    Delete

# Transaction Status

DealStatus

  • OK

    Transaction success

  • CANCELLED

    Transaction cancelled

  • CHANGED

    Transaction changed

# Order Status

OrderStatus

  • NONE

    Unknown status

  • UNSUBMITTED

    Unsubmitted (This enum value is deprecated)

  • WAITING_SUBMIT

    Waiting to submit

  • SUBMITTING

    Submitting

  • SUBMIT_FAILED

    Submission failed (This enum value is deprecated)

  • TIMEOUT

    Processing timed out, result unknown (This enum value is deprecated)

  • SUBMITTED

    Pending

  • FILLED_PART

    The unfilled part of the order has not been cancelled.

  • FILLED_ALL

    All filled

  • CANCELLING_PART

    Cancelling part of the order

    (This enum value is deprecated)

  • CANCELLING_ALL

    Cancelling the whole order (This enum value is deprecated)

  • CANCELLED_PART

    Part of the order is filled, and the remaining has been withdrawn.

  • CANCELLED_ALL

    All orders have been cancelled, no transactions.

  • FAILED

    Order failed, refused by serser

  • DISABLED

    Order disabled

  • DELETED

    Deleted, only unfilled orders can be deleted

  • FILL_CANCELLED

    The transaction is canceled (This enum value is deprecated)

# Order Type

OrderType

  • NONE

    Unknown type

  • NORMAL

    Limit orders

  • MARKET

    Market orders

  • ABSOLUTE_LIMIT

    Absolute limit orders(HK securities only)

  • AUCTION

    At-auction market orders (HK securities only)

  • AUCTION_LIMIT

    At-auction limit orders (HK securities only)

  • SPECIAL_LIMIT

    Special limit orders (HK securities only)

  • SPECIAL_LIMIT_ALL

    AON special limit orders (HK securities only).

  • STOP

    Stop orders

  • STOP_LIMIT

    Stop Limit orders

  • MARKET_IF_TOUCHED

    Market if Touched orders

  • LIMIT_IF_TOUCHED

    Limit if Touched orders

  • TRAILING_STOP

    Trailing Stop orders

  • TRAILING_STOP_LIMIT

    Trailing Stop Limit orders

  • TWAP_LIMIT

    Time Weighted Average Price Limit orders (HK and US securities only)

  • TWAP

    Time Weighted Average Price Market orders (US securities only)

  • VWAP_LIMIT

    Volume Weighted Average Price Limit orders (HK and US securities only)

  • VWAP

    Volume Weighted Average Price Market orders (US securities only)

Tips

  • Paper trade only supports limit orders (NORMAL) and market orders (MARKET).

# Position Direction

PositionSide

  • NONE

    Unknown position

  • LONG

    Long position, by default

  • SHORT

    Short position

# Account Type

TrdAccType

  • NONE

    Unknown type

  • CASH

    Cash account

  • MARGIN

    Margin Account

# Trading Environment

TrdEnv

  • SIMULATE

    Simulated environment

  • REAL

    Real environment

# Transaction Market

TrdMarket

  • NONE

    Unknown market

  • HK

    Hong Kong market

  • US

    US market

  • CN

    A-share market

  • HKCC

    HKCC market

  • FUTURES

    Futures market

  • FUTURES_SIMULATE_US

    US futures simulated market

  • FUTURES_SIMULATE_HK

    Hong Kong futures simulated market

  • FUTURES_SIMULATE_SG

    Singapore futures simulated market

  • FUTURES_SIMULATE_JP

    Japan futures simulated market

  • HKFUND

    HK fund market

  • USFUND

    US fund market

# Transaction Securities Market

# Transaction Direction

TrdSide

  • NONE

    Unknown direction

  • BUY

    Buy

  • SELL

    Sell

  • SELL_SHORT

    Sell short

  • BUY_BACK

    Buy 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 and Get History Order List interface.

# Order Validity Period

TimeInForce

  • DAY

    Good for the day

  • GTC

    Good until cancel

# Securities Firm to Which the Account Belongs

SecurityFirm

  • NONE

    Unknown

  • FUTUSECURITIES

    FUTU HK

  • FUTUINC

    MOOMOO US

  • FUTUSG

    MOOMOO SG

  • FUTUAU

    MOOMOO AU

# Simulate Account Type

SimAccType

  • NONE

    Unknown

  • STOCK

    Stock simulation account

  • OPTION

    Option simulation account

  • FUTURES

    Futures simulation account

# Account Risk Control Status

CltRiskStatus

  • NONE

    Unknown

  • LEVEL1

    Very Safe

  • LEVEL2

    Safe

  • LEVEL3

    Safe

  • LEVEL4

    Low Risk

  • LEVEL5

    Medium Risk

  • LEVEL6

    High Risk

  • LEVEL7

    Warning

  • LEVEL8

    Margin Call

  • LEVEL9

    Margin Call

# Day-trading Status

DtStatus

  • NONE

    Unknown

  • Unlimited

    Unlimited

  • EM_Call

    EM-Call

  • DT_Call

    DT-Call

# Transaction Category

TrdCategory

enum TrdCategory
{
    TrdCategory_Unknown = 0; //Unknown
    TrdCategory_Security = 1; //Securities
    TrdCategory_Future = 2; //Futures
}
1
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
}
1
2
3
4
5
6

# 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
}
1
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
}
1
2
3
4
5
6
7
8
9
10
11

# 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 (Minimum OpenD version requirements: 5.0.1310) 
  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 applicable to securities accounts) 

  optional int32 currency = 8;            //The currency used for this query (only applicable to general 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 (Minimum OpenD version requirements: 5.0.1310) 
  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
}
1
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

# 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 (such as plRatio equal to 0.088 represents an increase of 8.8%), 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
}
1
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

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
}
1
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

# Order Fee Item

OrderFeeItem

message OrderFeeItem
{
    optional string title = 1; //Fee title
    optional double value = 2; //Fee Value
}
1
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
}
1
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
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

# 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 for each long contract. Currently, only futures and options apply (Minimum OpenD version requirements: 5.0.1310)
    optional double shortRequiredIM = 7;        //Initial margin for each short contract. Currently, only futures and options apply (Minimum OpenD version requirements: 5.0.1310)
}
1
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
}
1
2
3
4
5
6
7
8