Comments (7)
Well, it should in theory, but I took a different approach here in favor of efficiency...
The way this works now is that it resamples data to the strategy resolution on every new tick that is received, so if there's a 5 second gap between ticks, you won't get bar events during that time.
However, when the new tick is received the self.bars
/ instrument.bars
/ instrument.get_bars()
should get you the full bar history for every second - even if the quote has not changed.
The idea behind this decision was that if nothing's happening in the market, its likely that the strategy shouldn't take any action - but when something is happening (a tick received), you'll have access to the full data for calculating moving averages, etc.
I'm still thinking if there's an elegant way (or a reason) to have the bar event fire every second that doesn't involves without using threads and without putting unnecessary strain on the system.
from qtpylib.
Ok... couldn't help it :)
If you'll add "force_resolution" = True
to your strategy initializer, you'll get a bar every resolution
- regardless of whether or not new ticks were received.
Version 1.5.27 released.
from qtpylib.
Unfortunately it's still skipping beats with force_resolution=True
. I'll see if I can fix it.
$ python sec_test.py
bar 1478895960 2016-11-11 20:26:00
bar 1478895961 2016-11-11 20:26:01
bar 1478895962 2016-11-11 20:26:02
bar 1478895964 2016-11-11 20:26:04
bar 1478895965 2016-11-11 20:26:05
bar 1478895966 2016-11-11 20:26:06
bar 1478895967 2016-11-11 20:26:07
bar 1478895969 2016-11-11 20:26:09
bar 1478895970 2016-11-11 20:26:10
bar 1478895971 2016-11-11 20:26:11
bar 1478895973 2016-11-11 20:26:13
bar 1478895975 2016-11-11 20:26:15
bar 1478895976 2016-11-11 20:26:16
from qtpylib.
So I tracked the issue down to Algo._tick_handler()
; it's not a thread/timing issue, it's how _tick_handler
decides if it's got a new bar:
if len(bar.index) > self.tick_bar_count > 0:
self._bar_handler(bar)
Which I think is saying if this bar has more bars than the last bar, call the bar handler? I don't really understand this section, but len(bar.index)
and self.tick_bar_count
are often the same, so it doesn't fire a bar.
from qtpylib.
Hopefully fixed in v. 1.5.29
from qtpylib.
Thanks, much better. It still skips seconds after running for a while, but I can probably live with it.
from qtpylib.
I see the same issue. It skips seconds after running for a while.
from qtpylib.
Related Issues (20)
- [BUG] TypeError: unsupported operand type(s) for -: 'float' and 'str'
- [BUG] Find available cash and account value inside strategy. HOT 1
- Ujhj
- Dependabot couldn't authenticate with https://pypi.python.org/simple/
- [BUG] pip install error (different than issue #141) HOT 1
- How can I add an FX broker using MT4/5 platform?
- ATR differences with TradingView
- How to backtest options strategy? How to add options data to MySQL database from csv?
- How to "first cross"
- Documentation down HOT 1
- Cannot install from PYPI server HOT 3
- [BUG] HOT 1
- http://www.qtpylib.io/ not accessible - documentation offline ? [BUG] HOT 1
- Order book logging and back testing
- Increase the usage of augmented assignment statements
- Arguments Helps
- Fatal Errors during installation (after preparing isolated conda environment for pip installation) [BUG] HOT 2
- [BUG] No module named 'Queue' in ibpy2 dependency HOT 2
- [BUG] error: invalid path 'Icon?'
- [BUG] module 'pandas' has no attribute 'ewma'
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 qtpylib.