Fix Redis, begin implementing MEXC

This commit is contained in:
2024-11-16 17:31:43 +00:00
parent 95a4a6930c
commit 761b084704
13 changed files with 524 additions and 109 deletions

View File

@@ -23,15 +23,16 @@ def initialise_elasticsearch():
def store_msg(index, msg):
global client
if not client:
client = initialise_elasticsearch()
if "ts" not in msg:
msg["ts"] = datetime.utcnow().isoformat()
try:
result = client.index(index=index, body=msg)
except ConnectionError as e:
log.error(f"Error indexing '{msg}': {e}")
return
if not result["result"] == "created":
log.error(f"Indexing of '{msg}' failed: {result}")
return
# global client
# if not client:
# client = initialise_elasticsearch()
# if "ts" not in msg:
# msg["ts"] = datetime.utcnow().isoformat()
# try:
# result = client.index(index=index, body=msg)
# except ConnectionError as e:
# log.error(f"Error indexing '{msg}': {e}")
# return
# if not result["result"] == "created":
# log.error(f"Indexing of '{msg}' failed: {result}")

View File

@@ -1,7 +1,8 @@
from decimal import Decimal as D
from typing import Optional
from pydantic import BaseModel
from typing import Optional
class PositionLong(BaseModel):
units: str
@@ -373,7 +374,9 @@ class Instrument(BaseModel):
guaranteedStopLossOrderMode: str
tags: list[InstrumentTag]
financing: InstrumentFinancing
guaranteedStopLossOrderLevelRestriction: Optional[InstrumentGuaranteedRestriction] = None
guaranteedStopLossOrderLevelRestriction: Optional[
InstrumentGuaranteedRestriction
] = None
class AccountInstruments(BaseModel):