Comments (3)
There's no strategy initialization in your code, and there's also a ]
at the beginning on the instrument=...
line. Does it also exist on the code you're running?
Please try running this code and let me know what's the output?
class TestStrategy(Algo):
def on_start(self):
pass
def on_tick(self, instrument):
print(".", end="")
def on_bar(self, instrument):
bar = instrument.get_bar()
print("\n ==> BAR:", bar)
if __name__ == "__main__":
strategy = TestStrategy(
instruments = [ "AAPL" ],
resolution = "1T" # 1Min bar resolution (Pandas "resample" resolutions)
)
strategy.run()
from qtpylib.
Hi Ran. I ran the example you gave.
python print_data.py
Server Version: 76
TWS Time at connection:20161202 16:42:58 CST
^C......................................................................................................................................................................................................................................................................................................................................
No output. The blotter is working. If I change the 1T to 1K, it works fine.
Another observation that might be related to this issue: I run this code
class TestStrategy(Algo):
def on_start(self):
pass
def on_tick(self, instrument):
print(".", end="")
def on_bar(self, instrument):
print(">", end="")
if __name__ == "__main__":
strategy = TestStrategy(instruments = [ "AAPL" ], resolution = "1K")
strategy.run()
One interesting observation is that nothing was printed until I pressed Ctrl+C. Then all the > and . result appeared. Second observation was that even with sampling K, on_tick is called twice as many as on_bar, which is not as I expected (the frequencies to be same, right?):
python print_data.py
Server Version: 76
TWS Time at connection:20161202 17:15:58 CST
^C.>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>.
>>> Interrupted with Ctrl-c...
It is like there is buffering happening and it is dumped when you terminate the process.
from qtpylib.
When printing with the end=""
parameter, you should add flush=True
to have it actually printing... :)
This should work:
from qtpylib.algo import Algo
class TestStrategy(Algo):
def on_start(self):
pass
def on_tick(self, instrument):
print(".", end="", flush=True)
def on_bar(self, instrument):
print(">", end="", flush=True)
if __name__ == "__main__":
strategy = TestStrategy(instruments = [ "AAPL" ], resolution = "1K")
strategy.run()
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.