Read the original:Blockchain Quantitative Investing Series Course ((3)) - cross-term leverage
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.
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.
So, 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 leverage. As with commodity futures, digital currencies also have a portfolio of related long-term leverage contracts. For example, on the OkEX exchange there are: ETC that week, ETC next week, ETC quarterly.
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.
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 developing leverage trading strategies through quantitative models, as well as programmatic algorithms that automatically place trading orders on exchanges, quickly and accurately capture opportunities and efficiently and steadily earn returns, is the appeal of quantitative 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, which can be used to capture momentary leverage opportunities, capture visible profits at every turn, and hedge potential risks.
Creating a digital currency cross-currency strategy Difficulty: Average
The strategic environment: - Trade mark: Ethereum Classic and ETC - Price difference data: ETC in the same week - ETC quarter (except for the co-integration check) - Trade cycle: five minutes. - Match the positions one to one. - Type of transaction: cross-section of the same variety
The strategic logic: - Opening conditions: If the current account is not held, and the price is less than the boll down-track, then the price is overbought, i.e.: buy ETC for the week, sell ETC for the quarter. - Opening condition: If the current account does not hold stock and the price is higher than the boll, then open the position; i.e. sell ETC for the week and buy ETC for the quarter. - Make a spread: If the current account holds ETC on a weekly basis, and holds ETC on a quarterly basis, and the spread is greater than the boll mid-range, then the spread is flat. That is, sell ETC on a weekly basis, buy ETC on a quarterly basis. - To make a spread settlement condition: If the current account holds ETC in the weekly spread, and holds several ETC orders in the quarter, and the spread is less than boll in the middle of the track, then the spread settlement condition is: buy ETC in the weekly spread, sell ETC in the quarterly spread.
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.
Next, we need to fill in the necessary detail code in the strategy framework based on the actual transaction process and transaction details.
Step 1: Declare the necessary global variables in the global environment.
Step 2: External parameters of the configuration policy. 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 falseK-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 graphDrawing Chart ()) 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 be traded on exchange.IO () - Chart drawn before the program starts ObjChart.reset () - Status bar information before the program is started LogProfitReset ()
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.
Step 1: Obtain basic data objects, account balances, and Boll indicator data for use in trading logic.
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 pending orders, holding a single contract and drawing up a chart.
We have created a simple strategy for a digital currency's long-term leverage, complete with over 200 lines of code.
### No. 9 This is just a trick, but the real thing is not 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.
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
bluemnLook closely, the coin is leveraged.