Forums  > Trading  > Blockchain Quantitative Investment Series Course (3) - Intertemporal Arbitrage  
     
Page 1 of 1
Display using:  

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-20 04:00
NO.1

In the book "Financial Alchemy" written by Soros in 1987, an important proposition was put forward: I believe the market prices are always wrong in the sense that they present a biased view of the future.

The market validity hypothesis is only a theoretical assumption. In fact, market participants are not always rational, and at each point of time, participants cannot fully acquire and objectively interpret all information. Even if it is the same information, everyone's feedback is different.

In other words, the price itself already contains the wrong expectations of market participants, so in essence the market price is always wrong. This may be the source of profit for the arbitrageurs.

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-20 04:01
NO.2

Based on the above principles, we also know that in a non-effective futures market, the market impact of delivery contracts in different periods is not always synchronized, and the pricing is not the reason of completely effective.

Then, based on the price of the delivery contract at different times of the same transaction target, if there is a large spread between the two prices, it is possible to simultaneously trade futures contracts of different periods and carry out intertemporal arbitrage.

Like commodity futures, digital currencies also have an intertemporal arbitrage contract portfolio associated with them. For example, in the OkEX exchange: ETC week, ETC next week, ETC quarter.

For example, suppose the spread between ETC week and ETC quarter is maintained at around 5 for a long time. If the spread reaches 7, we expect the spread to return to 5 at some time in the future. Then you can sell the ETC week and buy the ETC quarter to short the spread. vice versa.

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-20 04:01
NO.3

Although this spread exists, there are often many uncertainties in manual arbitrage due to the time-consuming, poorly accurate of manual operations and price-changing effects.

Through the quantitative model to capture arbitrage opportunities and develop arbitrage trading strategies, as well as programmatic algorithms automatically release trading orders to the exchange, to quickly and accurately capture opportunities and efficiently earn income, which is the charm of quantitative arbitrage.

This article will teach you how to use FMZ quantitative trading platform and the ETC futures contract in the OkEX exchange in digital currency trading, with a simple arbitrage strategy to demonstrate how to capture the instantaneous arbitrage opportunities, and seize every visible profit while simultaneously hedging the risks that may be encountered.

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-20 04:02
NO.4

Create a digital currency intertemporal arbitrage strategy

Difficulty: ordinary level

Strategic environment:

Transaction target: Ethereum (ETC)

Spread data: ETC weekly - ETC quarterly

Trading period: 5 minutes

Position match: 1:1

Transaction type: same variety intertemporal

Strategy logic:

Buying-long spread position conditions: If the current account has no positions, and the spread is less than the down trail of boll indicator, place a spread order, which is: buying long ETC weekly, selling short ETC quarterly.

Short-selling spread position conditions: If the current account has no positions and the spread is higher than the up rail of boll indicator, place a spread order, which is: selling short ETC weekly, buying long ETC quarterly.

Closing the buying-long spread position condition: If the current account holds a long ETC weekly position and holds a short ETC quarterly position, and the spread is higher than the middle rail of boll indicator, place a close spread order, which is: selling ETC weekly, buy to cover the ETC quarterly.

Closing the Short-selling spread position condition: If the current account holds a short ETC weekly position and holds a long ETC quarterly position, and the spread is lower than the middle rail of boll indicator, place a close spread order, which is: buy to cover the ETC weekly, selling ETC quarterly.

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-20 04:06
total 9 parts, please keep following, I will update soon.

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

deeds


Total Posts: 405
Joined: Dec 2008
 
Posted: 2018-08-20 13:29
Hi @RubyYao, thanks so much for sharing.

What is this "right" and "wrong" of which you speak?

Seems likely you have heard the following attributed to the professionals Schilling and/or Keynes: "The market can remain irrational longer than you can remain solvent."

Kind of related to another concept of Soros - reflexivity (reflexiveness?)

Are these factors considered in the strategy you outline?

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-21 12:24
NO.5

The above is a simple description of digital currency intertemporal arbitrage strategy logic, then how to implement your own ideas in the program? We tried to build the framework first on FMZ quantitative trading platform.

Strategy framework:


The strategy framework can be easily built up according to the strategic thinking and transaction process. The entire strategy can be simplified into three steps:

1. Pre-processing before transaction.

2. Get and calculate data.

3. Place an order and follow up.

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-21 12:25
NO.6
Next, we need to fill in the necessary details in the strategy framework based on the actual transaction process and transaction details.

First, pre-processing before transaction
Step 1: In the global environment, declare the necessary global variables.
Declare a chart object that configures the chart
Var chart = { }
Call the Chart function to initialize the chart
Var ObjChart = Chart ( chart )
Declare an empty array to store the spread sequence
Var bars = [ ]
Declare a timestamp variable that records historical data
Var oldTime = 0
Step 2: Configure external parameters for the strategy.

Step 3: Define the data processing function
Basic data function: Data ( )
Create a constructor Data and define its internal properties, including: account data, position data, K-line data timestamp, the latest buying/selling price of arbitrage contract A/B, positive/reverse arbitrage spread

Get the position function: mp ( )
Check through the entire array of positions, return the specified contract and the number of positions in the specified direction. Return false if there is none.

K line and indicator function: boll ( )
Synthesize a new K-line sequence based on the data of positive/reverse arbitrage spread. And return the up/middle/down rail data calculated by the boll indicator.
Order function: trade ( )
Insert the order contract name and trade type, then place the order in the latest buying/selling price and return the result after placing the order. Since it is necessary to simultaneously order two different directions of orders, the latest buying/selling price are converted within the function according to the order contract name.

Cancel order function: cancelOrders ( )
Get array of all pending orders and cancel them one by one. And if there is pending order, return false, and if there is none, return true.

Process holding single contract: isEven ( )
In the case of single-leg situation in the arbitrage trading, it is directly handled by simply closing all the positions. Of course, you can also change into chasing price.

Drawing chart function: drawingChart ( )
Call ObjChart.add ( ) method to draw the necessary market data and indicator data in the chart: up, middle, down rail, positive/reverse arbitrage spread.

Step 4: In the entry function main ( ), execute the pre-processing code before transaction, which only run once after the program starts, including:

filter the information that is not very important in the console SetErrorFilter ( )
Set the digital currency type to be traded exchange.IO ( )
Empty the drawn charts before the program starts ObjChart.reset ( )
Empty the status bar information before the program starts LogProfitReset ( )

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-21 12:25
NO.7
After defining the above pre-processing before transaction, it is necessary to proceed to the next step, enter the polling mode, and repeat the onTick ( ) function.
And set the sleep time when polling, because some of the digital currency exchange's API has a built-in access limit for a certain period of time.

Second, get and calculate data
Step 1: Get the underlying data object, account balance and boll indicator data for trading logic.

Third, place an order and follow-up
Step 1: Perform the buying and selling operation according to the above strategy logic. First, see if the price and indicator conditions are true, and then see if the position conditions are true, and finally execute the trade ( ) order function.

Step 2: After placing order, it is necessary to deal with abnormal situations such as pending orders and holding single contract, and draw charts.

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-21 12:26
NO.8
Above, we have created a simple digital currency intertemporal arbitrage strategy through more than 200 lines. The complete code is as follows:

NO.9
This strategy just serves as a trigger. The real market is not that simple, but you can use this example to play with your imagination.

What needs to be reminded is that, based on my limited experience, the pure period arbitrage strategy is basically not worth running in the current digital currency market situation, whether it is risk-free triangle arbitrage or cross-market arbitrage.

The reason is that no matter in which digital currency exchange's futures market, the margin is not fiat. Almost all digital currencies have fallen by about 70% since the beginning of the year. In other words, the strategy is always making currency, but the price of the currency is falling.

Take a broad view, the digital currency market has already left the blockchain. Just like the tulips then, the price always comes from people's expectations and confidence, and the confidence comes from the price...

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-21 12:28
visit this to get pics:https:https://fmzquant.quora.com/Blockchain-Quantitative-Investment-Series-Course-3-Intertemporal-Arbitrage

visit this to get complete code:https://www.fmz.com/strategy/104964

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-21 12:37
thanks for your reply.
the price itself already contains the wrong expectations of market participants, so in essence the market price is always wrong.
yes, they are.

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

deeds


Total Posts: 405
Joined: Dec 2008
 
Posted: 2018-08-21 12:45
Hi RubyYao

"the price itself already contains the wrong expectations of market participants, so in essence the market price is always wrong."

if market participants always trade the wrong price, how does it help to know the right price? (if the markets stay irrational, how does it help to be rational)

It would seem that, to profit from mis-pricing, some force needs to correct the market price after a position is acquired. (e.g. a tearful Ackman presentation?)

How does the general framework you have set out address that?

d


RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-23 06:19
I think market is about people. I cannot control everyone's thinking right or wrong, I naturally think it's wrongBlush rational is not my thing
Maybe I can write strategy but I am not a good teacher
Cry

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

deeds


Total Posts: 405
Joined: Dec 2008
 
Posted: 2018-08-23 20:10
Thanks for the response @RubyYao. Indeed, you can write strategy.

I look forward to pictures of your yacht.

d

gmetric_Flow


Total Posts: 7
Joined: Oct 2016
 
Posted: 2018-08-23 20:11
I'm slightly confused. Let's assume that the market price is inherently wrong (due to the expectations and biases of participants). Now we have a magical box which gives us the "right" price.If this right price is the one towards which the corrective forces of the market will move, then we are money and I really want one of these boxes. In the case that this price is somehow intrinsically correct, then it is kind of useless as we have no guarantee that the irrational actors will recognize this.

However, let's suppose we are in the first case, then our strategy (with its own biases and assumptions) will give us a target price. Now as the corrective forces move towards this price, wouldn't the market actors (who are always wrong by assumption) which are following the trend mean that the trend is wrong and therefore our pricing is wrong as well. We can probably take some philosophical duct-tape and fix this logic, but I have a hard time seeing how the math would work here.

deeds


Total Posts: 405
Joined: Dec 2008
 
Posted: 2018-08-23 20:20
@gmetric_Flow i think the issue is the fundamental logic of the 'strategy' rather than the math, compounded by the aspirational nonsense of always and everywhere...even a stopped clock is right twice a day.

gmetric_Flow


Total Posts: 7
Joined: Oct 2016
 
Posted: 2018-08-23 20:37
@deeds- I thought always and everywhere are "always" good assumptions. The strat sounds like a fairytale method which rides momentum and manages to always stay ahead of everyone and everything. But who knows?

deeds


Total Posts: 405
Joined: Dec 2008
 
Posted: 2018-08-23 22:31
Edit: corrected double post

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-29 05:07
thanks.
I wish I have a yacht one dayBig Smile

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-08-29 05:11
I am sharing more strategy writing on FMZ Quant: www.fmz.com, also on https://fmzquant.quora.com/ , https://t.me/fmzquant

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-09-11 04:38
Chew

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

RubyYao


Total Posts: 49
Joined: Aug 2018
 
Posted: 2018-09-30 04:00
Great news!!! Chug Beer
FMZ Quant has bagan a service for strategies writing.
Not matter you are an amateur or skilled programmer, if you have the idea that you want to deploy in the market, just tell us, and we will write it for you.
We have a programming team that has over 20 years of coding experience.
No matter how complicated your trading strategy is, as long as it can be quantified, we will make it happen. And you will also get the source code of your strategy, and you can check it through how we’ve done our job. The price is depending on your strategy’s complexity.
CoolFeel free to contact us if you are interested. Also, please tell you friends about our new promotion, especially those has great strategy but poor programming skill.
By the way, the strategy we write for you, the copyright totally belongs to you.
ApplauseApplause

Quantitative trading platform: www.fmz.com Turn your trading idea into code.

nikol


Total Posts: 553
Joined: Jun 2005
 
Posted: 2018-10-21 09:17
> For example, suppose the spread between ETC week and ETC quarter is maintained at around 5 for a long time.

This is bet on rising market, isn't it. Why do we need so much complexity?
Previous Thread :: Next Thread 
Page 1 of 1