Profit / loss trading calculator for share market historical data

In summary, the conversation discussed a share market trading calculator and the attempt at writing code to calculate buy and sell with profit/loss using moving averages. The equations involved the difference in buy and sell price times volume, and the formulas for buy and sell transactions. The issue of adding multiple transactions and managing equity was also raised.
  • #1
mp3streetpart
3
0

Homework Statement



Share market trading calculator.
I have tried to write code to calculate the buy and sell with profit/loss on historical data using moving averages. I'm am not interested in leverage yet.

bank = 10000
equity = 10000
sell = is current price of an instrument on the stock market either in the buy or sell routine.

Homework Equations


The difference in Buy price to sell price times volume.

The Attempt at a Solution


Buy formula
bank = bank - (10000 * sell) Remove money from bank to buy
profit = profit - (10000 * sell) Value to take to sell formula for profit/loss

Sell formula
profit = equity + ((10000 * sell ) + profit) Find profit/loss and compare against Buy
bank = profit: profit = 0


It works for a single buy and sell but I can't work out how to add more buys and sells to the bank or what to do with equity.
 
Physics news on Phys.org
  • #2
It's a little vague, but it looks like Equity should equal the current value of the stock that you own, at a particular time. You'd need to have a dataframe or some way of holding the stock names and values and how many shares you own of each. Then I guess you have a way to pull the share price for any given historical date?

When you sell shares, then equity is reduced, and bank increases.

At any particular time the value of (Bank + Equity) before a transaction should equal to (Bank + Equity) after transaction.
 

1. What is a profit / loss trading calculator for share market historical data?

A profit / loss trading calculator for share market historical data is a tool used by investors and traders to calculate the potential profit or loss on a particular trade based on historical data. It takes into account factors such as entry price, exit price, and number of shares to provide an estimate of the potential return on investment.

2. How does a profit / loss trading calculator work?

A profit / loss trading calculator uses mathematical formulas to analyze historical data, including stock prices, trade volumes, and other factors, to calculate the potential profit or loss on a trade. It takes into account the entry and exit prices, as well as the number of shares, to provide an estimate of the potential return on investment.

3. Why is it important to use a profit / loss trading calculator?

Using a profit / loss trading calculator can help investors and traders make more informed decisions about their trades. It provides a realistic estimate of the potential profit or loss on a trade, which can help with risk management and portfolio management.

4. Can a profit / loss trading calculator predict the future market performance?

No, a profit / loss trading calculator is not designed to predict future market performance. It is simply a tool that uses historical data to calculate the potential profit or loss on a trade. Market performance is influenced by a variety of factors and cannot be predicted with certainty.

5. Are there any limitations to using a profit / loss trading calculator?

Yes, a profit / loss trading calculator is based on historical data and does not take into account unexpected events or changes in the market. It is important for investors and traders to use the calculator as a guide and not rely solely on its results when making trading decisions.

Similar threads

  • General Discussion
2
Replies
46
Views
3K
  • General Math
Replies
1
Views
2K
  • General Math
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
1K
  • Precalculus Mathematics Homework Help
Replies
0
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
1K
  • General Discussion
4
Replies
133
Views
26K
  • Calculus
Replies
3
Views
2K
  • General Discussion
Replies
4
Views
3K
Back
Top