If you manage to get a meaningful data feed, you can always compare the datetime and if it's a match you sell if the name starts with - and otherwise buy.
Your best bet is to transform the list to match the format in the blog post linked above (Evaluating External Historical Performance)
@ab_trader said in Need help to get started with pre-made signal:
Your prices are around 6000-10000, your cash is 10000. How can you expect to buy 100 of shares in this case? Only 1 fits.
Top. I had this in mind and was completely taken off course by the chart.
Because the markers and the data are located very close to each other and where the first operations would have taken place, which also raised the question: how were the buy and sell issued on the same day? (the code didn't allow that)
Hi. I wrote an example strategy for you. You can access the indicator lines through the name in __init__ method.
params = (
self.stoch = StochasticRSI(k_period=self.p.stoch_k_period,
if not self.position:
close = self.data.close
price1 = close
price2 = price1 - self.p.stop_loss * close
price3 = price1 + self.p.take_profit * close
if self.stoch.l.fastk < 20:
self.buy_bracket(price=price1, stopprice=price2, limitprice=price3, exectype=bt.Order.Limit)
if self.stoch.l.fastk > 80:
self.sell_bracket(price=price1, stopprice=price3, limitprice=price2, exectype=bt.Order.Limit)
you haven't answered the question, which was a question related to the comment you made
I am sorry.
As you will understand from my other recent posts, I am a beginner in backtrader, so I can only be imprecise.
Intended code modifications & additions are basically of the same type than the ones highlighted in Dave Vallance's fork
ccxtbroker.py, ccxtstore.py ccxtfeed.py
listed in README.md
Regarding RACI part, yes, you're completely right, this is a topic that needs to be clarified.
I fully agree with what you expose, and have actually already encountered once these questions after a submission I made once (fortran scientific code - clearly not python :))
If it can be addressed thanks to a crowdfunding approach, this is great.
Thank you for your answer, and hope it can turn in a positive answer.
For other readers, it would be nice to know how many would feel like to contribute some funds, so that everybody has an idea of what amount needs be invested in an effort to even overall the expense (no need to clearly state how much you can afford).
If we do be many, this will also demonstrate that the preliminary task of quantifying the development work (if crowdfunding is accepted by @backtrader) is not made in vain.
@moontrader : thanks to have dropped a word, this is very positive
Thanks again @backtrader & @moontrader ,
Have a good day.
Your paper trading account uses the same data permissions as your standard account. It won't simply use your real money. You still need permissions.
If you have an Interactive Brokers account you should familiarize yourself with what the DOs and DONTs are.
As an alternative you can use the faux data demo, but it won't be any good to test any algorithm because the data is completely fake (even in the demo, you cannot use each and every ticker. The forex tickers tend to work most of the time)
There isn't enough information to even attempt anything. For example: the only provided output is from the modified source, without having the actual command line execution
As such one can only try to point the low hanging fruits. One would be:
Are you pointing to the right port? (usually 7496 for production and 7497 for paper trading)
The default port used by the sample and the IB ecosystem is 7496.
You quote above the following command:
./ibtest.py --data0 EUR.USD-CASH-IDEALPRO --resample --timeframe Minutes --compression 1
and this is theoretically working with the demo. But the demo also runs (default, can be of course be changed) on port 7497.
Cash Products like EUR.USD-CASH-IDEALPRO are allowed (afaik) to all IB customers (as long as your account is funded I think). Whether demo, paper trading or real account, that product is available for everyone. And the code (which relies on IBPy for interfacing to TWS) doesn't know what it is connecting to. The account type is controlled by the TWS (or IbGateway) instance you connect to.
Such calculation is probably what's already being done: the unleveraged value.
The idea seems to be to swap the current value with the current unleveraged value, so that the actual value curve doesn't spike. The leveraged value would still be accessible.
It makes sense
@steffen Is there a quantitative trading platform support the new python3 tws api? I'm looking for something could backtest and trade using Interactive Brokers, just like the BackTrader, but the ibpy is too old to use.
The idea of capturing your own ticks is in theory sound, but has always practical problems. And that's why companies that collect and curate data make money out of it.
Collecting ticks or minute bars or anything else with backtrader is just a python statement away (see for example the trace that run with 2 instruments collecting 1-minute bars during approximately 35 minutes)
The data points could have been stored somewhere (hierarchically or not) instead of simply having printed them out.
Thank you for the post! Currently I am looking on the testing couple ideas for american futures. The way that I think to go forward is to use back-adjusted prices and have continuous contacts. I've checked Quandl already and their continuous contracts are not suitable for me. I was thinking to chain data series based on max volume to match reality, so in the continuous contract I have prices only from the months with max volumes, but Quandl just chains contracts based on expiration months.
backtrader makes continuous contracts based on certain conditions (date and volume), but does not shift prices. As a result you will have gaps between contracts. So to make this shift ones need to re-write bt rollover method or just write a strategy which will make it and save prices into csv files. I am not a super-python guy, so I will probably go second way.
I don't think that adjusted prices in the past will harm the tests. I am going to use dollar value stats, no % stats. Also trades price delta will be the same as for real prices.
@RandyT said in v1.x -Quick Roadmap:
To achieve this,
AcountManager(based Acount LEVEL)/Order and Position Tracker & Recovery(based Engine LEVEL)/Strategy Position Manager(based Strategy LEVEL)
just like IB:
Thanks @backtrader, yes I understand the definition of prenext() as your quotes above show.. but they don't show how to use it to manage differing timeframes :-)
The sample code looks like it is useful though! It appears all I need after all is this?!