Tuesday, 27 August 2019

'Buy Low Sell High' 2019 Melbourne Datathon - INTRODUCTION


"Buy Low - Sell High"


2019



 






Scenario


You are a trader for a pension fund that makes money for it's investors by constantly buying and selling financial instruments such as shares in companies, foreign currencies or futures contracts. The general idea is that you aim to buy when the price is low and sell when it is high, hence making a profit.

Traditionally you'd stare at the live prices on a screen and through your experience know exactly when to trade. Recently your company has employed a team of machine learning experts to predict if prices are going up or down so as to hopefully remove the guess work form your trading decisions.

Every 5 minutes you are now receiving 14 different predictions from mathematical models. What they forgot to tell you is how to actually use those predictions. 

The challenge is to figure out how to use these predictions to determine trading decisions. The winner of the challenge will be the 'trader' who's 'strategy' makes the most money.





The Data


You have been provided with over 12 months of actual prices and predictions of future price movements at 5 minute intervals for some crypto-currency pairs. This is the data you will use to develop your 'trading strategy'.

Additionally you have also been provided with just the predictions (no prices) for some further currency pairs over the same time period. This is the data on which you will apply your strategy to come up with some 'buy' and 'sell' times that determine a 'trade'.

These times will be submitted and the returns calculated.




What does a 'strategy' look like?


A trading strategy uses only the predictions to make 'entry' and 'exit' trading decisions. It can be very simple logic or sophisticated logic - it is the challenge to come up with that logic. 

e.g
If prediction4 > 0.4 & prediction7 > 0.2  then 'Enter Long' (buy)
If prediction4 < 0.3 & prediction7 < 0.2 then 'Exit Long' (sell)

Code for an example strategy will be supplied




What does a Submission look like?


You will be submitting a file with 6 columns. Each row of the file will be a trade that will have it's return calculated.
  





keys_pair:   the pair to trade 
enterTime:  the time to enter the trade
exitTime:     the time to exit the trade
direction:     are we going long (1) or short (0)  
percentPair : what percent of the 'pair balance' do we want to put on this trade
strategyName: what are you calling this strategy (for reference)

The times we supply are just integers which represent 'minutes from start', hence no need to mess around with time stamps.

Direction means are we predicting the price will go up ('going long') or down ('short selling').

percentPair is the percent of the pair 'balance' that we want to put on each trade. There can be multiple trades for a single pair that overlap in time, but the sum of percentPair for that time stamp cannot be more than 1 (for each direction - see below*). 


Long and Short?


It's possible to still make money if we think the price is going down, which is called 'short selling'. This is how it's done,

Say X are 10 shares in IBM and we think the share price is dropping.

Rather than buy X, we borrow X from a stockbroker and immediately sell it on the stock exchange. When the price drops we buy X back from the exchange and return X to the stockbroker. We have made a profit as we sold X for more than we bought it back. We would pay the stockbroker 'interest' out of our profit.

'going long' is simpler as we expect the price to go up, so the stockbroker does not need to be involved. We simple 'buy low and sell high' directly from the stock exchange.

*For this exercise, Long and Short trade directions are evaluated separately, which means you will get a total return for long trades and a total return for short trades. Each submitted trades file can contain just longs, just shorts, or both longs and shorts. 




How is the Strategy Evaluated?


The general idea of how the strategies are evaluated are it is just a sum of the individual percentage gains of each trade. There is no re-investment of any profit.

  1. for each trade we determine the enter (EN) and exit (EX) prices
     
  2. the enter and exit prices are adjusted for the trading fee percentage (F), and then the trade percentage gain (TPG) calculated as a percentage of the entry price

    long: ( (EX*(1-F)) - (EN*(1+F)) )/ EN

    short: ( (EN*(1-F)) - (EX*(1+F)) )/ EN
     
  3. The percent weighting is applied
    TPG = TPG * percentPair
     
  4. TPG is capped
     
  5. It is determined if a stoploss has occurred
     
  6.  TPG  then summed over all trades to give a total return


Fees?


There is a cost associated with each trade made, called the fee. This means that we don't quite get the actual price price as the exchange takes their cut. When we want to buy, we pay slightly more, and when we want to sell we get slightly less. The fee is applied to the price on entering and exiting a trade.

Hence when we make a trade, we need to be confident the returns will cover the fees we are charged. For this exercise, the fee F = 0.15%.

Capping?


We need to have confidence that the return of each strategy is not influenced by one or two 'lucky' large trades. To do this we take all raw TPGs and calculate the mean (M) and standard deviation (SD) of these individual gains. Any trade that has a return greater than M + (2*SD) or less than M - (2*SD) is capped at that value. This has the effect of removing extreme values. 

Stop Losses?


If the price goes too far in the wrong direction then a 'stop loss' will be executed for that trade. For example, if we are 'going long' (hoping the price will go up) but the price falls by more than X% before the trade exit time is reached, then the trade will be immediately exited for you. This trade will use the price at the time the stop loss was triggered to calculate the trade returns.

For this exercise the stop loss value is 5%

Are there any other trade restrictions?


trade length


A 'dumb' strategy would just be to do a single trade for each currency pair that lasts the whole of the time period and guess if you think think it should be a long (price going up) or a short (price going down). Such a strategy might end up making a profit but it would be just guessing and not using the predictions. To prevent this, any trades that are longer than 4 days (60 x 24 x 4 minutes) in length will be eliminated.


number of trades


It's also possible if you think the predictions are no good to just submit zero trades and have a return of 0, hoping everyone else's strategy loses money. Hence all currency pairs must have at least 5 trades each.



How do we Submit our Trades?


Once you have created a trades file, you will upload it via our web portal. Each team can only upload 1 file every 6 hours, so be prudent. Each file can only contain 1 long strategy and 1 short strategy. Make sure your file names for each submission are different and that each strategy has a different name.

Several times a day we will calculate the returns and display them along with other metrics on the leader board.

You must submit trades for all the pairs in the data set. These will be divided into 3 groups and returns calculated for each group. 

  1. Train group - these are the currency pairs that have real names and prices. Use this set to make sure your calculations of the returns match ours.
     
  2. Public group - this will be a subset of the remaining currency pairs (which have masked names and no prices). You will be able to see the returns for these pairs.
     
  3. Private group - the remaining currency pairs. You won't be able to see the returns until the competition is over.

Who Wins?


In order to win there are several criteria:
  1. The top 3 teams whose combined best long and best short returns on the private group exceed those of the benchmark solution will be qualify for the next stage.
     
  2. We will then release a further data set. We will need to witness your code crunching this new data to generate the predictions file.

    Note: we don't need the code itself or the logic - that is your IP. We just need to see stuff happening to make sure there has been no dodgy business occurring!
     
  3. It is the returns on this set that will determine the grand champion, so long as they still beat the benchmark solution

What do we Win?


There will be a cash prize for the top 3 teams beating the benchmark solution. Any team or individual may be asked to come and develop their strategy for a real trading company, so there is a good chance that this could lead to a job and wealth directly correlated to the performance of your solution!


Skills, Team size etc...


In order to do well in this challenge, you must have a couple of skills;

  1. the ability to think logically to come up with ideas
     
  2. the ability to write code to test those ideas
It will not be advantageous to form teams from the start. The benefit of team forming will come later on when you want to combine ideas.


Can you tell us more about the predictions?


There are 14 predictions for each currency pair for each time stamp. The predictions are weakly correlated to the actual percentage change in price at some point in the future. Prediction1 is the shortest term prediction (1 hour ahead) and prediction14 is a longest term prediction (96 hours ahead), with the remaining being sequential in their prediction horizon.

The predictions are simulated but do represent what can be achieved. We cannot divulge any further information about the predictions.


Where is the Data?


See our next post for information on the data and some sample code. 

8 comments:

  1. "We will then release a further data set. We will need to witness your code crunching this new data to generate the predictions file."

    Does this mean that the new data will be of a different time period? Meaning that the "minutesSinceStart" variable will not be comparable across the given dataset for training and the new dataset at the end?

    ReplyDelete
  2. Correct. You should not use the absolute value of minutesSinceStart in your model. Only use it for relative time differences between records. The new data will still be at 5 minute intervals.

    ReplyDelete
  3. Thank you for the clarification. One final question if I may:

    "There can be multiple trades for a single pair that overlap in time, but the sum of percentPair for that time stamp cannot be more than 1"

    Given that the long strategy and short strategy are independent of one another, does this mean you could have both a long trade open and a short trade open at the same time, where they both use 100% of the account balance?

    ReplyDelete
    Replies
    1. This is correct. Longs and Shorts are evaluated completely independently.

      Delete
  4. "Prediction1 is the shortest term prediction (1 hour ahead) and prediction14 is a longest term prediction (96 hours ahead), with the remaining being sequential in their prediction horizon."

    Are the remaining 12 predictions equally spaced in time between 1 hour and 96 hours?

    ReplyDelete
    Replies
    1. On top of the same page its written "Every 5 minutes you are now receiving 14 different predictions from mathematical models. What they forgot to tell you is how to actually use those predictions"

      On FAQ

      "Prediction1 is the shortest term prediction (1 hour ahead) and prediction14 is a longest term prediction (96 hours ahead), with the remaining being sequential in their prediction horizon."

      Are above both statements defining predictions same? 5 minutes or prediction1 for 1 hour and prediction14 for 96 hours

      Delete