-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-payload.py
37 lines (32 loc) · 1.13 KB
/
gen-payload.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
#!/usr/bin/env python
from faker import Faker
import json
fake = Faker()
def gen_payload():
tradeId=fake.pyint(100000,999999)
tradeDate=fake.date(pattern="%Y-%m-%d")
notional=fake.pyint(1,1000000)
accountNumber=fake.pystr_format()
trader=fake.pystr_format(string_format='????######')
currencyPair=fake.random_element(elements=('EURUSD', 'USDJPY', 'GBPUSD', 'USDCHF', 'EURGBP', 'EURJPY', 'EURCHF', 'AUDUSD', 'USDCAD'))
buySell=fake.random_element(elements=('BUY', 'SELL'))
counterparty=fake.company()
rate=fake.pyfloat(positive=True, min_value=0.5, max_value=3.5)
status=fake.random_element(elements=('NEW', 'UPDATE', 'CANCEL'))
# Convert to a JSON string.
return {
"tradeId": tradeId,
"tradeDate": tradeDate,
"notional": notional,
"accountNumber": accountNumber,
"trader": trader,
"currencyPair": currencyPair,
"buySell": buySell,
"counterparty": counterparty,
"rate": rate,
"status": status
}
if __name__ == "__main__":
# Convert map to JSON string.
payload = gen_payload()
print(json.dumps(payload))