In this part, we will analyse correlations between the variables used to model the MarketPlace simulator. First, we will import the figures generated by Matlab when the P2P_EXCRATE.m function located in the /Source_Code directory is executed. Then, we will continue by further analysing the data generated TradeLog_all.csv.
This notebook is structured as:
1. How do traders choose their exchange rate?
2. Comparing the IBR with the best available rate over time
3. How long it takes a matching event for a given ER?
4. Results and discussion
In [89]:
import graphlab
data_rolled = graphlab.SFrame.read_csv('Source_Code/data_and_graphics/TradeLog_relinfo.csv');
data_all = graphlab.SFrame.read_csv('Source_Code/data_and_graphics/TradeLog_all.csv');
In [90]:
# Summary of the data. Here each entry corresponds to a unique user
data_rolled
Out[90]:
In [91]:
# Summary of the data. Here each entry corresponds to a unique tradeLog of total or partial matching event
data_all
Out[91]:
a) IBR: as discussed in Part 1 of this project, one of the first things that we need to define to create the MarketPlace simulator is a model for the IBR. Here I assume that IBR follows a Brownian motion type of curve. This is a reasonable model that is usually used in "real life" data.
b) Behavior of other users: there will be several traders coming on both sides of the MarketPlace (Euro side and GBP side) each of them with their own exchange rate. The simulator sort all the traders by their exchange rate and add up the amount of cash for each exchange rate. Therefore in the queue system, each exchange rate seen corresponds to several traders. This is shown in the Fig below.
- The exchange rates on both sides of the market are sorted and positioned with respect to the IBR. The distribution shows how the exchange rates of the traders are chosen, i.e., followin a random distribution (either normal or lognormal) with average 0.5% above the IBR (for selling side) and the equivalent (since the buying side exchange rate is 1/GBP) is true for the buying side. This is to show that most of the traders would like to have a deal that pays better than the IBR.
- In other words, traders on the selling side who order high exchange rates are the greedy ones and on the buying side, the ones who order very low exchange rate are also the greedy ones but on the Euro side.
- There is a cutof at 0.5% below the IBR (for the selling side) ad the equivalent for the buying side. This means that any trader who comes and places an order with exchange rate below 0.5% the IBR, the system automatically will match the trader. Therefore, none of them will get a deal worse than 0.5% below the IBR.
In [92]:
from IPython.display import Image
Image(filename='Extra_graphics/selling_and_buying_cartoon.png')
Out[92]:
The next cartoon shows the allowed matching events between traders on both sides of the market. The process starts with lowest exchange rates on both sides as represented by the arrows. For instance, the traders on the GBP market with exchange rate 1.2620 will have priority to match the traders on the Euro market with 1.2760. Master Note: the rate 1.2760 means that this is the exchange rate that the buying side (Euro market) is willing to pay and the rate 1.2630 is the rate that the selling side (GBP market) is willing to sell. Therfore, the rate of 1.2760 from the point of view of a trader in the GBP market that initially ordered 1.2620 is a great deal because he will sell his GBP for a higher price. The same is true for the trader in the Euro side, he is willing to pay 1.2760 but he will pay only 1.2620.
When the amount of cash of 1.2760 ends, the next best available will be 1.2700. With this, the traders will have opportunity to get equal or better rates than they have ordered.
In [93]:
Image(filename='Extra_graphics/matching_events_cartoon.png')
Out[93]:
When the overlaping exchange rates are all matched, there will be a gap and no matching events can occur, thus the next time spet in the simulation is called. This is ilustrated in the cartoon below.
In [94]:
Image(filename='Extra_graphics/no_matching_events_cartoon.png')
Out[94]:
In the picture below, I show the time series for the IBR with the best available rate on both sides of the market where the sampling of exchange rates for the traders is chosen following a normal distribution. As we can see, when the market is in favor of the GBP, i.e., GBP_to_Euro exchange rate is increasing, the best available in the GPB follows the trend whereas the best available in the Euro market goes down.
In [95]:
Image(filename='Source_Code/data_and_graphics/fig1.png')
Out[95]:
In the following, we show some plots for using the dayX_relinfo.csv, ie, the rolled up partial matching events for each user in a single matching event. Therefore, the matching rate for a user will be the average rate for all his partial matching weighted by the amount of cash on each partial matching, W-avgMatched. The avgIBR is the the average of the IBR over the time that it took to complete the full matching of the total cash of a particular trader. The color code is time difference between the time the trader left the system (had his matching completed) and the time he entered the system.
Similar plots for the dayX_allinfo.csv, ie, the data without aggregation per each trader.
In [96]:
Image(filename='Source_Code/data_and_graphics/avgrate_avgIBR_timeDiff.png')
Out[96]:
In [97]:
Image(filename='Source_Code/data_and_graphics/rates_IBR_timeDiff.png')
Out[97]:
In [98]:
Image(filename='Source_Code/data_and_graphics/cash_amount_effect.png')
Out[98]: