Giter Club home page Giter Club logo

Comments (14)

enzbus avatar enzbus commented on June 24, 2024 1

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.

andrewcz avatar andrewcz commented on June 24, 2024 1

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.

andrewcz avatar andrewcz commented on June 24, 2024

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.

enzbus avatar enzbus commented on June 24, 2024

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.

enzbus avatar enzbus commented on June 24, 2024

PS this is the series currently used as interest rate for JPY, expressed in annualized percentage. Is that right?

from cvxportfolio.

andrewcz avatar andrewcz commented on June 24, 2024

Thank you @enzbus !! Will put together a code example by the end of the week,as well as further details

from cvxportfolio.

andrewcz avatar andrewcz commented on June 24, 2024

Hi @enzbus just advise created a pull request with my attempt.
Cheers Andrew

from cvxportfolio.

enzbus avatar enzbus commented on June 24, 2024

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.

andrewcz avatar andrewcz commented on June 24, 2024

@enzbus !!! amazing!! you legend! I think i have successfully added you as a collaborator.
Feel free to make any changes :).
Cheers,
Andrew

from cvxportfolio.

enzbus avatar enzbus commented on June 24, 2024

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.

andrewcz avatar andrewcz commented on June 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.