@Eduardo-De-La-Garza said in How to handle repeated code in next and prenext?:
From what I understand that would overload the function and the parent code wouldn't run.
inside of MyBaseStrat
then overwrite next2 for your strategy specific functionality
@Yulem said in Final SELL order not created in Quickstart Examples:
I believe the logic is to generate a SELL using the final day's CLOSE value which makes sense and is what I saw in the previous examples. What am I missing???
In the Quickstart guide examples there is no logic to close the position at the end of the backtest.
@hghhgghdf-dfdf said in Final SELL order not created in Quickstart Examples:
If you want to generate a sell specifically using the final day's close value, you can do so in the strategy's stop method
I didn't try this by myself, but based on the bt workflow I doubt that this will work, since stop is called after all the bars are gone and it should be no price to execute the order.
I'm exactly looking for something like this, i must say it looks surprising.
I merge historical data with livedata from a websocket to another dataframe.
This dataframe should then be displayed in a live chart.
However i wonder how to get started on this.
A little bit more information on how to use this would be very nice :D
Thanks in advance and thanks for your work
In my strategy, in the notify_timer method, I need
self.datetime.date(0), which gives an error because of the above problem. That is, at the first bar, len(self) is 0, which result in an error when using self.datetime.date(0).
Any help is apperaciated.
@arikenig The problem for using delayed data is that reqMarketDataType is NOT called, and that it should be called before subscribing to a delayed data feed.
If you have a live account, it is much much simpler to run your paper TWS (or gateway) on the same machine. Just take care to point to the paper TWS ! (port)
It is strange that you still have an error when both your live and paper account run on the same computer.
Do you also have on your live account delayed data for the instrument you try to trade on your paper account ?
Have you parametrized data feed sharing from your live toward your paper account ? This is something you have to setup. From the previous given IBKR.info link :
"2. Market data mirroring and sharing user selection
On the Client Portal, those functions are present in the section: Settings -> Account Settings -> Configure (gear) icon"
If you still have delayed data in your paper account, you will notice it in the API logs (you have to search the item in the TWS menu to display them, they are something like encrypted on disk)
Please create a regular PR in the main Backtrader GitHub repository: https://github.com/mementum/backtrader
It would be great if the test could be provided validating the fix. Ideally the test should fail before and pass after applying the fix :-).
Thanks for sharing.
As a side note:
suggest to take a look at the discussion in the PR I was posting above (https://github.com/mementum/backtrader/pull/393).
There are several issues in this PR that were reviewed/fixed that your code may benefit from as well.
@vladisld said in IB feeds question:
@chewbacca said in IB feeds question:
Does BT have to be restarted before each market open, or are there other options (i.e. running BT continuously) ?
Also BT could be run continuously, both TWS and TWS Gateway need to be restarted daily (https://financefeeds.com/interactive-brokers-adds-auto-restart-feature-tws-platform/) even with auto-restart feature enabled. It means all the data subscriptions need to be renewed anyway.
IMHO it is easier ( and cheaper if you run in cloud) to start/shutdown the system on (extended) trading session start/end every day. If in cloud - it even could be easily done using scheduling APIs.
It's not in the cloud, it's in a local VM, and I know that restarting the bot is easier, however, I was looking for a solution that would allow me to run the bot continuously.
Actually I've found a very nice function that will probably work - backwards() @ linebuffer.py
Placed it @ log_data called in each next()/notify_timer() with the current day's date, so if a bar enters data1 - it should remove it.
So, now waiting for live data to see what'd happen :)