Script to generate random transactions
This commit is contained in:
parent
7f23c5f8a7
commit
852dedfc0c
25
api/generate_sample_transactions.py
Normal file
25
api/generate_sample_transactions.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
import faker
|
||||||
|
import requests
|
||||||
|
|
||||||
|
url = 'http://127.0.0.1:5000/api'
|
||||||
|
username = ''
|
||||||
|
password = ''
|
||||||
|
|
||||||
|
shares = ["TWTR", "GOOG", "AAPL", "MSFT", "AMZN", "FB", "NFLX", "TSLA", "BABA", "BA", "BAC", "C", "CAT", "CSCO", "CVX", "DIS", "DOW", "DUK", "GE", "HD", "IBM" "INTC", "JNJ", "JPM", "KO",
|
||||||
|
"MCD", "MMM", "MRK", "NKE", "PFE", "PG", "T", "UNH", "UTX", "V", "VZ", "WMT", "XOM", "YHOO", "ZTS"]
|
||||||
|
|
||||||
|
fake = faker.Faker()
|
||||||
|
|
||||||
|
token = requests.post(url + '/user/login', json={"email": username, "password": password}).json()['data']['token']
|
||||||
|
|
||||||
|
for i in range(1, 1000):
|
||||||
|
payload = {
|
||||||
|
"count": random.randint(1, 100),
|
||||||
|
"price": random.random() * 100,
|
||||||
|
"symbol": shares[random.randint(0, len(shares) - 1)],
|
||||||
|
"time": fake.date_time().isoformat() + ".000Z"
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.post(url + '/transaction', json=payload, headers={'Authorization': 'Bearer ' + token})
|
@ -10,4 +10,5 @@ flask-cors==3.0.10
|
|||||||
bcrypt==3.2.0
|
bcrypt==3.2.0
|
||||||
pytest~=7.1.1
|
pytest~=7.1.1
|
||||||
pytest-cov
|
pytest-cov
|
||||||
marshmallow~=3.15.0
|
marshmallow~=3.15.0
|
||||||
|
faker~=4.0.0
|
Loading…
Reference in New Issue
Block a user