hugodanielcom

PureRebalance

hugodanielcom Aktualisiert   
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).
Versionshinweise:
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).
Versionshinweise:
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).
Pine Bibliothek

In echter TradingView-Manier hat der Autor diesen Pine-Code als Open-Source-Bibliothek veröffentlicht, so dass andere Pine-Programmierer aus unserer Community ihn weiterverwenden können. Ein Hoch auf den Autor! Sie können diese Bibliothek privat oder in anderen Open-Source-Publikationen verwenden, aber die Wiederverwendung dieses Codes in einer Publikation unterliegt den Hausregeln.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.

Möchten Sie diese Bibliothek nutzen?

Kopieren Sie die folgende Zeile und fügen Sie sie in Ihr Skript ein.