Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Interest Paid on Leveraged Assets #32

Closed
jaredbroad opened this issue Feb 21, 2015 · 6 comments
Closed

Model Interest Paid on Leveraged Assets #32

jaredbroad opened this issue Feb 21, 2015 · 6 comments
Labels

Comments

@jaredbroad
Copy link
Member

Leverage is currently free in LEAN. Implement a system for deducting interest charges from cash when holding leveraged stock overnight. Apply a default interest rate of 1.5% on the leveraged fraction of holdings. Potentially best place is to apply cash charge on day change in AlgorithmManager data loop.

@QANTau
Copy link
Contributor

QANTau commented Mar 6, 2015

When looking at this feature, would it be possible to consider the calculation of swap for FX transactions also. It would be nice to be able to specify a 'Calculation Time' that would fire an event where the calculation could be performed.

The default event code could calculate a 1.5% default rate, but could be overridden to perform custom calculation (in the case of FX swap, we could probably load external data to calc the swap rate) and return the +/- interest back into the account.

Applying on the 'day change' may not work in all cases as brokers may not charge swap at the end of the day (I have a local broker that charges the swap at 1930hrs local time), so the ability to set this to a custom time of day may be more appropriate.

I definately don't have the C# skills to build an event model like this, but will volunteer to put together an example of swap calculation code using external interest rate data if that helps.

@jaredbroad
Copy link
Member Author

Great feedback thanks @QANTau. We will factor this into the design of the leverage fee calculations. Its probably best done in the transaction models class however it has some similarities to the Benchmark system.

One way to help would be starting with the source of the swap rate data, and how to import it into LEAN. It might be nice if this was standardized/similar to the way benchmark loads in data (#30). If possible it would be sourced from a web-source like Yahoo to be self-updating.

@jaredbroad jaredbroad changed the title [Feature] Model Interest Paid on Leveraged Assets Model Interest Paid on Leveraged Assets Mar 11, 2015
AlexCatarino added a commit to AlexCatarino/Lean that referenced this issue Jun 29, 2016
Implements IMarginInterestModel interface to model interest paid on leveraged assets.
Implements a ConstantMarginInterestModel to model a constant interest paid.
Modifies SecurityPortfolioManager and AlgorithmManager to enable the margin interest modelling.
Adds MarginInterestTests to test the implementation
Ref: issue QuantConnect#32
AlexCatarino added a commit to AlexCatarino/Lean that referenced this issue Jun 29, 2016
Implements IMarginInterestModel interface to model interest paid on leveraged assets.
Implements a ConstantMarginInterestModel to model a constant interest paid.
Modifies SecurityPortfolioManager and AlgorithmManager to enable the margin interest modelling.
Adds MarginInterestTests to test the implementation
Ref: issue QuantConnect#32
AlexCatarino added a commit to AlexCatarino/Lean that referenced this issue Jun 29, 2016
Implements IMarginInterestModel interface to model interest paid on leveraged assets.
Implements a ConstantMarginInterestModel to model a constant interest paid.
Modifies SecurityPortfolioManager and AlgorithmManager to enable the margin interest modelling.
Adds MarginInterestTests to test the implementation
Ref: issue QuantConnect#32
AlexCatarino added a commit to AlexCatarino/Lean that referenced this issue Aug 2, 2016
Implements IMarginInterestModel interface to model interest paid on leveraged assets.
Implements a ConstantMarginInterestModel to model a constant interest paid.
Modifies SecurityPortfolioManager and AlgorithmManager to enable the margin interest modelling.
Adds MarginInterestTests to test the implementation
Ref: issue QuantConnect#32
@jaredbroad
Copy link
Member Author

@ebengtso
Copy link

I provided a sample code to calculate interests..

https://www.quantconnect.com/forum/discussion/5460/calculate-rollover-interest-for-oanda/p1

It would be interesting if the model could attach the interests to the trade, as costs or contribution.

@Martin-Molinero
Copy link
Member

Closing since Lean now supports this. Missing to implement the default margin interest rate model see #6981

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants