What You Need to Know to Familiar with MyLanguage on FMZ -- Parameters of MyLanguage Trading Class Library
It is really simple to write trend strategies in MyLanguage. Thanks to encapsulation, we can write a strategy with only a few lines of code. In addition to querying MyLanguage Doc: MyLanguage Doc of FMZ Quant (https://www.fmz.com/bbs-topic/9480), there is a lack of some guidance articles. Therefore, in this article, we will learn to familiar with MyLanguage on FMZ. The MyLanguage on FMZ can be divided into three areas: commodity futures, digital currency spot, and digital currency futures. Let's sort out the differences in the use of different markets together. Let's take a look at an important content first.
MyLanguage trading class library
The "MyLanguage trading class library" is a framework class library that integrates and encapsulates some values, parameters and modes that need to be set by users, it breaks away from the level of strategy code, and it is set and configured by users when creating robots. It comes with the creation of MyLanguage strategy.
The understanding of these parameters and settings is essential for mastering the strategy of using MyLanguage on FMZ. Let's learn the concept and purpose of each parameter together.
The "Trading settings" group
Execution methods
The execution methods includeBar model
andTick model
.- Bar model
The Bar model is a trading logic that is executed each time a new K-line bar is created. For example, as shown in the figure below, the strategy adopts a 5-minute K-line period. The current time is 09:15:01. At this time, a new 5-minute K-line bar is generated, and the robot executes the strategy code logic written once. Only the K-line bar with the period completed (that is, the penultimate K-line bar) is displayed on the K-line chart. When the penultimate K-line bar is completed, it will be updated to the chart (at this time, the last K-line bar becomes the penultimate K-line bar).
- Bar model
To put it simply, when the last K-line bar is completed and the new period K-line bar comes out, the robot program executes the established strategy logic (trading strategy code written) once.
The advantage of this model is to avoid the interference caused by the real-time price changes during the period, and only look at the market data when the last K-line bar is finalized, as the basis for strategic trading and opening and closing positions. The disadvantage is that there may be a lag in opening and closing positions, because the strategy will not take action until the last K-line bar period is completed.
- Tick model
Tick model refers to the continuous implementation of the established strategic logic according to the real-time market. Once the trading conditions in the strategy are triggered, it will execute the trading instructions immediately. The advantage of this model is to monitor the market in real-time and execute trading instructions immediately without waiting for confirmation. The disadvantage is that it is easy to be disturbed frequently by the market. As shown in the following figure, the update time changes in real-time, and the chart also shows the last K-line bar (the current K-line bar, and the K-line bar on the chart also changes in real-time).
- Default number of open positions
When writing the MyLanguage strategy, if no order quantity parameter is specified for BK,SK,BPK,SPK, then those parameters will be used as the order quantity. For example:
MA5^^MA(C,5);
MA10^^MA(C,10);
CROSSUP(MA5,MA10),BK;
At this time, if the "default number of opening positions" is set to 2, then when the execution conditions of strategy BK CROSSUP (MA5, MA10)
are triggered, the number of opening positions is 2 (the specific number of opening positions is 2, 2 currencies, or 2 contracts, depends on which exchange is added, whether it is commodity futures, digital currency spot, or digital currency futures).
Take the backtest system as an example:
Maximum order quantity of a single transaction
The maximum quantity allowed for a single order. If the signal set triggers a large order quantity (set by the command parameter in the strategy or the default number of opening positions), the order will be split into small orders to place orders.Sliding point (integer)
The parameter is related to thepricing currency accuracy
parameter in the "spot transaction" group. It is mainly used to set the premium added or subtracted when placing an order. For example, when it is necessary to buy, when the counterparty sells a price of 10, we place the purchase price of 11. At this time, 11-10=1. The extra difference of 1 yuan is the sliding price. On the contrary, the selling part is the sliding price. The purpose of adding the sliding price is to ensure the transaction.
In commodity futures trading, different varieties have different priceTick (that is, the price per jump), and the same is true in digital currency trading. If the price for order placed is not a multiple of priceTick, such as the i2009
iron ore 2009 contract, the price per jump is 0.5. If I place an order of 760.1, it does not meet the requirements of priceTick. Such an order cannot be placed successfully, and the exchange will reject the order. If the order is 760.5, it is OK. Therefore, this problem needs to be considered when setting sliding price.
For commodity futures, the system will obtain the priceTick of the current variety automatically (the parameter of pricing currency precision is not effective). At this time, the sliding point
set is a multiple of the priceTick, for example:
It shows that the price of iron ore per jump is 0.5 when we set the sliding point to 5.
Because digital currency provides information such as price per jump that is not uniform, and some provide it, and some do not. Therefore, the parameter "pricing currency accuracy" is required to control. For example, the "pricing currency accuracy" parameter is set to 2, that is, the order price is accurate to the second decimal place, that is, 0.01. At this time, the priceTick is 0.01. If the sliding point is set to 5, the sliding price (or premium) added or subtracted based on the opponent's price will be 0.05 each time you place an order.
- Maximum period of variable
The maximum number of data to be saved. If this parameter is set to 200, the data series calculated in the strategy, such as the moving average and MACD indicator line, will only save the data on the last 200 K-lines.
Futures options
- Variety code
This parameter is mainly used to set the contract code of commodity futures
and digital currency futures
markets. Please refer to the MyLanguage document for details: https://www.fmz.com/bbs-topic/9480
-Digital currency futures
Refer to API documentation: https://www.fmz.com/api#exchange.setcontracttype... Contract code description.
If the exchange object added by the strategy is digital currency spot, this parameter setting is invalid.
Real bot option
- Resume the progress automatically
Check this parameter and restart after the strategy stops. The previous position will continue and the signal will continue to run, instead of running by using the initial status. If we need to run the strategy in the initial status, we can leave this parameter unchecked.
- Order Retries
If there is no deal when placing an order (for example, if the market changes quickly and the sliding price is not set to a large number, the opening position may have moved when placing an order). Cancel the order and replace the order. This parameter controls the number of times to replace the order. More than the number of times, no more orders, the signal execution is complete.
-Network rotation interval (milliseconds)
It is only valid for digital currency futures and cash, and controls the frequency of rotation of the program.
- Account synchronization time (seconds)
The time interval for reading account data.
- Position synchronization time after opening the position (milliseconds)
It is mainly used for the digital currency futures exchange. Sometimes the interface of the digital currency futures exchange will return to the old data, leading to position judgment errors, thus causing the strategy to place repeated orders. This problem can be alleviated by increasing the parameter setting. Let the strategy wait for a certain time to synchronize the position after placing an order.
- Leverage ratio
This parameter is only used for digital currency futures. Set the leverage of digital currency futures. The range and value of leverage supported by each digital currency future exchanges may be different, so it should be set specifically.
Commodity futures are fixed margin rates and they cannot be set independently.
Spot trading
Quantity per lot
This parameter is only valid for digital currency spot transactions, that is, set the default order quantityMinimum trading volume
It is used for digital currency spot, which is different from the concept of precision, new comers are always confused here, precision refers to the decimal place that is accurate, rather than the numerical value. The minimum transaction volume refers to the minimum value of each order, if the calculated order quantity is lower than this value, it will not be traded (such as insufficient funds, incomplete transactions, and the remaining small amount of planned transactions in a single transaction). Simply put, a single order operation, the minimum quantity of orders to meet this value. If it is less than this value, no order will be placed.Pricing currency precision
This parameter refers to the price precision (price decimal digits) at the time of trading, which affects the "sliding point" parameter we mentioned earlier. Special attention should be paid to some trading pairs priced by BTC. This kind of trading pair has very small price values and a large number of price decimal places. Attention should be paid to setting this price precision.Trading variety accuracy
This parameter refers to the order quantity precision during transaction and it controls the decimal places of the order quantity. For example, the unit quantity plan is 0.1234 currency. If this parameter is set to 2, the order quantity will be adjusted to 0.12.Commission
This parameter is used for digital currency spot, and the commission parameter is used to calculate the order quantity when placing an order (when place a buy order), so as to avoid the calculated order quantity exceeding the quantity of assets actually needed. If the commission rate of the exchange is uncertain, this parameter can be set a little larger.Profit and loss statistics interval
MyLanguage return statistics are calculated at regular intervals and print the current floating profit and loss, so whether the position is held or not (there is no real position in digital currency spot, it is a logical position), it can be calculated.Failed and retry (milliseconds)
This parameter is used to determine the interval between retries when the interface call fails.Use proxy
This parameter is mainly used for digital currency futures and digital currency spot. The use of SS5 proxy allows domestic server dockers to access some mentioned exchange interfaces.Hide common network errors
Check this parameter to filter some error logs.Switch base address
This parameter is mainly used for digital currency futures and digital currency spot. It is used to switch the base address of the rest protocol API interface, such as https://www.okex.com. It can only be accessed by overseas servers. You can use this parameter to switch to: https://www.okex.me. In this way, the docker running on the local computer can also access the OKX exchange interface.Push notification
After this parameter is checked, the order log will be placed, and the push message in the strategy will be pushed to the push option set by the current account.
Let's be familiar with the template parameters of the MyLanguage here. In the next section, we can get familiar with the MyLanguage runtime interface, charts, etc. on the FMZ platform.
Subscribe to my newsletter
Read articles from FMZ Quant directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
FMZ Quant
FMZ Quant
Quantitative Trading For Everyone