hugodanielcom

PureRebalance

hugodanielcom Aggiornato   
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).
Note di rilascio:
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).
Note di rilascio:
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).
Libreria Pine

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzare questa libreria in privato o all'interno di altre pubblicazioni open-source, ma il riutilizzo del codice è subordinato al rispetto del Regolamento.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questa libreria?

Copia il testo ed incollalo nel tuo script.