Margin level formula breakdown - binance

I'm trying to make sense of the formula for margin level calculation as brought out here:
Margin Level = Total Asset Value / (Total Borrowed + Total Accrued Interest)
For example, if my collateral is 1 BTC, ETH/BTC price is 0.1 and I borrowed 10 ETH, how would the following values be calculated?
Total Asset Value
Total Borrowed
Total Accrued Interest
Is everything calculated in terms of base (ETH) or quote (BTC) asset?
Based on my intuition, I could come up with the following breakdown, but would like a confirmation.
For example, if hour = 1 (time of borrow) and eth_hourly_interest_rate = 0.001:
Total Asset Value = collateral + (borrowed * current_price) = 1 BTC + (10 ETH * 0.1) = 2 BTC
Total Borrowed = borrowed * price_at_borrow = 10 ETH * 0.1 = 1 BTC
Total Accrued Interest = hour * eth_hourly_interest_rate * current_price = 1 * 0.001 ETH * 0.1 = 0.0001 BTC
Therefore, margin level = 2 / (1 + 0.0001) = ~1.998
In this example, both current_price and price_at_borrow are the same for simplicity, but current_price would change in time while price_at_borrow will stay the same.

Total Accrued Interest for n hours = eth_hourly_interest_rate_hour(0,1) * eth_hourly_interest_rate_hour(1,n) * Total Borrowed * current price

Related

trying to create a loan calculator on a website ( https://www.atlasfoundation.net/ ) and I am getting trouble in the coding of Python. The code is:

trying to create a loan calculator on a website ( https://www.atlasfoundation.net/ ) and I am getting trouble in the coding of Python. The code is:
user enter the cost of the loan, the interest rate, and #the number of years for the loan
Calculate monthly payments with the following formula
M = L[i(1+i)n] / [(1+i)n-2]
M = monthly payment
L = Loan amount
i = interest rate (for an interest rate of 5%, i = 0.05)
n = number of payments
#Start of program
#Declare variables
monthlypayment = 0
loanamount = 0
interestrate = 0
numberofpayments = 0
loandurationinyears = 0
loanamount = raw_input("Lending Money ")
interestrate = raw_input("Interest Rates are? ")
loandurationinyears = raw_input("Time Duration in Years?")
#Convert the strings into floating numbers so we can use them in the formula
loandurationinyears = float(loandurationinyears)
loanamount = float(loanamount)
interestrate = float(interestrate)
#Since payments are once per month, number of payments is number of years for the loan
payments = loaninyears*12
#calculate the monthly payment based on the formula
payment = amount * interestrate * (7+ interestrate) * payments / ((1 + interestrate) * payments -1)
#Result to the program
print("Payment will be " + st(monthlypayment))
## Heading

Add count till it reaches certain percentage

I need to calculate how many more tickets i need to meet the target percentage. Let me try to explain with an example.
Lets assume I have below data -
Tickets Met - 27
Tickets Missed - 3
Total Tickets - 30
Met % - 90%
Target % - 95%
So i want to know how many more tickets should i met to reach 95% (where my missed count will not change)
I suggest following below formula:
Lets assume Tickets_to_be_met = x,
x = (0.95 * Total_Tickets) - Current_Tickets
My formula is based on simple Maths(Percentage) calculation:
Considering your example: ((27 + x) / 30) * 100 = 95
where
27 = Current_Tickets,
30 = Total_Tickets
EDIT
In Excel,
Try using =((95*B1)-(A1*100))/5 Where B column contains Total_tickets and A column contains Current_tickets
Considering the Formula: (27 + x) / (30 + x) = 95 / 100
Hope it helps!
Assuming you know your total tickets and current tickets met
Total tickets: 30
Tickets met: 27
You want to additionally add tickets such that your tickets met is 95% of total tickets
(Current_tickets_met + x)/(Total_tickets + x) = 95%
(27+x)/(30+x) = 95/100
This resolves x to be of value 30
Which means, if you additionally add 30 tickets
Current tickets met = 27+30 = 57
Total tickets met = 30+30 = 60
And 57/60 = 95%

Express a percentage as a range value

I have a range:
1.75 [which I need to be 100%] to 4 [which needs to be 0%] (inclusive).
I need to be able to put in the percent, and get back the value.
How would I find the value for a percentage, say 50%, using a formula in Excel?
What I have tried so far: If I 'pretend' to reverse the percentage so that 1.75 is 0% and 4 is 100%, it seems a lot easier: I can use = (x - 1.75) / (4 - 1.75) * 100 to return the percentage of x, which is to say (x - min) / (max - min) * 100 = percentage of a range.
But I can't get this to work when the max is actually lower than the min. And...I'm not looking for the percent, I'm looking for the value when I enter the percent. :-/
The percentage of the value in the range is
=(max - value) / (max - min)
The value at some percentage is
=(min - max) * percentage + max
Edit: Perhaps a more intuitive way to attack "the value at some percentage" (notice I changed the terms here):
= (max - min) * (1- percentage) + min
IOW,
= (total distance) * (complement of fractional distance) + baseline
The complement is needed because you have reversed the sense of upper and lower bounds.
Like so, I used =4-(2.25*A1),=4-(2.25*A2) and =4-(2.25*A3)
0 4
0.5 2.875
1 1.75

excel NPV does not work properly

let us consider following example
Example: Invest $2,000 now, receive 3 yearly payments of $100 each, plus $2,500 in the 3rd year. Use 10% Interest Rate.
Let us work year by year (remembering to subtract what you pay out):
Now: PV = -$2,000
Year 1: PV = $100 / 1.10 = $90.91
Year 2: PV = $100 / 1.102 = $82.64
Year 3: PV = $100 / 1.103 = $75.13
Year 3 (final payment): PV = $2,500 / 1.103 = $1,878.29
Adding those up gets: NPV = -$2,000 + $90.91 + $82.64 + $75.13 + $1,878.29 = $126.97
Looks like a good investment.
i have tried to calculate same in excel
10%
100
100
100
2500
-2000
=NPV(A1,A2,A3,A4,A5)+A6
and got (43.78),why?please help me
You need to net your final year - 100 + 2500
The NPV function assumes each cell value is the money recieved at the end of its own year.
It is assuming that you are getting the 2500 a year after the last 100 dollar payment.
try this instead:
100
100
2600
NPV(.10,100,100,2600)-2000 = ~126.97

Represent Negative percentage in excel instead of 0.0%

How can I show negative percent in excel?
I need to find worst case.
Current Input
if A = 15/19 = 78.9%
B = 162/268 = 60.4%
C = 0/5 = 0.0%
D = 0/90 = 0.0%
Output required.
FYI numerator and divisor is coming from another cell
if A = 15/19 = 78.9%
B = 162/268 = 60.4%
C = 0/5 = -5.0%
D = 0/90 = -90%
I'm having trouble understanding your question but you will only get a negative percentage where one of either the numerator or denominator is below zero:
0/5 = 0%
5/5 = 100%
-5/5 = -100%
5/-5 = -100%
If you presume we're talking about employees here, comparing the number of tasks assigned versus the number of tasks completed and you want to judge two employees differently even though neither of them accomplished anything you'll have to use something besides percentages.
In your example you imply that 0/5 is different from 0/90 but this would also imply that somebody completing 10/20 tasks (50%) should be rated differently from somebody completing 200/400 tasks (also 50%).
Some things you could do are giving each employee some value like 2 points for every task they complete and subtracting 3 points for every task they did not complete.
A = (15 *2) - (4 *3) = 18 points
B = (162*2) - (106*3) = 6 points
C = (0 *2) - (5 *3) = -15 points
D = (0 *2) - (90 *3) = -270 points
The problem here is that you would need to decide the weighting, as comments have pointed out, this weighting would give somebody who completed 200/400 tasks less points than somebody who completed 10/20. It looks like you've already decided to go with a modified 'percentage' value so further argument is moot but the weighting would have to be determined based on the meaning behind the numbers.
I'll give one alternative below where 3 points are given for completing a task and 2 are subtracted for failing to complete a task:
A = (15 *3) - (4 *2) = 37 points
B = (162*3) - (106*2) = 274 points
C = (0 *3) - (5 *2) = -10 points
D = (0 *3) - (90 *2) = -180 points
Another metric I might consider is to take ALL 205 of the uncompleted tasks and assign percentages based on how many of the uncompleted tasks belong to each user:
A = 4 / 205 = 1.9%
B = 106 / 205 = 51.7%
C = 5 / 205 = 2.4%
D = 90 / 205 = 43.9%
In this case, you would be ranking whoever has failed to complete the largest percentage of the uncompleted tasks pool.
This is what I ended up doing
Cell A1 = 0.0%
Then I did following using if else condition.
Output
Formula in D2
=IF(IFERROR(C2/B2,"")=$A$1,-B2*0.01,IFERROR(C2/B2,""))
Hope it will help others

Resources