This commit is contained in:
2025-09-30 14:15:21 +05:30
parent 0a146c2169
commit c21ec7ba42
8 changed files with 326 additions and 1160 deletions
+46 -2
View File
@@ -50,6 +50,9 @@ from utils_v2.date_time import date_time
# To work with date and time:
import datetime
# For randomization:
import random
# *****************************************************************************************************************
# ***** ****
@@ -172,7 +175,7 @@ class TradingTick(BaseModel):
frozen = True
)
broker: Literal["zerodhaKite", "iciciBreeze"] = Field(
broker: Literal["dummy", "zerodhaKite", "iciciBreeze"] = Field(
description = "the broker that gave you the details of this instrument",
frozen = True
)
@@ -461,6 +464,48 @@ class TradingTick(BaseModel):
# Done here:
return modelled_ticks
@staticmethod
def dummy_tick(symbol: str = "TCAOFF"):
ltp = 1_250 * random.uniform(0.95, 1.05)
now_utc = date_time.get_current_utc_date_time().timestamp()
return TradingTick(
symbol = symbol,
name = symbol,
exchange = "NSE",
exchangeToken = "999999",
broker = "dummy",
brokerToken = 999999,
tradeable = False,
segment = "NSE",
type = "EQ",
strike = 0,
expiryTs = None,
expiryTz = None,
prevClose = 99,
ltp = ltp,
qty = int(1_000 * random.uniform(0, 1)),
chg = 123,
pChg = 1,
o = 1_200,
h = 1_300,
l = 1_100,
c = ltp,
totVol = 4810200 * random.uniform(0.95, 1.05),
vwap = None,
totBuyQty = None,
totSellQty = None,
oi = None,
oiDayHigh = None,
oiDayLow = None,
rcvdTs = now_utc,
tradeTs = now_utc,
tradeTz = "Asia/Kolkata",
exchgTs = now_utc,
exchgTz = "Asia/Kolkata",
depth = None
)
@staticmethod
def time_setter(item):
if not item.get("expiryTs"):
@@ -506,7 +551,6 @@ class TradingTick(BaseModel):
return redis_key
# ┓┏ ┓• ┓ •
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗