• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Buy/Sell stocks at user defined price

 
Greenhorn
Posts: 5
Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have stock trading application in my assignment and one of the use cases suggest that the user can buy/sell stocks at market price or user defined price. I have 2 queries in relation to this -

1. When the user sets the price of the stock say at 110 and the current market price is at 100. How will I handle the scenario where the automatic buying/selling of stock happens once the price reaches 110?

2. Also, when the user wants to buy the stock at market price, I am thinking of storing the market prices in my DB tables. This can happen if I subscribe to the pricing system where the updates in prices are posted automatically. And my subscriber class would then populate the stock prices in the DB table. I was bit hesitant to call the pricing system to fetch the current market price and make the transaction happen. I am not sure if this is a good idea but my thinking was that this would keep the system less reliant on the outside system. And if I store the prices on the tables, it would execute the transactions faster (which is one the requirements of my assignment)

Also, do I have to show the JMS classes in the class diagrams? Will it have to be in that detail? I am thinking of covering the JMS part in the component diagram and not much it in the class diagram.

Any response or advice is highly welcome and looking forward to it.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that this is for an assignment, and not for a real system ... so feel free to ignore, as this response is just for a bit of realism.

Sourav Bws wrote:
2. Also, when the user wants to buy the stock at market price, I am thinking of storing the market prices in my DB tables. This can happen if I subscribe to the pricing system where the updates in prices are posted automatically. And my subscriber class would then populate the stock prices in the DB table.



With most trading systems / exchanges (that trade in equities), it is the trades that create the prices -- and not the other way. In other words, the prices are an indication of trades that already happened, and not the prices for future trades.

So, when you want to "buy at market", your "bid" is automatically matched with the lowest "ask", and traded. The new market price is then indicated by your trade. I believe that there are some safety nets for low volatility, etc., but you get the general idea.

Henry
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sourav Bws wrote:
1. When the user sets the price of the stock say at 110 and the current market price is at 100. How will I handle the scenario where the automatic buying/selling of stock happens once the price reaches 110?



In the scenario mentioned in my previous post, where it it the trades that sets the prices, this is easily done...

Buy/Sell at user specified prices are simply bids/asks (orders). If the user want to sell at 110, and the latest market price is at 100, then an ask is sent into the exchange for 110. Later, when someone wants to buy at market, it is matched with the lowest ask. And if the lowest ask is 110, then that's the new price (and the trade happens).

And again, there should be safety nets, such as asking for something lower than the highest bid, will automatically get you the higher price instead. etc.

Henry
 
Sourav Bws
Greenhorn
Posts: 5
Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Sourav Bws wrote:
1. When the user sets the price of the stock say at 110 and the current market price is at 100. How will I handle the scenario where the automatic buying/selling of stock happens once the price reaches 110?



In the scenario mentioned in my previous post, where it it the trades that sets the prices, this is easily done...

Buy/Sell at user specified prices are simply bids/asks (orders). If the user want to sell at 110, and the latest market price is at 100, then an ask is sent into the exchange for 110. Later, when someone wants to buy at market, it is matched with the lowest ask. And if the lowest ask is 110, then that's the new price (and the trade happens).

And again, there should be safety nets, such as asking for something lower than the highest bid, will automatically get you the higher price instead. etc.

Henry



Hi Henry,

I have cleared my OCMJEA exam and the piece of advice that you shared in the above post was really really helpful. I can't thank you enough for this.

Best Regards,
Sourav
https://au.linkedin.com/in/souravbws
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic