Sumber dimuat naik... memuat...

Pelaksanaan cepat alat perdagangan kuantitatif separa automatik

Penulis:Kebaikan, Dicipta: 2020-08-30 10:11:02, Dikemas kini: 2023-10-08 19:54:06

Quickly implement a semi-automatic quantitative trading tool

Pelaksanaan cepat alat perdagangan kuantitatif separa automatik

Dalam perdagangan niaga hadapan komoditi, arbitraj intertemporari adalah kaedah perdagangan yang biasa. Jenis arbitraj ini tidak bebas risiko. Apabila arah satu sisi penyebaran terus berkembang, kedudukan arbitraj akan berada dalam keadaan kehilangan terapung. Walau bagaimanapun, selagi kedudukan arbitraj dikawal dengan betul, ia masih sangat operasional dan layak.

Dalam artikel ini, kita cuba beralih ke strategi perdagangan lain, dan bukannya membina strategi perdagangan automatik sepenuhnya, kita menyedari alat perdagangan kuantitatif interaktif separa automatik untuk memudahkan arbitrage intertemporari dalam perdagangan niaga hadapan komoditi.

Platform pembangunan kami akan menggunakan platform FMZ Quant. Tumpuan artikel ini adalah bagaimana untuk membina strategi separa automatik dengan fungsi interaktif.

Arbitraj intertemporal adalah konsep yang sangat mudah.

Konsep arbitrase intertemporal

  • Kutipan dari Wikipedia


# Strategy Design

The strategy framework is as follows:

Fungsi utama Walaupun benar. If(exchange.IO(status)){ // Menentukan status sambungan protokol CTP. LogStatus(_D(), Sudah disambungkan ke CTP!) // Waktu pembukaan pasaran, sambungan log masuk adalah normal. { lain { LogStatus(_D(), CTP tidak disambungkan!) // Tidak log masuk ke bahagian hadapan perdagangan. {} {} {}


If the CTP protocol is connected properly, then we need to set up the trading contract and then get the market quote. After obtaining the quotes, we can use the FMZ Quant platform build-in "line drawing" library to draw the difference.

Fungsi utama Walaupun benar. If(exchange.IO(status)){ // Menentukan status sambungan protokol CTP. exchange.SetContractType ((rb2001) // Tetapkan kontrak bulan jauh Var tickerA = exchange.GetTicker() // data harga kontrak bulan jauh exchange.SetContractType ((rb1910) // Tetapkan kontrak bulan terdekat Var tickerB = exchange.GetTicker() // data harga kontrak hampir bulan Var diff = tickerA.Terakhir - tickerB.Terakhir $.PlotLine ((diff, diff)

LogStatus(_D(), Sudah disambungkan ke CTP!) // Waktu pembukaan pasaran, sambungan log masuk adalah normal. { lain { LogStatus(_D(), CTP tidak disambungkan!) // Tidak log masuk ke bahagian hadapan perdagangan. {} {} {}


Get the market data, calculate the difference, and draw the graph to record. let it simply reflects the recent fluctuations in the price difference.
Use the function of "line drawing" library ```$.PlotLine```

 ![Quickly implement a semi-automatic quantitative trading tool](/upload/asset/6e286fea238b8266dd13.png) 

# Interactive part

On the strategy editing page, you can add interactive controls directly to the strategy:

 ![Quickly implement a semi-automatic quantitative trading tool](/upload/asset/6e9b91112616d444b964.png) 

Use the function ```GetCommand``` in the strategy code to capture the command that was sent to the robot after the above strategy control was triggered.

After the command is captured, different commands can be processed differently.

The trading part of the code can be packaged using the "Commodity Futures Trading Class Library" function. First, use ```var q = $.NewTaskQueue()``` to generate the transaction control object ```q``` (declared as a global variable).

var cmd = GetCommand() jika (cmd) { jika (cmd == plusHedge) { q.pushTask ((exchange, rb2001, sell, 1, fungsi ((task, ret) { Log ((task.desc, ret) jika (ret) { q.pushTask ((exchange, rb1910, buy, 1, 123, fungsi ((task, ret) { Log ((q, tugas.desc, ret, tugas.arg) {y: i} { C: $ 00FFFF } {y: i} } jika (cmd == minusHedge) { q.pushTask ((exchange, rb2001, buy, 1, fungsi ((task, ret) { Log ((task.desc, ret) jika (ret) { q.pushTask ((exchange, rb1910, sell, 1, 123, fungsi ((task, ret) { Log ((q, tugas.desc, ret, tugas.arg) {y: i} { C: $ 00FFFF } {y: i} } jika (cmd == coverPlus) { q.pushTask ((exchange, rb2001, closesell, 1, fungsi ((task, ret) { Log ((task.desc, ret) jika (ret) { q.pushTask ((exchange, rb1910, closebuy, 1, 123, fungsi ((task, ret) { Log ((q, tugas.desc, ret, tugas.arg) {y: i} { C: $ 00FFFF } {y: i} } jika (cmd == coverMinus) { q.pushTask ((exchange, rb2001, closebuy, 1, fungsi ((task, ret) { Log ((task.desc, ret) jika (ret) { q.pushTask ((exchange, rb1910, closesell, 1, 123, fungsi ((task, ret) { Log ((q, tugas.desc, ret, tugas.arg) {y: i} { C: $ 00FFFF } {y: i} { C: $ 00FFFF } { C: $ 00FFFF } q.poll() `


Kandungan berkaitan

Lebih lanjut