Refactor trading logic to use MAX_TRADES constant for trade limit

This commit is contained in:
Nawaz Haider
2026-01-01 22:30:32 +06:00
parent 051070ebdd
commit d5ec01ffd9
2 changed files with 4 additions and 2 deletions
+1
View File
@@ -8,3 +8,4 @@ PROFIT_MARGIN = 0.02
TRADING_BPS_THRESHOLD = 50
MARKET_SESSION_SECONDS = 900
TIMEZONE = "US/Eastern"
MAX_TRADES = 1
+3 -2
View File
@@ -11,6 +11,7 @@ from utils.clob_client_and_order import (
cache_tocken_trading_infos,
)
from utils.cpu_affinity import set_cpu_affinity
from config import MAX_TRADES
gc.disable()
@@ -25,7 +26,6 @@ requests.options = session.options
async def main():
max_trades = 1
trades = 0
logger = setup_logging()
@@ -59,6 +59,7 @@ async def main():
logger.info("Trading session ended. Starting new session.")
gc.collect()
await asyncio.sleep(10)
trades = 0
up_token, down_token, market_slug = await fetch_tokens()
book = OrderBook(up_token, down_token, market_slug)
asyncio.create_task(cache_tocken_trading_infos(client, book))
@@ -77,7 +78,7 @@ async def main():
down_ask_price = 1 - up_bid_price
down_bid_price = 1 - up_ask_price
if trades < max_trades:
if trades < MAX_TRADES:
trading_side = book.last_signal
if trading_side == SIGNALES.UP: