Futu Securities
It supports FutuNN live trading and demo trading, you need to download FutuOpenD
App.
When using FutuOpenD
to access demo trading, some stock codes are not supported, so you can’t trade, but the FutuOpenD mobile app is able to demo trading.
For configuration of exchange objects, running FutuOpenD
software, etc. on FMZ Quant, please refer to Futu Securities Configuration Description Document.
Frequency of interface calls
For GetOrder
, GetOrders
, GetPositions
, GetAccount
functions use cached data by default, so there is no limit to the frequency of calls.
When new data is available, FutuOpenD
will update the data automatically, and cached data will be updated synchronously.
The exchange.IO("refresh", true)
function can be called to disable caching, if disable caching then the frequency of calls is maximum of 10 queries per 30 seconds, exceeding the frequency limit will report an error.
Stock code
For example: 600519.SH
The strategy code uses the exchange.SetContractType()
function to set the stock code, for example:
function main() {
var info = exchange.SetContractType("600519.SH") // Set to stock 600519.SH, namely Kweichow Moutai, and the account will be switched to the China mainland market
Log(info)
Log(exchange.GetAccount()) // The currently set stock is Kweichow Moutai. At this time, call the GetAccount function to obtain the account assets, which are the account assets of the China mainland market
Log(exchange.GetTicker()) // Obtain the current price information of Kweichow Moutai stock
}
def main():
info = exchange.SetContractType("600519.SH")
Log(info)
Log(exchange.GetAccount())
Log(exchange.GetTicker())
void main() {
auto info = exchange.SetContractType("600519.SH");
Log(info);
Log(exchange.GetAccount());
Log(exchange.GetTicker());
}
Functions to set the direction of the transaction exchange.SetDirection
, functions to place orders exchange.Buy
/exchange.Sell
,
the withdrawal function exchange.CancelOrder
and the query order function exchange.GetOrder
are used in the same way as in the futures market.
Account information data format:
Define the market using TrdMarket
to distinguish between Hong Kong Market
, United States Market
, and China Mainland Market
.
Excerpts from the Futu API
documentation:
const (
TrdMarket_TrdMarket_Unknown TrdMarket = 0 //Unknown Trading Market
TrdMarket_TrdMarket_HK TrdMarket = 1 //Hong Kong Trading Market
TrdMarket_TrdMarket_US TrdMarket = 2 //United States Trading Market
TrdMarket_TrdMarket_CN TrdMarket = 3 //China Mainland Trading Market
TrdMarket_TrdMarket_HKCC TrdMarket = 4 //Hong Kong A-share Trading Market
TrdMarket_TrdMarket_Futures TrdMarket = 5 //Futures Trading Market
)
Get account information data, the exchange.GetAccount()
function returns:
{
"Info": [{
"Header": {
... // omit
"TrdMarket": 1 // In the Info raw information, market ID, indicates that the account assets are used for trading in the Hong Kong market
},
"Funds": { // Information on the account's assets in that market
...
}
}, ...],
"Stocks": 0,
"FrozenStocks": 0,
"Balance": 1000000, // Asset values in the current market
"FrozenBalance": 0
}
FutuOpenD
distinguish by region based on the logged in IP address
There are restrictions on accessing market data for accounts logged in from non-mainland IP addresses, which can be found in the official documentation of FutuOpenD
.
Futures_Binance
It supports the dual position mode of Binance futures; you can use exchange.IO
to switch:
function main() {
var ret = exchange.IO("api", "POST", "/fapi/v1/positionSide/dual", "dualSidePosition=true")
// ret : {"code":200,"msg":"success"}
Log(ret)
}
def main():
ret = exchange.IO("api", "POST", "/fapi/v1/positionSide/dual", "dualSidePosition=false")
Log(ret)
void main() {
auto ret = exchange.IO("api", "POST", "/fapi/v1/positionSide/dual", "dualSidePosition=true");
Log(ret);
}
It supports switching between crossed position/isolated position:
function main() {
exchange.SetContractType("swap")
exchange.IO("cross", true) // Switch to crossed position
exchange.IO("cross", false) // Switch to isolated position
}
def main():
exchange.SetContractType("swap")
exchange.IO("cross", True)
exchange.IO("cross", False)
void main() {
exchange.SetContractType("swap");
exchange.IO("cross", true);
exchange.IO("cross", false);
}
It supports for switching to Binance unified account mode:
function main() {
exchange.IO("unified", true) // Switch to unified account mode
exchange.IO("unified", false) // Switch to commom mode
}
def main():
exchange.IO("unified", True)
exchange.IO("unified", False)
void main() {
exchange.IO("unified", true);
exchange.IO("unified", false);
}
It supports setting up STP mode for Binance spot/futures orders:
function main() {
// "NONE" indicates that STP mode is disabled, other parameters are: "EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH"
exchange.IO("selfTradePreventionMode", "NONE")
}
def main():
exchange.IO("selfTradePreventionMode", "NONE")
void main() {
exchange.IO("selfTradePreventionMode", "NONE");
}
Futures_HuobiDM
exchange.IO("signHost", "")
to set an empty string.
Use exchange.IO("signHost", "https://aaa.xxx.xxx")
to switch the base address of Huobi Futures participating in signature verification.
Use exchange.IO("base", "https://bbb.xxx.xxx")
or exchange.SetBase("https://bbb.xxx.xxx")
to switch the base address of the platform interface.XXX_USDT
, use the function exchange.SetContractType("swap")
to set the contract code to swap
perpetual contract, using exchange.IO("cross", true)
can switch to USDT
-margined perpetual contract in the crossed position mode. Using exchange.IO("cross", false)
to switch back to the isolated position mode. The initial default is the isolated position mode.exchange.IO("dual", true)
to switch to a bidirectional position, and use exchange.IO("dual", false)
to switch to a unidirectional position.Huobi
Switch special trading pairs:
It supports Huobi spot leverage tokens, such as: LINK*(-3)
; the code defined by the exchange is: link3susdt
, which is written when FMZ Quant Trading Platform sets the trading pair LINK3S_USDT
.
It is also possible to switch trading pairs in the strategy:
function main() {
exchange.SetCurrency("LINK3S_USDT")
Log(exchange.GetTicker())
}
def main():
exchange.SetCurrency("LINK3S_USDT")
Log(exchange.GetTicker())
void main() {
exchange.SetCurrency("LINK3S_USDT");
Log(exchange.GetTicker());
}
Futures_OKX(Futures_OKCoin/Futures_OKEX)
exchange.IO("simulate", true)
can switch to the simulated trading environment. If you want to switch to the real trading environment, use exchange.IO("simulate", false)
to switch. The initial default is the live trading environment.exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode, the initial default is the crossed position mode.exchange.IO("dual", true)
to switch to a bidirectional position, and use exchange.IO("dual", false)
to switch to a unidirectional position.OKX(OKCoin/OKEX)
exchange.IO("simulate", true)
to switch to the demo bot environment. If you want to switch to the live trading environment, use exchange.IO("simulate", false)
to switch to live trading, the initial default is the live trading environment.Futures_Bibox
exchange.IO("cross", true)
to switch to the crossed position mode, and use exchange.IO("cross", false)
to switch to the isolated position mode; the initial default is crossed position mode.GetOrders
and GetTrades
functions are not supported.Futures_Bitget
exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode.exchange.IO("dual", true)
to switch to a bidirectional position and exchange.IO("dual", false)
to switch to a unidirectional position.Futures_MEXC
exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode.Futures_GateIO
exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode.exchange.IO("dual", true)
to switch to a bidirectional position and exchange.IO("dual", false)
to switch to a unidirectional position.exchange.IO("unified", true)
to switch unified accounts; use exchange.IO("unified", false)
to switch back to non-unified accounts.GateIO
exchange.IO("unified", true)
to switch unified accounts; uses exchange.IO("unified", false)
to switch back to non-unified accounts.Futures_Bybit
exchange.IO("cross", true)
to switch to crossed position mode, use exchange.IO("cross", false)
to switch to isolated position mode. Use exchange.IO("unified", true)
to switch to unified margin interface, use exchange.IO("unified", false)
to switch back to normal contract interface.exchange.IO("unified", true)
to switch to the unified margin interface, and exchange.IO("unified", false)
to switch back to the common contract interface.exchange.IO("dual", true)
to switch to a bidirectional position and exchange.IO("dual", false)
to switch to a unidirectional position.Futures_Pionex
exchange.IO("cross", true)
to switch to crossed position mode, use exchange.IO("cross", false)
to switch to isolated position mode. Use exchange.IO("dual", true)
to switch to bidirectional positions and exchange.IO("dual", false)
to switch to unidirectional positions.exchange.IO("dual", true)
to switch to a bidirectional position and exchange.IO("dual", false)
to switch to a unidirectional position.Futures_BitMEX
exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode.BitMEX
Bitfinex
Futures_Phemex
exchange.IO("dual", true)
to switch to a bidirectional position and exchange.IO("dual", false)
to switch to a unidirectional position.Backpack It supports setting the STP mode for Backpack spot orders:
function main() {
// "Allow" means to allow self-dealing, "RejectTaker" "RejectMaker" "RejectBoth" "Allow"
exchange.IO("selfTradePreventionMode", "Allow")
}
def main():
exchange.IO("selfTradePreventionMode", "Allow")
void main() {
exchange.IO("selfTradePreventionMode", "Allow");
}
Futures_CoinEx
exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode.Futures_Aevo
xxx
, use exchange.IO("signingKey", "xxx")
to pass it in. Note that signingKey has a time limit. After passing it in, the exchange.IO
function returns the public key of signingKey.Futures_Kraken
multi-collateral
contract of Futures_Kraken exchange supports crossed position, isolated position and leverage settings.
Use exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode.Futures_Crypto
accountId
:
Use exchange.IO("accountId", "xxx")
to set accountId.Gemini
exchange.IO("subAccount", "xxx")
to switch subaccounts.Futures_Aevo
Id
Description:
The exchange order Id
consists of the actual Id
and the order timestamp. The timestamp and the actual order Id
are separated by English commas. The purpose is to support the exchange.GetOrder(Id)
function to query orders. Since the order timestamp in the data returned by the exchange will change with the order status, if you need to record the order Id
and other information locally, please separate the actual order Id
record.Futures_dYdX
exchange.IO("simulate", true)
, you can switch to the test network environment. If you want to switch to the main network environment, use exchange.IO("simulate", false)
, the initial default is the main network environment.exchange.IO("limitFee", 0.001)
Set the fee rate. The default is 0.001.exchange.IO("secondsOfValidity", 60 * 60 * 24 * 28)
sets the validity period. The default is 60 * 60 * 24 * 28.Futures_WOO
exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode.exchange.IO("dual", true)
to switch to a bidirectional position, and use exchange.IO("dual", false)
to switch to a unidirectional position.Futures_KuCoin
exchange.IO("cross", true)
to switch to crossed position mode, and use exchange.IO("cross", false)
to switch to isolated position mode.