From b4cf0a2e71ad2c204925b33f9600dc720e25b827 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Sun, 09 Jan 2022 23:22:58 +0000
Subject: [PATCH] Initial shift to rapidjson
---
test.py | 41 +++++++++++++++++++++++------------------
1 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/test.py b/test.py
index 788ceff..76de53f 100644
--- a/test.py
+++ b/test.py
@@ -1,5 +1,4 @@
""".#test.py main module."""
-import json
import time
import httpx
from whereismysock import all
@@ -7,21 +6,18 @@
import book
import protocol
+test = False
+
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():
"""Test function to print websocket."""
messages = all(f"ws://{HOST}:{PORT}/information")
@@ -44,9 +40,11 @@
for message in so_far_today:
protocol.handleMessage(bs, message)
-
-message = {"type": "ADD", "product": "F_SOH_APP0104T1700", "price": 99.0,
- "side": "BUY", "volume": 1000000}
+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)
# print(json.dumps(message))
# print(send(message))
# printRecoveryLog()
@@ -56,8 +54,15 @@
bs = {}
# recoverBook(bs)
-# print(list(bs))
-# for i in bs:
- # print(bs[i].product)
- # bs[i].printBook()
-book.testBook()
+testRecoverBook(bs)
+print(list(bs))
+for i in bs:
+ 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()
--
Gitblit v1.10.0