Comments (14)
Hello, and thanks. Example strategies in other (non-US) markets are in the works (PR #127), main issue is improving cleaning logic of Yahoo Finance historical data (I encountered issues on a few FTSE100 names with phony old open prices, ...). Regarding cost of financing (interest rates) FRED provides data at least for EUR, JPY, GBP, and these can already be used as cash_key
. More complicated setups (multi-currency, multi-markets with different trading times, non-convex margin or borrow cost, ...), won't probably be supported in the main library, but can be developed with user-defined custom derived classes of MarketData
, HoldingCost
, .... Another problem with strategies heavy on borrowing is that historical borrow fees of stocks are not publicly available, so it's difficult to develop credible examples. There are some (market neutral with borrow cost and market neutral without borrow cost), but they should be taken with a grain of salt.
PS If you have a specific example strategy in mind feel free to open a PR, even if it includes a user-defined subclass of HoldingCost
(which I think is what you mean, but I'm not sure) it would be a good addition to the examples suite.
from cvxportfolio.
Thank you @enzbus ! much appreciated. I do have one in mind. Let me try and through something together and open a PR.
Cheers,
Andrew
from cvxportfolio.
Hi @enzbus I hope your well. I am not sure if this is the best place to ask this question, but setting up a static portfolio - so a portfolio with fixed weights. leveraged with a cross currency - so borrowing jpy to invest in say us stocks - keeping track of interest rate, fees, margin calls (say 1.1 times the borrowed amount), currency exchange and re-balancing monthly to maintain the the leverage ratio is quite challenging and is (surprisingly) non trivial. I am having a bit trouble pulling together a working solutions.
Do you have any advice or thoughts.
Would be great to get your comments on the above.
Best,
Andrew
from cvxportfolio.
That sounds interesting @andrewcz ; apologies if I repeat it but I would suggest that you put together your current code in a prototype example, open a PR, and we take it from there. Of course don't include any IP you wish to keep private. It sounds like the cash_key
would by JPYEN
, which is already supported, and we would derive from DownloadedMarketData
to rebase the assets' returns in JPY, using FixedWeights
(or Uniform
) as example policy. Then we can see if also HoldingCost
needs to be derived or we can use the default one...
from cvxportfolio.
PS this is the series currently used as interest rate for JPY, expressed in annualized percentage. Is that right?
from cvxportfolio.
Thank you @enzbus !! Will put together a code example by the end of the week,as well as further details
from cvxportfolio.
Hi @enzbus just advise created a pull request with my attempt.
Cheers Andrew
from cvxportfolio.
Thanks! Looks great, I added a few comments. Give me write permission to your branch if you wish, happy to help. Looks like we can use that MarketData subclass to prototype future extension of MarketData to handle multi-currency portfolios :)
from cvxportfolio.
@enzbus !!! amazing!! you legend! I think i have successfully added you as a collaborator.
Feel free to make any changes :).
Cheers,
Andrew
from cvxportfolio.
Sure, I can clean up the way MarketData
does FX conversion, eventually that will go in the main library. But you should spend some time on documenting what it is that you want to do, and possibly find references on how margin should calculated, and financing charges. From a quick search I found this https://www.interactivebrokers.com/webinars/Mechanics_of_Overseas_Trade.pdf , it seems in this case financing is charged with the interest rate of the country the stock is from, not the country you buy it from. I'm not going to speculate, so please do find references or clearly state the problem setting and assumptions. Thanks!
from cvxportfolio.
Hi @enzbus I have done some further thinking, curious on your thoughts on the below.
Main strategy
A set of fixed weights on assets (or optimized weights), I think fixed is a good starting point.
Borrowed jpy to invest in asset for leverage.
Leverage 1:3.5 (3.5 dollars for every 1 dollar invested.
If portfolio goes to 1:4.2 (4.2 dollar for every 1 dollar invested) bring portfolio back to leverage 2 above
If portfolio goes to 1:2.8 (2.8 dollars for every 1 dollar invested) bring portfolio back to 2 (the 3.5 dollars for every 1 dollar invested), portfolio buys assets to the point of the setting of the
If the portfolio is margin called (portfolio is 6 dollars for every 1 dollar invested) the portfolio sells assets until it moves to 1:3.5
Risks and costs.
Interest rate risk of JPY. (noted and taken), this has been checked, if in interactive brokers you submit an order to buy say SPY, and you attach a jpy/usd order you will be charged the interest rate on jpy and also take the currency risk of jpy to usd, calculated daily.
Currency risk of jpy to usd. (noted and taken), calculated daily as this affects the margin ratio, this should be incorporated into the margin calculation (?).
Transaction costs (noted and could be modelled)
Bid ask spread or liquidity risk, could this be modelled (?), if the portfolio has to sell what price will it get.
from cvxportfolio.
Related Issues (20)
- pip install complains of scipy<1.11.0 HOT 4
- User provided returns forecast (`r_hat`) can be problematic HOT 1
- Interest rate on short sell cash proceeds
- Error from sp500_ndx100 example HOT 1
- Issue When Running examples/sp500_ndx100.py HOT 5
- I HOT 2
- NaN Handling HOT 3
- MultiPeriodOptimization Behavior Documentation HOT 10
- Single-step use question HOT 5
- do_asset_selection potential bug HOT 3
- Pandas 2.2.0 causes issues HOT 1
- Possible issue when using Cvxportfolio's internet access through a VPN HOT 4
- Make test suite fail on warnings
- 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
- 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
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.