mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-21 07:48:06 +00:00
v4.0.6
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "aiomql"
|
name = "aiomql"
|
||||||
version = "4.0.5"
|
version = "4.0.6"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
classifiers = [
|
classifiers = [
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
from .core import *
|
from .core import *
|
||||||
from .lib import *
|
from .lib import *
|
||||||
from .contrib import *
|
from .contrib import *
|
||||||
|
from ._utils import *
|
||||||
|
|||||||
+22
-24
@@ -10,35 +10,33 @@ from .core.config import Config
|
|||||||
|
|
||||||
logger = getLogger(__name__)
|
logger = getLogger(__name__)
|
||||||
|
|
||||||
|
async def backtest_sleep(secs):
|
||||||
async def backtest_sleep(secs: float):
|
"""An async sleep function for use during backtesting."""
|
||||||
config = Config()
|
config = Config()
|
||||||
btc = config.backtest_controller
|
sleep = config.backtest_engine.cursor.time + secs
|
||||||
try:
|
while sleep > config.backtest_engine.cursor.time:
|
||||||
if btc.parties == 2:
|
await asyncio.sleep(0)
|
||||||
steps = int(secs) // config.backtest_engine.speed
|
|
||||||
steps = max(steps, 1)
|
|
||||||
config.backtest_engine.fast_forward(steps=steps)
|
|
||||||
btc.wait()
|
|
||||||
|
|
||||||
elif btc.parties > 2:
|
|
||||||
_time = config.backtest_engine.cursor.time + secs
|
|
||||||
while _time > config.backtest_engine.cursor.time:
|
|
||||||
btc.wait()
|
|
||||||
else:
|
|
||||||
btc.wait()
|
|
||||||
except Exception as err:
|
|
||||||
btc.wait()
|
|
||||||
logger.error("Error: %s in backtest_sleep", err)
|
|
||||||
|
|
||||||
|
|
||||||
# async def backtest_sleep(secs):
|
# async def backtest_sleep(secs: float):
|
||||||
# """An async sleep function for use during backtesting."""
|
|
||||||
# btc = BackTestController()
|
|
||||||
# config = Config()
|
# config = Config()
|
||||||
# sleep = config.backtest_engine.cursor.time + secs
|
# btc = config.backtest_controller
|
||||||
# while sleep > config.backtest_engine.cursor.time:
|
# try:
|
||||||
|
# if btc.parties == 2:
|
||||||
|
# steps = int(secs) // config.backtest_engine.speed
|
||||||
|
# steps = max(steps, 1)
|
||||||
|
# config.backtest_engine.fast_forward(steps=steps)
|
||||||
|
# btc.wait()
|
||||||
|
#
|
||||||
|
# elif btc.parties > 2:
|
||||||
|
# _time = config.backtest_engine.cursor.time + secs
|
||||||
|
# while _time > config.backtest_engine.cursor.time:
|
||||||
|
# btc.wait()
|
||||||
|
# else:
|
||||||
|
# btc.wait()
|
||||||
|
# except Exception as err:
|
||||||
# btc.wait()
|
# btc.wait()
|
||||||
|
# logger.error("Error: %s in backtest_sleep", err)
|
||||||
|
|
||||||
|
|
||||||
def dict_to_string(data: dict, multi=False) -> str:
|
def dict_to_string(data: dict, multi=False) -> str:
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from logging import getLogger
|
|||||||
from ..core.models import OrderSendResult, TradePosition
|
from ..core.models import OrderSendResult, TradePosition
|
||||||
from ..core.config import Config
|
from ..core.config import Config
|
||||||
from .positions import Positions
|
from .positions import Positions
|
||||||
from .._utils import backtest_sleep
|
|
||||||
|
|
||||||
logger = getLogger(__name__)
|
logger = getLogger(__name__)
|
||||||
|
|
||||||
@@ -26,13 +25,13 @@ def delta(obj: time) -> timedelta:
|
|||||||
return timedelta(hours=obj.hour, minutes=obj.minute, seconds=obj.second, microseconds=obj.microsecond)
|
return timedelta(hours=obj.hour, minutes=obj.minute, seconds=obj.second, microseconds=obj.microsecond)
|
||||||
|
|
||||||
|
|
||||||
# async def backtest_sleep(secs):
|
async def backtest_sleep(secs):
|
||||||
# """An async sleep function for use during backtesting."""
|
"""An async sleep function for use during backtesting."""
|
||||||
# btc = BackTestController()
|
config = Config()
|
||||||
# config = Config()
|
btc = config.backtest_controller
|
||||||
# sleep = config.backtest_engine.cursor.time + secs
|
sleep = config.backtest_engine.cursor.time + secs
|
||||||
# while sleep > config.backtest_engine.cursor.time:
|
while sleep > config.backtest_engine.cursor.time:
|
||||||
# btc.wait()
|
btc.wait()
|
||||||
|
|
||||||
|
|
||||||
class Session:
|
class Session:
|
||||||
|
|||||||
@@ -126,13 +126,14 @@ class Strategy(ABC):
|
|||||||
|
|
||||||
async def _backtest_sleep(self, *, secs: float):
|
async def _backtest_sleep(self, *, secs: float):
|
||||||
try:
|
try:
|
||||||
if self.backtest_controller.parties == 2:
|
# if self.backtest_controller.parties == 2:
|
||||||
steps = int(secs) // self.config.backtest_engine.speed
|
# this is not needed, as the backtest_engine iterator will handle this
|
||||||
steps = max(steps, 1)
|
# steps = int(secs) // self.config.backtest_engine.speed
|
||||||
self.config.backtest_engine.fast_forward(steps=steps)
|
# steps = max(steps, 1)
|
||||||
self.backtest_controller.wait()
|
# self.config.backtest_engine.fast_forward(steps=steps)
|
||||||
|
# self.backtest_controller.wait()
|
||||||
|
|
||||||
elif self.backtest_controller.parties > 2:
|
if self.backtest_controller.parties >= 2:
|
||||||
_time = self.config.backtest_engine.cursor.time + secs
|
_time = self.config.backtest_engine.cursor.time + secs
|
||||||
while _time > self.config.backtest_engine.cursor.time:
|
while _time > self.config.backtest_engine.cursor.time:
|
||||||
self.backtest_controller.wait()
|
self.backtest_controller.wait()
|
||||||
|
|||||||
Reference in New Issue
Block a user