Comments (10)
Hi @Pirat83,
Thank you for pointing this out. Yes, I can add an option that allows between_time to be a tuple of time objects so that timezone information is preserved.
from pybroker.
Hi @Pirat83,
Sorry for the delay. I am looking at this now.
I am not able to reproduce the issue you are having. Could you provide sample code here? Also, which OS and version of Pandas are you using? I noticed that timezone conversion seems to work differently on Windows in Pandas.
FWIW, the between_time parameter ends up using Panda's between_time method to filter dates.
from pybroker.
Hi @edtechre, I am using Linux and Pandas < 2.0.0. So I think it is the latest 1.x.y version.
from pybroker.
Thank you @Pirat83. That is the same as my setup. Can you provide me with sample code?
from pybroker.
Hi @edtechre, Yes of course.
from pybroker.
Hi @Pirat83,
Let me know if this is still an issue.
from pybroker.
Oh sorry. I will provide the code this week or close the ticket.
from pybroker.
Hi @edtechre - I have added some example code to https://github.com/Pirat83/pybroker-experiments/tree/issue-69-and-51
from pybroker.
So one of the main challenges is that pybroker dropps the timezone and then continues working with datetime
without timezones.
datetime
s are still in the US/Eastern timezone even if the timezone is not present any more. If someone want's to filter for some candles then ´datetime´s need to be used without timezone but they must match the US/Eastern timezone.
Since:
result: TestResult = self.backtest(
self.start_date_time, self.end_date_time, self.time_frame, ('9:30', '16:00'),
[Day.MON, Day.TUES, Day.WEDS, Day.THURS, Day.FRI]
)
can not be used if start_date_time
and end_date_time
additional filtering needs to be introduded in _weitght
and _execute
like this:
result: TestResult = self.backtest(
timeframe=self.time_frame, between_time=('9:30', '16:00'),
days=[Day.MON, Day.TUES, Day.WEDS, Day.THURS, Day.FRI]
)
Please correct me if I am wrong. Thank you very much or did not understand somehting correctly.
Thank you very much for your time and work.
from pybroker.
Hi @Pirat83,
Sorry for the late response. The timezone information is dropped in order to support filtering backtest data by the start/end date arguments, because those are datetime objects without timezone information. This happens independently of filtering with between_time
.
Note, filtering with between_time
uses Pandas' between_time filtering.
I would suggest performing any filtering on your DataFrame before executing your backtest on it. This can be done by querying your DataSource for the DataFrame, and then passing the modified DataFrame as your DataSource to the Strategy. See this notebook for an example.
If that is not enough, then I suggest assuming that you are dealing with times that have been normalized to US/Eastern, as you mentioned.
from pybroker.
Related Issues (20)
- Multi-timeframe? HOT 2
- Indicator might be wrong when applying filter on backtesting data HOT 2
- Add MAE (Maximum Adverse Excursion) and MFE (Maximum Favorable Excursion) metrics. HOT 1
- Add regular defined contribution to portfolio HOT 1
- Add Ruff for Python linter and code formatter HOT 3
- Real-time question HOT 1
- The feature names should match those that were passed during fit HOT 6
- [Feature] Add support for Schwab HOT 1
- 设置了ctx.score的值后,买入的具体原则是怎样的,这个ctx.score具体作用和影响是什么呢 HOT 1
- How to set a different ctx.sell_fill_price HOT 1
- Walkforward questions HOT 1
- Question from the Rebalancing example HOT 1
- About update numpy to 2.0 HOT 4
- Can ctx.score work with ctx.sell_shares? HOT 1
- 有考虑接入okx biance的数据么 HOT 1
- Add config option to save stop values in TestResult HOT 1
- caching data bug in month or week frequence HOT 2
- AKShare got an unexpected keyword argument 'timeframe' HOT 3
- Rotational Trading not working when using start_of_month HOT 1
- [Question] symbol for indicator but not for trading HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pybroker.