Comments (8)
Why not using ?
timestamp = event.timestamp
from qstrader.
This is here:
from qstrader.
This was a bit of a quick "hack" by me just to get the date in there for backtesting. I think we'll need a more sophisticated approach going forward.
It depends on how realistic we want this to be simulated. The order has to be sent from the trading workstation/server at some point in time. At the moment this is .utcnow(), but it should reference the actual timestamps of the market data.
Then of course there is the timestamp for the FillEvents, which will need to be simulated with some latency (to eventually represent slippage). The latency can be simulated using a random distribution of arrival and execution times. But...this motivates a much more sophisticated approach to slippage, where we give slightly worse bid/ask prices depending upon the market.
Lots to think about!
from qstrader.
To be honest, I'm not sure! That sounds like an obvious thing to do :-)
Also, I've just noticed that I've hardcoded the exchange (ARCA) into the code as well. This will need some thought. If you look at IB, it tends to respond with different exchanges (ARCA, BATS, "Smart") etc.
from qstrader.
timestamp
attribute doesn't exist for this kind of event
You need (after ticker = event.ticker
)
timestamp = self.price_handler.get_timestamp(ticker)
and create this get_timestamp
method in PriceHandler
class
https://github.com/mhallsmoore/qstrader/blob/master/qstrader/price_handler/price_handler.py#L11
def get_timestamp(self, ticker):
"""
Returns the most recent actual timestamp for a given ticker
"""
if ticker in self.tickers:
timestamp = self.tickers[ticker]["timestamp"]
return timestamp
else:
print(
"Timestamp for ticker %s is not "
"available from the %s." % (ticker, self.__class__.__name__)
)
return None
from qstrader.
I tried a few approaches and also settled on the above by @femtotrader.
I think a live execution handler would very much benefit from using this & tying it in with the response given from the broker. That way it's easy to calculate the total time taken from when a tick was passed through the loop, to an order being confirmed. Would be quite a useful metric.
from qstrader.
Fixed by 7f38214
from qstrader.
We can probably close this one also
from qstrader.
Related Issues (20)
- BUG: AttributeError: 'SMASignal' object has no attribute 'update' HOT 1
- Use with crypto
- QSTrader Documentation links are broken or moved
- no module named qstrader
- Dangling function
- Use of Assets!
- Documentation correction
- Pandas 1.3.x?
- How should a pair/pool trading strategy be implemented? HOT 2
- strategy_backtest.run() error, your assistance please HOT 1
- Please provide SPY CSV file please !! HOT 1
- Documentation HOT 1
- SimulatedBroker Issue HOT 1
- Lack of timestamp data from yahoo finance results in testing of qstrader with sixty_forty.py impossible
- Massive fail of the modules from qstrader HOT 2
- No module named 'qstrader.price_parser' ,for help HOT 2
- Scaled down order in simulated broker mentioned but not implemented?
- Compatibility with python 3.11 -error when plotting HOT 1
- timestamp date format in 60-40 portfolio HOT 3
- Click version requirement 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 qstrader.