Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Data-driven Business and Behavioural Analytics 2023/24

Assignment 2

We will discuss this assignment in class on Tuesday, November 7th

Submitting Instructions

For this coursework, you will be asked to develop an agent-based model and report and analyse the results you get from it. The ABM must be coded in Python. You can either use a notebook or an IDE of your choice, but you must submit all your code in a single zip file (even if it is just one python file, this must be zipped). You also must submit a pdf in which you report the results and discuss them. Submission will be available on Learn.

Introduction

This assignment is inspired by the work of Cocco, Tonneli, and Marchesi1 and requires you to simulate the trading of the GBP vs. Bitcoin currency pair. You can use any library you want, and any resource you want, but everything you use must be appropriately referenced. The main goal of this coursework is to make sure you know how to develop an ABM for a real-world financial scenario.

We recommend you familiarise yourself with the aforementioned article, and especially the introduction, which will give you context for this assignment. However, you will need to develop agents and conduct analysis different from the one in the article.

Additionally, keep in mind that you can use any research result or dataset (Google Scholar is your friend!) to model the agents, estimate parameters, and to validate your model.

Task 1 – Build the Agents

Initially, all agents in this model hold both fiat currency (GBP) and Bitcoin. To represent real-life scenarios, every 90 days 60% new Bitcoin enter the market and those are assigned to a random group of agents, giving them an amount of Bitcoins proportional to those already owned following the Gibrat principle of preferential attachment (richer gets richer).

Task 1.1 – Building the Chartists Agents (15 marks)

The Chartists try to make a profit in the fiat currency (GBP) by buying and selling Bitcoin. They trade following a set of rules defined below, i.e. they enter the market (open a position) following the opening rules and exit the market (close a position), following the closing rules. They can only open a new position if they have closed their previous position.

We have two rules for opening and closing a positions:

Opening & Closing position rules:

• Rule 1 – Filtering. Check the Bitcoin price today compared to the average price in the past n days. If the price today is lower than average price in the past n days, open a position. If you opened a position in the past n days and the price is higher today, close that position.

• Rule 2 – Exponential Moving Average (EMA). We calculate the EMA according to the following formula:

where Closet is the closing price at period t and n is a number of periods to take into account. If the close price is higher than EMA(n), then open a position. If the close price is lower than EMA(n) for an open position, close it.

We define 4 subtypes of Chartists agents based on how much they value each rule for open-ing and closing a position. We have two levels of rule importance – a rule can be of low importance (accounts for 20% of decision) or high importance (accounts for 80% of decision), keeping in mind that the importance might differ for the same rule based on whether it is used for opening or closing a position. Construct all 4 subtypes of Chartists agents based on the possible rule importance combinations. All these are the same type of agent with just different values for rule importance.

Discuss the behaviour you expect from these agents. Explain any modifications or additions you have made. Which subtype of Chartists do you expect to perform best? Why?

Task 1.2 – Building the Random Traders (5 marks)

Random traders do not need seek to generate profit from the exchange. They enter the mar-ket for different reasons (e.g. to diversify their portfolio) and they open and close positions with the same probability, according to their available crypto and fiat currency.

Discuss the behaviour you expect from the random traders. How would they trade in the market compared to the Chartists?

Task 1.3 – Create a Market Environment (10 marks)

Create the market environment where the agents would trade with each other. Explain any assumption you make. As for the price update function, use the following market response to the agents’ trading as defined by Petrov 2 :

where rn(∆Nn) is the price change at the step n, α = √ 2/2 is the parameter limiting the minimum price shift, sgn(.) is the sign function, and ⌊.⌋ is the floor function.

Task 2 – Comparing Agents

Task 2.1 – Run the Model (10 marks)

Run the model you created for the period between January 1, 2020 and October 31, 2023. Vary the parameter n within a range you choose (motivating your choice) and discuss the changes in the behaviour of the agents.

Task 2.2 – Compare Agents (10 marks)

Compare how the agents (including random traders) perform in the following aspects:

• ratio between GBP and Bitcoin held

• total wealth acquisition (GBP plus Bitcoin)

• number of opened positions

Discuss your results. How do the different subtypes of Chartists compare? What about random traders? Did you expect the results you obtained? Why?

Task 3 – Model Validation

Task 3.1 – Wealth Acquisition (10 marks)

Validate your model using the results by Cocco, Tonneli, and Marchesi or any other resource you like. Compare the Bitcoin, GBP, and total wealth acquisition of your agents vs the types of agents in Cocco, Tonneli, and Marchesi. Discuss the differences between your results and those in the literature.

Task 3.2 – Price Change (5 marks)

Discuss the change of price over the period. Compare the prices you obtain with those in the article and the real-world values. Compare the results from your model with at least one stylised fact of Bitcoin price time series (remember to cite the source!). Why do you think the prices in your model do (or do not) match published results?

Task 4 – Cyberattack on Bitcoin (10 marks)

Imagine a hacking group is planning a cyberattack on Bitcoin on December 1, 2023. They would hack the accounts of 40% of the traders(agents), selling all their Bitcoin, and blocking their accounts. How would the remaining agents react to this change? Evaluate the behavior of the different agents and comment on the changes you observe. Which agents adapt the best to sudden changes like this cyberattack?

Task 5 – Propose a New Agent Class

Task 5.1 – Design a New Agent Class (10 marks)

Design a new agent class in this model based on news, research articles, or other resources you might find useful. To fully define this new agent class take into account the four steps for agent design we have seen in class.

Task 5.2 – Discuss How Your Agent Performs (5 marks)

Discuss how your new agent class compares to the subtypes of Chartists and the random traders in the cyberattack scenario. Comment on the advantages and disadvantages of your agent. Do you think this is a good agent to represent actual traders? Why?

Task 6 – Result Discussion (10 marks)

Write a short report (≈ 250 words) summarising your observations. This report should include any limitations of the ABM you created (anything you think affected your results), performance of different agents, any improvements you can think of, etc.