how to calculate interest - ruby-on-rails

We have a web app that among other things, allow users to leave a cash balance on their account (which can be cashed out anytime or used to purchase items on the site). Users can withdraw and deposit funds to their account anytime. It was never intended for it, but we now have users who leave large sums on their account and they're now requesting that we provide some interest on their account balance which is totally reasonable. Problem is we have no idea how to calculate interest on an account where users can withdraw and deposit funds anytime, but all the banks obviously do it so I was wondering if there's a standard way (or ruby gem) to calculate interest. Any pointers or help is greatly appreciated.
The db table setup is pretty simple.
User has one Account
Accounts(user_id, balance)
Account has many activities
Activities(account_id, type, amount, description, created_at)
Where type can be either "Deposit" or "Withdrawal".

For the answer on what interest calculation to use I agree with Ray Toal that you are going to have to ask your client what interest calculation to use and what their payment scheme is like.
Usually speaking, financial institutions that offer interest on a chequing account are calculated with compounding interest calculated daily [at the close?] of each business day and paid monthly at the end of each month by a deposit directly into the account.
Notably, banks and other financial institutions will tell their clients the interest rate on a yearly basis (APR) and not the interest rate per-day. It is an elementary mistake that I have made in the past.

Take a look at the Exonio gem: https://github.com/Noverde/exonio.
This gem implements some of the Excel financial formulas, including the Interest calculation that you are asking for.
From their docs:
What is the interest part of a payment in the 8th period (i.e., 8th
month), having a $5,000 loan to be paid in 2 years at an annual
interest rate of 7.5%?
Exonio.ipmt(0.075 / 12, 8, 12 * 2, 5_000.00) # ==> -22.612926783996798
So, in the 8th payment, $22.61 are the interest part.

Related

Searching for a particular trading platform

I'm trying to find an "Exchange/trading platform" with the following conditions
I must be able to purchase currencies (fiat or crypto) and not need to return back to the base currency. I do not wish to open and close positions. I plan to only take, never make. - Is there a name for this?
The commission needs to be as low as possible preferably less than 0.1% per trade (I want to high-frequency trade)
I'm after API access for the High-frequency trading.
I'm after a large grid/table (every currency into every other currency) for example:
Ideally, 9+ currencies. - I have made this in excel using modified data from https://www.exchangerates.org.uk/currency/currency-exchange-rates-table.html
If all of these exist on a single website, that would be wonderful!
Thank you in advance for any and all help.
Binance.com (crypto) has what you want.
API Access: https://github.com/binance-exchange/binance-official-api-docs
Low Fees: 0.075% for a taker trade
If you use my referral link you will get an additional permanent 10% trading fee reduction.
https://www.binance.com/en/register?ref=OTWO00WS
(I also get 10% so it's a win win)

Higher bid following currency change

For a long time my adwords account was working with NIS currency (while 1USD = 3.5NIS). I've decided to transfer my account to USD currency, for this I've opened a new account and copied all campaigns.
I've noticed something very bizarre in my new USD account. Keywords which were placed in the first page with NIS currency now require a much higher bid. For example, a keyword had a 0.82NIS bid (0.24 USD) and had avg. position of 2.8 now requires 1.31$ according to google to enter the first page.
How is it possible?
Thanks
I'd guess that the most important factor is that your new account has no CTR history, meaning that your quality score tends to be much lower than in your old account.
This in turn leads to higher first page bid estimates.
Your Google account manager might be able to change the currency of your old account if you're a big spender an important customer. That way, your bids should stay pretty much the same.

Add a fee per transaction with PayPal

I am creating iOS application where local carpenters can sell their furniture in my app.
My business model would be based on a small fee per transaction (let's say 0.001% + 1$ per sale). Is it possible with PayPal (how)?
If not - are there any alternatives?
Not related to coding, but business-wise, .001% seems like smaller than you mean for it to be. A better amount would be something like 5%. If your app succeeded beyond your wildest dreams and you started doing $1,000,000,000 a year in sales, .001% of that would net you $10,000.

Black Scholes options pricing

I am investigating how involved creating a very simple options trading platform will be(not for profit but for learning purposed). Can someone please explain the process flow of how Black Scholes option pricing is used within trading platforms, the below is my understanding please correct me if i am mistaken:
1) in memory prices of options derived from Black Scholes formula.
2) an incoming buy order for an option in FIX protocol format.
3) trading platform compares the price of buy order with the price derived from Black Scholes and decides to buy accordingly.
please correct me if i am mistaken anywhere thanks in advance
1) in memory prices of options derived from Black Scholes formula.
That is the job of the user application, Quickfix will not help in any matter regarding this.
2) an incoming buy order for an option in FIX protocol format.
You take the message, parse it and store the rwquired information for yourself.
3) trading platform compares the price of buy order with the price derived from Black Scholes and decides to buy accordingly.
This again is the job of the user application. Inforamtion collected from Step 2 will help you in this.
FIX is a message format for communicating, which should be kept away from your programming logic. Else it will slow down the messaging unnecessarily for no apparent gain.

Magento: Deduct Tax at Checkout for (most) countries [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am working on a UK fashion store. The customer has a specific requirement - never add tax (VAT) at checkout; rather, have VAT built into the price, and deduct when applicable.
The use case is that EU purchases will have no tax added at checkout - as the price includes it. And, rest of the world purchases will have the VAT deducted at the checkout.
I can't see how to do this in Magento. I though to set up some negative values for tax rates, but that doesn't work.
Any ideas?
This is a very complex problem.
This is possible. First of all, create tax rules for all countries which will get your pre-taxed prices: UK Seller Tax Rules for Magento (It is essential that there is a tax rule for UK!)
Also in tax configuration, change "catalog prices" to "including taxes", do this also for "shipping prices". And set "tax calculation based on" to "shipping address".
Be sure to set your "default tax calculation destination" correctly (to your UK address).
Switch to your products tab, mark all products (there is a link on the left side to do this). Look for "actions" on the right side and use "update attributes", scroll to the product tax class and take the tax class you set up in point 1.
This works as follows: you have a product in your system for 20 pounds. Magento now knows that these are including VAT. Users will see 20 pounds in the frontend as the price for the product. Now e.g. if someone from Australia will order your product, Magento will look for a tax rule for Australia, but cannot find one. So it will assume 0% tax. It knows that the price of your product is including 20% tax. So it deducts 20% tax from the product's price.
It gets complicated if you wish to deliver to countries with different tax rates within the EU, e.g. Germany, which has 19%. You will have to create a tax rule for germany with 19% tax. Magento will deduct 20% UK Tax and will add 19% German Tax.
Good luck. If Magento shows undesired behavior adding and deducating tax in the frontend, try playing with the "tax calculation based on". Some have better results using "shipping origin". I don't know which suits your needs better.

Resources