Recalculation of position size from portfolio value

Hello dear devs,

I have a feature request. It is a bit complex, so I explain the situation first. Currenlty Iam in the process of creating a investment plattform that has a binance account in the backend. Clients can invest into our service and the deposited money will go directly into the binance account.

Our investment service will use self-coded strategies from tradingview and use the alerts to create trades that are opened and closed automatically. Currently Iam using your service and Iam very satisfied. Now to my current problem I really would like to get help with:

If clients deposit and withdraw of the service the balance of the binance account can change very often within a day. The position size is calculated by the tradingview strategies and varies each time (depending on risk/volume and other different factors). The origin of the calculation is the “portfolio value” we set in Tradingview directly. Due to the fact that clients can withdraw and deposit money at any time the value inside of tradingview doesn’t represents the actual value of the binance account. Currently it is needed to update the tradingview alerts everytime someone is withdrawing/depositing money → not very good.

A feature that really helps would be the following:

If a alert is sended with a specific quantity, the value is re-calculated by TTA with the following formula:

position size = old position size * (current portfolio balance / original portfolio balance)

A example:

Tradingview is sending a alert with q = 0.001 BTC
Original portfolio balance = 100$ (set in Tradingview)
new portfolio balance = 300$ (current Binance balance)

0.001 BTC * (300$/100$) = 0.003 BTC

So basicly the input from the tradingview alert is recalculated to the current portfolio size and is a factor of the sended value from Tradingview.

For that it would need the following steps on the TTA connector:

  1. Get Tradingview Alert
  2. Get portfolio size
  3. calculate: q = old position size * (current portfolio balance / original portfolio balance)
  4. send signal to Binance with updated q from TTA

I hope I explained it in a way, that it was understandable.

Iam looking forward to get your help. That would really help us with our service and automate it even further.

Thank you in advance