2022 Meisai Title C translation + idea sharing

MCM-C: Trading strategy (ideas in the back)

background

Market traders frequently buy and sell volatile assets with the goal of maximizing their total returns. There is usually a commission on each sale. Two such assets are gold and Bitcoin.

Figure 1: Gold daily price in USD per troy ounce. Source: London Bullion Market Association, 11 September 2021

Figure 2: Bitcoin daily price in USD per Bitcoin. Source: Nasdaq, September 11, 2021

Require

A trader asks you to develop a model that uses only the daily price stream to date to determine whether a trader should buy, hold or sell an asset in his portfolio on a daily basis

On September 11, 2016, you will start with $1000. You will use a five-year trading period, from September 11, 2016 to September 10, 2021. On each trading day, the trader will have a portfolio consisting of cash, gold and bitcoin [C, G, B] in dollars, troy ounces and bitcoin, respectively. The initial state is [1000, 0, 0]. The commission cost per transaction (purchase or sale) is the transaction amount. Assume αgold = 1% and αbitcoin = 2%. There is no cost to hold an asset.

Note that Bitcoin can be traded on a daily basis, but Gold is only traded on market open days, the pricing data files reflect both LBMA-GOLD.csv and BCHAIN-MKPRU.csv, your model should take this trading schedule into account.

To develop a model, you can only use data from the two spreadsheets provided: LBMA-GOLD.csv and BCHAIN-MKPRU.csv. (Official website provides download)

• Develop a model that provides the best daily trading strategy to that day based only on price data. How much is the model and strategy worth using your initial $1000 investment on September 10, 2021?

• Provide evidence that your model provides the best strategy.

• Determine how sensitive the strategy is to transaction costs. How do transaction costs affect strategies and outcomes?

• Communicate your strategies, models and results to traders in a maximum of one memo (two pages)

Thought analysis

This topic is the establishment of a portfolio model, which mainly includes two processes of forecasting and planning:

1. We need to predict each price series to determine when the asset should be sold to obtain a return based on future price fluctuations;

2. Establish a target plan, take the weight of gold (gold transaction amount) or the weight of bitcoin (bitcoin transaction amount) as the unknown parameter, the objective function will get the largest report in a certain period of holding the asset, so as to search for it. get better parameters.

We can make decisions (buy or sell or hold) for these three trading activities based on forecasting future trends.

First, forecasting the price of gold and bitcoin can optionally be run using various machine learning regressions.

Here, for example, the sliding window-xgboost is used for prediction, that is, the price data of the first 5 days is used to predict the price of the next day. (Take gold price forecast as an example)

Tools used: SPSSPRO (all functions are free, unlimited times and unlimited time)

https://www.spsspro.com/?utm_source=CSDN

Step 1  Upload data

Step 2  Null value handling

In fact, 10 data with missing values ​​were eliminated.

Step 3  : Process the data so that the time series is converted into the price data of the first 5 days as the independent variable, and the price data of the next day as the dependent variable.

Step 4  Then run xgboost to make predictions, and use genetic algorithm to optimize the learning rate and regular term parameters.

The model is complex and takes a long time to run, please be patient!

result

Step 5 After making the prediction, we need to get a buy-sell-hold trading strategy, in which gold is only traded on the opening day, which means that on weekends or holidays, the trading status must be held, and gold can be reserved separately. and Bitcoin's common trading day data for analysis. Assuming that gold and bitcoin are bought and sold at the same time, the main design is a time series data such as a rate of return. For example, we can buy on any day, we can use (predict the price of gold on a certain day/purchase The actual price of gold -1) to get the yield, when the increase reaches a certain value, it is recommended to sell.

Note: The initial state is [1000, 0, 0], and the transaction cost of each transaction (buy or sell) is a% of the transaction amount, including 1% for gold and 2% for Bitcoin, then, for $1,000, There are two steps to buy and sell. We recommend that the actual transaction amount be reserved at 960 US dollars and 40 US dollars as the transaction cost.

Establish simple target planning:   \Deltat is the period from buying to selling

Since buy-sell is ongoing, we need to create a loop to run it.

In order to achieve more perfect results and be more realistic, financial risk analysis can be added, similar to VaR, CVaR, or the use of information entropy. After establishing a perfect investment model, we can use it to optimize the algorithm to adjust the weights. For optimization, such as particle swarm method, genetic algorithm, immune algorithm, etc.

Guess you like

Origin blog.csdn.net/weixin_51952869/article/details/123000213