The resource loading... loading...

Blockchain Quantitative Investing Series Course ((3)) - cross-term leverage

Author: 15565556421, Created: 2018-08-10 14:38:50, Updated:

Read the original:Blockchain Quantitative Investing Series Course ((3)) - cross-term leverage

NO.1

In his 1987 book, The Alchemist of Silicon Finance, Soros made an important proposition: I believe the market prices are always wrong in the sense that they present a biased view of the future.The market efficacy hypothesis is only a theoretical hypothesis, in fact market participants are not always rational, and at each point in time, it is impossible for participants to fully access and objectively interpret all information, and even if it is the same information, everyone's feedback is not the same.

In other words, the price itself already contains the wrong expectations of the market participants, so the market price is inherently wrong; this may be the source of the profits of the profiteers.

NO.2

Based on the above principles, we also know that in an inefficient futures market, the market influence between the different time frames of the bid-offer spread is not always synchronous and its pricing is not entirely efficient.

Then, based on the price of the exchange rate for different periods of the same trading index, if the two prices have a large price difference, it is possible to buy and sell futures contracts at different periods at the same time, and to carry out cross-term arbitrage.As with commodity futures, digital currencies also have their own set of over-the-counter (OTC) futures.

For example, suppose that the difference between the price of ETC during the week and the price of ETC during the quarter lasts for about 5 days. If the price difference reaches 7 on a given day, we expect the difference to return to 5 at some point in the future. Then we can sell ETC during the week and buy ETC during the quarter to make up the difference.

NO.3

Despite the existence of such price differences, there is often a lot of uncertainty about the impact of time, poor accuracy and price variations on the human hand.

Capturing leverage opportunities and formulating leverage trading strategies through quantified models, as well as programmatic algorithms that automatically place trading orders to exchanges, quickly and accurately capture opportunities, efficiently and steadily earn returns, is the appeal of quantified leverage.This article will teach you how to use inventors' quantitative trading platforms and ETC futures contracts on the OkEX exchange in digital currency trading to demonstrate a simple strategy of leverage that can be used to capture momentary leverage opportunities, capture visible profits at every turn, and hedge potential risks.

NO.4

Creating a digital currency cross-currency strategy Difficulty: Average

The strategic environment:

  • This is the first time that the ETC has traded on ETH since its inception.
  • Price difference data: ETC during the week - ETC quarter (except for the co-integration check)
  • Trading cycle: 5 minutes
  • 头寸匹配:1:1
  • Type of transaction: cross-section of the same variety

The strategic logic:

  • If the current account does not hold stock and the price is less than boll down, then the price is overbought.
  • If the current account does not hold stock and the price is higher than the boll, then the short position is open.
  • If the current account holds more ETC on a weekly basis and holds more ETC on a quarterly basis, and the price difference is greater than the boll, then the price difference is flat; i.e. sell ETC on a weekly basis and buy ETC on a quarterly basis.
  • If the current account holds ETC on a weekly basis and holds multiple ETC orders on a quarterly basis, and the price is less than the boll in the middle of the track, then the spot price is the difference; i.e. buy ETC on a weekly basis and sell ETC on a quarterly basis.

NO.5

The above is a simple description of the logic of the digital currency cross-term arbitrage strategy, so how do you implement your ideas in the program?The strategic framework: Inventor quantified (www.fmz.cn)It is easy to build a strategic framework by comparing strategic ideas and the trading process. The whole strategy can be simplified into three steps: 1. Pre-processing before the transaction. 2. Obtain and compute data. 3. Order and follow up.

NO.6

Next, we need to fill in the necessary detail code in the strategy framework based on the actual transaction process and transaction details.

A. Pre-processing of the transaction

Step 1: Declare the necessary global variables in the global environment.

  • Declare a chart object for a configured chart var chart = { }
  • Call the Chart function, initialize the chart var ObjChart = Chart or chart
  • Declare an empty array for storing price difference sequences var bars = [ ]
  • Declare a recording of historical data as a timestamp variable var oldTime is 0.

Step 2: External parameters of the policy configuration.Inventor quantified (www.fmz.cn)

Step 3: Define the data processing functionBasic data functions:Data ()) is a data type. Create a constructor function Data and define its internal properties. These include: account data, holding data, K-line data time frames, bid/ask spread, positive/negative bid/ask spread.Inventor quantified (www.fmz.cn) Get the hold functionI'm not sure. Goes through the entire holding array, returns the number of holdings for the specified contract, the number of holdings for the specified direction, if none, returns false K-lines and indicator functions:boll ()) New K-line sequences are synthesized based on positive/counter-setting price difference data. The uptrend, midtrend, and downtrend data calculated by the Boll indicator are returned. Subscript functions:trade ()) Enter the name of the order and the type of the order, and then enter the price of the order and return the result. Since it requires two different orders to be placed at the same time, the buy/sell price is converted within the function according to the name of the order. Cancel the order functionCancel Orders () Retrieves all outstanding orders and cancels them one by one. Returns false if there are any outstanding orders, and true if there are no outstanding orders. Dealing with a single contractisEven (): One-legged trading occurs in the processing of leveraged trades, where all positions are directly dealt with by a simple flattering of the transaction. Of course, it can also be changed to a tracking method. Draw the graphDrawingChart ()) Use the ObjChart.add () method to plot the necessary market data and indicator data in the chart: up, down, up, down, positive/negative.Step 4: Execute transaction preprocessing code inside the main () input function, which runs only once after the program is started.

  • Not important information in the filter panel SetErrorFilter ()
  • Set up the digital currency to tradeexchange.IO ( )
  • Chart drawn before the program starts ObjChart.reset ()
  • Status bar information before the program is started LogProfitReset ()

NO.7

Once the transaction preprocessing is defined, the next step is to enter the consultation mode and repeat the onTick () function. Sleep () is also set as a sleep time when querying, as some digital currency exchanges' APIs have built-in limits on the number of visits in a given time.

Second, get and calculate data.

Step 1: Obtain basic data objects, account balances, and Boll indicator data for use in trading logic.

Third, order and follow-up

Step 1: Execute the buy/sell operation according to the above strategic logic. First determine whether the price and indicator conditions are satisfied, then determine whether the holding conditions are satisfied, and finally execute the trade () suborder function.Step 2: Once the order has been completed, it is necessary to deal with anomalies such as unfinished orders, holding a single contract and drawing a chart.

NO.8

We have created a simple strategy for a digital currency's long-term leverage, complete with over 200 lines of code.

NO.9

This strategy is just a throwing dice, the real one isn't that simple, but you can play with your imagination by using examples.

I need to remind you that, in my limited experience, in the current state of the digital currency market, it is basically not worth running a pure futures strategy, whether it is a risk-free triangle or a cross-market leverage.The reason is that the futures market of any digital currency exchange is not backed by fiat currency. Today, almost all digital currencies have fallen by about 70% since the beginning of the year. That is, the strategy has always been in the coin, but the price of the coin has fallen.

In a nutshell, the digital currency market has quietly moved away from blockchain, and like tulips in those days, prices always come from expectations and confidence, and confidence comes from price...

Read more:Blockchain Quantitative Investing series of courses ((1) - briefing Blockchain Quantitative Investing Series Courses ((2) - Understanding the digital currency Blockchain Quantitative Investing series of courses ((4) - Dynamic balancing strategies


More

bluemnLook closely, the coin is leveraged.