Testing with BTC #1291
Unanswered
xXwHiteHatHackerXx
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey! This is my first time using Github so I might have chosed the wrong option to ask the question however:
I have built a code that calculate btc forecast and i really want to use backtesting.py to test its accuracy.
Im using Google Gemini to guide me since im new to coding and python in general.
Im reciving nice win rate on my code but im getting some wierd error message:
lib/python3.10/site-packages/backtesting/backtesting.py:954: UserWarning: time=3871: Broker canceled the relative-sized order due to insufficient margin.
I have tried to change cash up to 1.000.000 USD but that dosen't feel realtistic since btc has never been over 117k USD. According to Gemini this could be the problem:
Trade Size (Order Size)
Whole Bitcoin vs. Fractional Trading: As the previous warning indicated, the backtesting library does not support fractional trading by default. This means that if your strategy attempts to buy "1 Bitcoin" (i.e., a whole unit) when the price is $70,000, you need at least $70,000 in capital. If your strategy attempts to buy "2 Bitcoins" simultaneously, you would need $140,000.
Strategy Logic: The problem might lie in how your strategy (MyCandleStrategy) defines the size of its buy and sell orders. If your strategy attempts to buy a fixed quantity (e.g., always 1 BTC or 0.5 BTC) or a relative size based on a percentage of your available capital, problems can still arise:
But what I dont understand is why am I getting this? Dosen't backtesting.py support BTC? Thanks and sorry again if i missplaced this question.
Beta Was this translation helpful? Give feedback.
All reactions