-
Notifications
You must be signed in to change notification settings - Fork 1
/
system_parameters.py
278 lines (259 loc) · 8.73 KB
/
system_parameters.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
"""
Definition of System Parameters, their types, and default values.
By using a dataclass to represent the System Parameters:
* We can use types for Python type hints
* Set default values
* Ensure that all System Parameters are initialized
"""
from typing import List, Dict, TypedDict
from QuantLib import GeometricBrownianMotionProcess
from model.entities.balance import Balance
from model.types.base import (
CryptoAsset,
Currency,
Fiat,
ImpactDelayType,
MarketPriceModel,
MentoExchange,
OracleType,
Stable,
TraderType,
)
from model.types.pair import Pair
from model.types.configs import (
MarketPriceConfig,
MentoExchangeConfig,
OracleConfig,
TraderConfig,
ImpactDelayConfig
)
from model.utils.rng_provider import RNGProvider
class Parameters(TypedDict):
"""
System Parameters as they are passed to a simulation run
after the parameter sweep.
Used as type annotation for functions that take params.
"""
rng_seed: int
rngp: RNGProvider
mento_exchanges_config: Dict[Stable, MentoExchangeConfig]
mento_exchanges_active: List[MentoExchange]
market_price_model: MarketPriceModel
market_price_processes: List[MarketPriceConfig]
market_price_correlation_matrix: List[List[float]]
average_daily_volume: Dict[Pair, float]
impact_delay: ImpactDelayConfig
impacted_assets: List[Pair]
variance_market_price: Dict[Currency, Dict[Fiat, float]]
traders: List[TraderConfig]
reserve_inventory: Dict[Currency, float]
reserve_target_weight: float
oracles: List[OracleConfig]
class InitParameters(TypedDict):
"""System Parameters
Each System Parameter is defined as:
system parameter key: system parameter type = default system parameter value
"""
rng_seed: List[int]
mento_exchanges_config: List[Dict[Stable, MentoExchangeConfig]]
mento_exchanges_active: List[List[MentoExchange]]
market_price_model: List[MarketPriceModel]
market_price_processes: List[List[MarketPriceConfig]]
market_price_correlation_matrix: List[List[List[float]]]
average_daily_volume: List[Dict[Pair, float]]
impact_delay: List[ImpactDelayConfig]
impacted_assets: List[List[Pair]]
variance_market_price: List[Dict[Currency, Dict[Fiat, float]]]
traders: List[List[TraderConfig]]
reserve_inventory: List[Dict[Currency, float]]
reserve_target_weight: List[float]
oracle_pairs: List[List[Pair]]
oracles: List[List[OracleConfig]]
parameters = InitParameters(
rng_seed=[1000],
# Configuration params for each stable's exchange
mento_exchanges_config=[{
MentoExchange.CUSD_CELO: MentoExchangeConfig(
reserve_asset=CryptoAsset.CELO,
stable=Stable.CUSD,
reference_fiat=Fiat.USD,
reserve_fraction=0.1,
spread=0.0025,
bucket_update_frequency_second=5*60,
max_sell_fraction_of_float=0.0001
),
MentoExchange.CEUR_CELO: MentoExchangeConfig(
reserve_asset=CryptoAsset.CELO,
stable=Stable.CEUR,
reference_fiat=Fiat.EUR,
reserve_fraction=0.1,
spread=0.0025,
bucket_update_frequency_second=5*60,
max_sell_fraction_of_float=0.0001
),
MentoExchange.CREAL_CELO: MentoExchangeConfig(
reserve_asset=CryptoAsset.CELO,
stable=Stable.CREAL,
reference_fiat=Fiat.BRL,
reserve_fraction=0.1,
spread=0.0025,
bucket_update_frequency_second=5*60,
max_sell_fraction_of_float=0.0001
),
}],
mento_exchanges_active=[[
MentoExchange.CUSD_CELO,
MentoExchange.CEUR_CELO,
MentoExchange.CREAL_CELO
]],
# Market parameters for MarketPriceGenerator
market_price_model=[MarketPriceModel.QUANTLIB],
# check order of parameters for each model, e.g. for GBM param_1 is drift and
# param_2 is volatility
market_price_processes=[
[
MarketPriceConfig(
pair=Pair(CryptoAsset.CELO, Fiat.USD),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=1,
),
MarketPriceConfig(
pair=Pair(CryptoAsset.CELO, Fiat.EUR),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=1,
),
MarketPriceConfig(
pair=Pair(CryptoAsset.CELO, Fiat.BRL),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=1,
),
MarketPriceConfig(
pair=Pair(CryptoAsset.BTC, Fiat.USD),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=0.1,
),
MarketPriceConfig(
pair=Pair(CryptoAsset.ETH, Fiat.USD),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=0.2,
),
MarketPriceConfig(
pair=Pair(CryptoAsset.DAI, Fiat.USD),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=0.001,
),
MarketPriceConfig(
pair=Pair(Stable.CUSD, Fiat.USD),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=0.01,
),
MarketPriceConfig(
pair=Pair(Stable.CEUR, Fiat.EUR),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=0.015,
),
MarketPriceConfig(
pair=Pair(Stable.CREAL, Fiat.BRL),
process=GeometricBrownianMotionProcess,
param_1=0,
param_2=0.02,
),
]
],
market_price_correlation_matrix=[
[
[1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1],
]
],
average_daily_volume=[{
Pair(CryptoAsset.CELO, Fiat.USD): 1000000,
Pair(CryptoAsset.CELO, Fiat.EUR): 1000000,
Pair(CryptoAsset.CELO, Fiat.BRL): 1000000,
Pair(Stable.CUSD, Fiat.USD): 1000000,
Pair(Stable.CEUR, Fiat.EUR): 1000000,
Pair(Stable.CREAL, Fiat.BRL): 1000000,
Pair(CryptoAsset.BTC, Fiat.USD): 1000000,
Pair(CryptoAsset.ETH, Fiat.USD): 1000000,
Pair(CryptoAsset.DAI, Fiat.USD): 1000000,
}],
impact_delay=[
ImpactDelayConfig(
model=ImpactDelayType.NBLOCKS,
param_1=10
)
],
impacted_assets=[[
Pair(CryptoAsset.CELO, Fiat.USD),
Pair(Stable.CUSD, Fiat.USD),
Pair(Stable.CEUR, Fiat.EUR),
Pair(Stable.CREAL, Fiat.BRL),
Pair(CryptoAsset.BTC, Fiat.USD),
Pair(CryptoAsset.ETH, Fiat.USD),
Pair(CryptoAsset.DAI, Fiat.USD),
]],
variance_market_price=[{
Pair(CryptoAsset.CELO, Fiat.USD): 1,
Pair(Stable.CUSD, Fiat.USD): 0.01,
Pair(Stable.CEUR, Fiat.EUR): 0.01,
Pair(Stable.CREAL, Fiat.BRL): 0.01,
Pair(CryptoAsset.BTC, Fiat.USD): 0.1,
Pair(CryptoAsset.ETH, Fiat.USD): 0.2,
Pair(CryptoAsset.DAI, Fiat.USD): 0.001,
}],
traders=[
[
TraderConfig(
trader_type=TraderType.ARBITRAGE_TRADER,
count=1,
balance=Balance({CryptoAsset.CELO: 500000, Stable.CUSD: 1000000}),
exchange=MentoExchange.CUSD_CELO
),
TraderConfig(
trader_type=TraderType.ARBITRAGE_TRADER,
count=2,
balance=Balance({CryptoAsset.CELO: 500000, Stable.CEUR: 1000000}),
exchange=MentoExchange.CEUR_CELO
),
]
],
reserve_inventory=[{
CryptoAsset.CELO: 10000000.0,
CryptoAsset.BTC: 1000.0,
CryptoAsset.ETH: 15000.0,
CryptoAsset.DAI: 80000000.0,
}],
reserve_target_weight=[0.5
],
oracle_pairs=[[
Pair(CryptoAsset.CELO, Fiat.USD),
Pair(CryptoAsset.CELO, Fiat.EUR),
Pair(CryptoAsset.CELO, Fiat.BRL),
]],
oracles=[
[
OracleConfig(count=1,
type=OracleType.SINGLE_SOURCE,
aggregation=None,
delay=10,
price_threshold=0.02,
reporting_interval=6,
),
]
]
)