79203258

Date: 2024-11-19 11:40:23
Score: 0.5
Natty:
Report link

After taking a quick look at your code I found at least two possible causes of your issues.

  1. you want to trade BTCUSD but you set your capital to $1000. As you did not show a sample of the data you used, it might be possible that your strategy tries to buy btc but it cant because your account has not enough cash. Set your cash to higher amount and try again.
  2. this part of your function is not doing what you expect. :
def next(self):
    current_time = datetime.now()
    if current_time.weekday() >= 5:  # Skip weekends
        return

the datetime.now() function gives you the actual current date not the current date in your backtest. If you run your backtest on a weekend it will not even attempt to buy anything.

We could give you a better answer if you would have included a data sample and a sample log of your program. Maybe another look at documentation could help. DateTime Management

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: guest123