| | |
| | | """.#test.py main module.""" |
| | | import json |
| | | import time |
| | | import httpx |
| | | from whereismysock import all |
| | |
| | | import book |
| | | import protocol |
| | | |
| | | test = True |
| | | |
| | | HOST: str = 'sytev070' |
| | | PORT: str = '9000' |
| | | if (test): |
| | | PORT: str = '9005' |
| | | else: |
| | | PORT: str = '9000' |
| | | |
| | | USER: str = 'test' |
| | | PASS: str = 'none' |
| | | |
| | | |
| | | def send(message): |
| | | """Send message to exchange.""" |
| | | return httpx.post(f"http://{HOST}:{PORT}/execution", |
| | | data={"message": json.dumps(message), |
| | | "username": USER, |
| | | "password": PASS}).json() |
| | | |
| | | |
| | | def logAllIncomingMessages(): |
| | |
| | | for message in so_far_today: |
| | | protocol.handleMessage(bs, message) |
| | | |
| | | def testRecoverBook(bs: {str, book.Book}): |
| | | f = open("data.test", "r"); |
| | | so_far_today = f.read(); |
| | | for message in so_far_today: |
| | | protocol.handleMessage(bs, message) |
| | | |
| | | message = {"type": "ADD", "product": "F_SOH_APP0104T1700", "price": 99.0, |
| | | "side": "BUY", "volume": 1000000} |
| | | |
| | | message = {"type": "ADD", "product": "F_THS_APP0119T2230", "price": 99.0, |
| | | "side": "BUY", "volume": 1} |
| | | |
| | | # print(json.dumps(message)) |
| | | # print(send(message)) |
| | | print(protocol.send(message)) |
| | | # printRecoveryLog() |
| | | # logAllIncomingMessages() |
| | | # print(getInformation()) |
| | | # wstest() |
| | | |
| | | bs = {} |
| | | # bs = {} |
| | | # recoverBook(bs) |
| | | # testRecoverBook(bs) |
| | | # print(list(bs)) |
| | | # for i in bs: |
| | | # print(bs[i].product) |
| | | # bs[i].printBook() |
| | | book.testBook() |
| | | # print(bs[i].product) |
| | | # bs[i].printBook() |
| | | # print() |
| | | # if (len(bs[i].askSide.levels) > 0): |
| | | # print(bs[i].askSide.levels[0]) |
| | | # if (len(bs[i].bidSide.levels)): |
| | | # print(bs[i].bidSide.levels[0]) |
| | | # print() |
| | | # book.testBook() |