-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathNoiseTrader.cpp
More file actions
76 lines (67 loc) · 1.79 KB
/
Copy pathNoiseTrader.cpp
File metadata and controls
76 lines (67 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "Market.h"
#include "OrderBook.h"
#include "Distribution.h"
#include "NoiseTrader.h"
#include <cmath>
#include <iostream>
NoiseTrader::NoiseTrader(
Market * a_market,
Distribution * a_ActionTimeDistribution,
Distribution * a_OrderTypeDistribution,
Distribution * a_OrderVolumeDistribution,
double a_buyFrequency,
int a_favouriteStockIdentifier
):Agent(a_market,NOISE_TRADER, a_favouriteStockIdentifier)
{
m_ActionTimeDistribution = a_ActionTimeDistribution ;
m_OrderTypeDistribution = a_OrderTypeDistribution ;
m_OrderVolumeDistribution = a_OrderVolumeDistribution ;
m_buyFrequency = a_buyFrequency;
m_sellFrequency = 1.0 - m_buyFrequency;
}
NoiseTrader::~NoiseTrader()
{
}
double NoiseTrader::getNextActionTime() const
{
return m_ActionTimeDistribution->nextRandom() ;
}
OrderType NoiseTrader::getOrderType() const
{
if(m_OrderTypeDistribution->nextRandom()<m_buyFrequency)
{
// std::cout << "MARKET_BUY " << std::endl ;
return MARKET_BUY ;
}
else
{
// std::cout << "MARKET_SELL " << std::endl ;
return MARKET_SELL ;
}
}
int NoiseTrader::getOrderVolume() const
{
// std::cout<<"market volume simulated"<<std::endl;
return (int)m_OrderVolumeDistribution->nextRandom();
}
void NoiseTrader::makeAction(int a_OrderBookId, double a_currentTime)
{
OrderType thisOrderType = getOrderType() ;
int thisOrderVolume = getOrderVolume() ;
submitOrder(
a_OrderBookId, a_currentTime,
thisOrderVolume,
thisOrderType
) ;
}
void NoiseTrader::processInformation()
{
// For exemple, read the market book history and decide to do something within a reaction time
}
int NoiseTrader::getOrderPrice (int a_OrderBookId, OrderType a_OrderType) const
{
return -1;// A noise trader does not specify a price
}
void NoiseTrader::submitCancellation(int a_OrderBookId,bool a_cancelBuy) const
{
}