The resource loading... loading...

FMZ Quantitative Platform Strategy Writing Tutorials for Beginners (must see)

Author: The grass, Created: 2019-08-13 17:47:27, Updated: 2021-08-06 10:29:46

The disadvantage of this mechanism is obvious: on a K-line, only one trade can be generated, and the price is usually based on the closing price of the K-line. And a K-line can only get four prices from high to low, and no information can be obtained about how the price changes in a K-line, whether the highest price occurs first or the lowest price occurs first, etc. For example, the 1 hour K-line is sure to get a trade information every few seconds, and the trade instructions will be sent in the disc instead of waiting for the K-line to end.

The FMZ platform resets both analogue-level resets and real disk-level resets. Analogue-level resets generate 14 reset time points on each underlying K-line cycle, based on the tick generated by the underlying K-line cycle.The real disk level is the real collected tick, about once every few seconds, and currently partially supports real depth ((contains 20 files), real penny transaction.There is a large amount of data and a slow rate of retracement, so it is not possible to retracement particularly long time. FMZ's retracement mechanism allows the strategy to be traded multiple times on a single K line, avoiding the situation where only close price transactions can be done, more accurate and taking into account the retracement speed.https://www.fmz.com/digest-topic/4009

The iterative policy framework is the same as the real disk, and is a dead loop. Since iteration jumps at different iterative points, this time can be done without Sleep, which automatically jumps to the next time point at the end of one loop.Sleep(10)I'm not going to be able to do this.

The photo of the retest

The retargeting engine takes a snapshot of the spot price at the time of the retargeting and the price of the buy price is higher than the sell price. If the transaction is not completed, a pending list is generated. The transaction requires a sliding point to ensure.

Settings for retesting pages

img

  • 1.回测页面的选择,左侧是策略编辑页面。
  • 2.回测起始结束时间,由于数据不完整,回测可能直接从有数据的时间开始。
  • 3.回测GetRecords()The default cycle of a function can also be specified in the code.
  • 4.回测机制的选择。
  • 5.展示或隐藏跟多回测设置。
  • 6.最大日志数、收益数据数、图表数据数等,为了防止数据量过大导致浏览器卡死。
  • 6.底层tick生成依据K线周期。
  • 7.交易滑点。
  • 7.容错,会模拟API请求出错情况,检查策略容错能力。
  • 8.是否绘制行情图标,回测中如果使用了TA指标函数,会自展示在图标上,买卖也会标记。
  • 9.手续费设置
  • 10. Add exchanges - trading pairs and assets.
  • 11.回测参数设置,如果参数是数字还支持一键优化参数,自动按照一定范围遍历参数回测。

Difference between retest and real disk

  • 1.回测时有效的行情只有GetTicker和GetRecords,其它如获深度、成交历史都不是真实的(因为数据量太大,实盘级回测目前已经支持这些数据,但只有最近数据)。
  • 2.回测添加的交易所都是独立账户,目前不支持切换交易对。因此无法在一个账户里操作两个交易对。
  • 3.回测中无法使用网络请求。
  • 4.回测无法使用IO扩展,只能操作最基础的API。
  • 5.回测只能获取标准的数据,像Info之类的牵扯到实盘的数据不存在。
  • 6.回测中也有可能不成交,注意冻结订单情况。
  • 7.商品期货回测不支持市价单。

Strategic blunders and common mistakes

As mentioned earlier, using an API interface on a physical disk can cause access to fail and return.nullThis will cause errors and cause the hard drive to stop, so the strategy is to be tolerant of errors.

Commonly misunderstood

Common misconceptions:

  • API access network error, interface access delay will return null, when use will report an error.
  • The exchange limits errors such as IP limitation, order accuracy, access frequency, parameter errors, insufficient assets, market failure, cancellation of completed orders, etc.; the API documentation can be consulted specifically based on the error code.
  • The exchange returns data errors, which occasionally occur, such as returning empty depth, delayed account information, delayed order status, etc.
  • This is a logical error.

Before using the API to return data, it is necessary to judge whether it is null.

//1.判断为null进行处理
var ticker = exchange.GetTicker();
while(ticker == null){
     Log('ticker 获取出错');
     ticker = exchange.GetTicker();
 }
 Log(ticker.Last);
 // 2.判断不为null再进行引用
 var ticker = exchange.GetTicker();
 if(!ticker){
     Log(ticker.Last);
 }
 // 3._C()函数重试
 var ticker = _C(exchange.GetTicker);
 Log(ticker.Last);
 // 4. try catch容错
 try{
     var ticker = exchange.GetTicker();
     Log(ticker.Last);
 }
 catch(err){
     Log('ticker 获取出错');
 } 

If you want to get the wrong information, you can use it.GetLastError(), which returns the last error message string, can be used for differential processing of errors.

FAQ

There are a lot of common misconceptions about the forum top posts:https://www.fmz.com/bbs-topic/1427The following is a summary of some of the problems you may encounter by searching Ctrl+F.

How to place a trustee?

Add a host for more details.

Can you find a strategy for transcribing?

https://www.fmz.com/marketsSome people offer copywriting services or consult in groups, and need to contact themselves at their own risk.

Access to all interfaces prompts timeout

This refers to access to the exchange interface overtime, if it occurs occasionally is not a problem, if it is constantly prompted to say that the network in which it is not accessible, the need to use an overseas server.

Error in the following command:

The system reports errors, usually written errors for the strategy, and attempts to close a position without holding or with insufficient number of holdings will cause the error.

symbol not set

Futures exchanges retest, no contracts are set in the code, see exchange.SetContractType

BITMEX 429 error, {error:{message:Rate limit exceeded retry in 1 seconds......}}

The frequency of access to the exchange interface is too high.

{“status”:6004,“msg”:“timestamp is out of range”}

Server timestamp is out of range and needs to be updated to avoid excessive deviation.

GetOrder(455284455): Error: invalid order id or order cancelled.

Some exchanges canceled orders, and the information about the order was not maintained and could not be accessed.

GetOrders: 400: {“code”:-1121,“msg”:“Invalid symbol.”}

Invalid transaction pairs, check whether the transaction pair is set to error.

Secret key decrypt failed

Failed to resolve API KEY. If you have modified the FMZ password after configuring APIKEY, try adding an exchange page in FMZ and reconfiguring the exchange APIKEY.

Signature not valid: Invalid submission time or incorrect time format

It is recommended to use a Linux server, or install time sync software on windows systems where this problem occurs.

Why set up a global proxy so that the trustee can't access the exchange API?

Global proxies do not have proxy host network ports, so it is best to deploy hosts with overseas servers due to latency issues.

How can the strategy be kept local instead of being uploaded to the FMZ?

Using Python, you can import a local file, save the policy normally written in FMZ's API as a file on your own server under the execution path, and read the execution directly.

#!python2.7

def run(runfile):
      with open(runfile,"r") as f:
            exec(f.read())
            
def main():
    run('my.py')

How to use an exchange's test net or change the API base address

You can switch directly to the corresponding API base address using exchange.SetBase.

exchange.SetBase("https://www.okex.me")

More

gaoencheer api

ScienceHow do I implement the policy locally? I wrote a simple Log output statement and followed the end-of-sentence operation. The first step is to use a laptop as a server and run the host program. The second step is to write a simple test.py program for log output information (the FMZ API interface function); The third step, as at the end of the text, is to write a runfile and run it through run.py calling test.py. /upload/asset/1add39483ef82d45b3ce3.png

gyp9I bought the NetEase Cloud Quantitative Trading course, now where to go?

MonuRajak many

MonuRajak hi

I'm not sure.Learning

wqyThere's a small typo, GetAccount gets the account. In the introduction, FrozenStocks is supposed to be a frozen balance, not a available balance.

Lieutenant Jaya.getorder outtime get order outtime, exchange of okx, what to do

The Tree of LifeIf the collateral rate is not available, the collateral rate to 0% will be forced to break even.

shifeng2020I'm looking at a 1-minute k-string operation, so the sleep time of the Python dead loop can be set to 0.1s, which is sleep ((100)

East Windmillsexchange.SetDirection (("closebuy"); // if it is a permanent contract, directly set exchange.SetDirection (("sell") I tried OKex's perpetual contract here, and if it's set to sell, it's just empty, not cheap.

East Windmillsexchange.SetDirection (("closebuy"); // if it is a permanent contract, directly set exchange.SetDirection (("sell") I tried OKex's perpetual contract here, and if it's set to sell, it's just empty, not cheap.

East WindmillsThere are two spelling errors in the GetOrders code. One is that function is written as a function and the other is that it is written as a condition of the for loop.

East WindmillsIt was my fault. exchange.Buy ((-1, 0.5), the trading pair is ETH_BTC, the market price list represents the purchase of ETH for 0.5BTC exchange.Buy ((price, 0.5), if this is the limit list, it represents buying 0.5ETH at the price of the price

East Windmillsexchange.Buy ((-1, 0.5), the trading pair is ETH_BTC, which represents the market price of buying ETH of 0.5BTC This is supposed to be the market price for buying 0.5 ETH of nickel.

gyp9Thank you.

The grassIt has been on the web https://study.163.com/course/courseMain.htm?share=2&shareId=400000000602076&courseId=1006074239&_trace_c_p_k2_=c3f5d238efc3457d93c8b92c0398d2b2

The grassWeight Watchers adds a homepage to your group.

wqyI'm having trouble asking if we have an official chat group. Sometimes I don't know where to ask questions.

The grassChanged

The grassAcquire again

The grassYou can use GetRawJSON or view the info in the field

East WindmillsI found a lot of spelling mistakes in the code, haha.

The grassHi, corrected, thank you for pointing out the error.

The grassSome perpetual contracts allow bidirectional holdings, which need to be set to break even.