Comments (5)
You're looking for the execute
method of a policy object, I think. Let me know if it works for you, you need to instantiate a market data object for it, in a similar way of a market simulator.
You're right on the way the back-test result is formatted. In the future it will be possible to continue a back-test from the end, at the last timestamp you have the weights but not w_plus
.
from cvxportfolio.
PS I added a new option to cvx.DownloadedMarketData
and cvx.UserProvidedMarketData
, do_asset_selection
, which is better set to False
for online usage. This is only in the repository version at this point, and I'm testing it with examples/strategies/dow30_daily.py
, running it every day at market open New York time. It will take some days to make it to a pip release.
from cvxportfolio.
Another question about execute
and online usage (and looking at your example dow30_daily).
cvx.UserProvidedMarketData (or in your case cvx.DownloadedMarketData) tends to be using open prices. But if you are online isn't the most recent price going to be close? Because you don't have the bar full bar yet to use open. do the 'price' df have one extra row than the volume and returns dfs passed into cvx.UserProvidedMarketData?
from cvxportfolio.
You only need past returns (open prices are used by execute
to give number of shares to trade, optionally). Past returns are passed down to all elements of a policy (covariance estimators, ...) to make their forecasts. If you don't know the most recent past return it's not necessarily a big deal. For online execution, though, you should know the most recent one to get the dollar holdings you have at time t
. As you correctly say, Yahoo Finance doesn't provide accurate open prices a few minutes after market open. If I find another free source to use for that I'd switch, but for now I'm using the Yahoo Finance ones and then, next day, recompute the holdings for the past day. You can see it done in the commits, some names get a little adjustment. This is not part of the main library, it's logic specific for the examples strategies that are run online. I'll maybe work on making it smarter, but if you have paid data sources that give you more accurate prices you should probably use them. The example strategies do the best I can with free data.
from cvxportfolio.
That clarifies, thanks.
from cvxportfolio.
Related Issues (20)
- Questions on accounting model (e.g., for short positions) HOT 3
- Robustify online execution of example strategies (when open prices are missing) HOT 1
- Failure on non-numeric (object dtpye) user-provided data difficult to understand HOT 6
- Example request - Margin in a different currency HOT 14
- BUG: packaging failed to include modules moved into submodules (constraints, data)
- Feature request: handle user-defined time-varying universes (and better error checks with temporary `nan`s in user-provided returns) HOT 13
- Data quality issues in `ftse100_daily` example strategy
- EOFError: Ran out of input HOT 4
- Rendering of code blocks in README on github is broken
- Feature request: add `market_data=None` option to `Policy.execute`
- Feature request: Add constraint priority with automatic resolution into soft-constraints HOT 1
- Is it possible to have different costs definition depending on entry or exit HOT 1
- can we load into our custom crypto data into cvxportfolio for backtesting and portfolio construction ? [bounty possible] HOT 1
- Feature Request: Online Data Loading HOT 1
- Ecos needs to added in pyproject "test" optional dependencies HOT 1
- Issue loading data from FRED HOT 9
- Testsuite failing on py 3.9 b/c of dependencies HOT 1
- The result of backtesting 30 years is different from 5 years? HOT 5
- Feature Request: Ignore Tcosts in first period HOT 2
- Incompatible with Numpy 2.0
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 cvxportfolio.