hugodanielcom

PureRebalance

hugodanielcom Uppdaterad   
Library "PureRebalance"

A rebalance function that is pure.

Depends only on its arguments to perform the necessary calculations.

rebalance(token_price, portfolio_token_amount, portfolio_fiat_amount, rebalance_ratio) Rebalances a portfolio made of tokens and fiat to a given ratio of tokens per fiat
  Parameters:
    token_price: The value of a single unit (1) token
    portfolio_token_amount: The number of tokens in the portfolio
    portfolio_fiat_amount: Fiat available in the portfolio
    rebalance_ratio: The ratio of token value / fiat that the portfolio should have after the rebalance (0.5 is used if no argument is supplied).
  Returns: The number of tokens to buy or sell in order to achieve the desired portfolio ratio passed as argument (a positive value is returned if the tokens are to be bought, and negative value if the tokens are to be sold).
Versionsinformation:
v2

Updated:
rebalance(token_price, portfolio_token_amount, portfolio_fiat_amount, rebalance_ratio) Rebalances a portfolio made of tokens and fiat to a given ratio of tokens per fiat
  Parameters:
    token_price: The value of a single unit (1) token
    portfolio_token_amount: The number of tokens in the portfolio
    portfolio_fiat_amount: Fiat available in the portfolio
    rebalance_ratio: The ratio of token value / fiat that the portfolio should have after the rebalance (0.5 is used if no argument is supplied).
  Returns: The number of tokens to buy or sell in order to achieve the desired portfolio ratio passed as argument (a positive value is returned if the tokens are to be bought, and negative value if the tokens are to be sold).
Versionsinformation:
v3 - Removed all "simple" arguments

Updated:
rebalance(token_price, portfolio_token_amount, portfolio_fiat_amount, rebalance_ratio) Rebalances a portfolio made of tokens and fiat to a given ratio of tokens per fiat
  Parameters:
    token_price: The value of a single unit (1) token
    portfolio_token_amount: The number of tokens in the portfolio
    portfolio_fiat_amount: Fiat available in the portfolio
    rebalance_ratio: The ratio of token value / fiat that the portfolio should have after the rebalance (0.5 is used if no argument is supplied).
  Returns: The number of tokens to buy or sell in order to achieve the desired portfolio ratio passed as argument (a positive value is returned if the tokens are to be bought, and negative value if the tokens are to be sold).
Pinebibliotek

I sann TradingView-anda har författaren publicerat denna Pine-kod som ett bibliotek med öppen källkod så att andra Pine-programmerare från vår community kan återanvända den. Hatten av för författaren! Du kan använda det här biblioteket privat eller i andra publikationer med öppen källkod, men återanvändning av den här koden i en publikation regleras av våra ordningsregler.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här biblioteket?

Kopiera följande rad och klistra in det i ditt skript.