Creating a tranding script for 2 virtual currencies
Posted: Fri Dec 25, 2009 5:40 pm
Hello everyone,
Can someone please help me out with a problem I'm having when designing this live trading script.
Firstly I'll try to explain what I need to accomplish.
Each user can have 2 different virtual currencies in his/her account, I would like to create an script where users could post a buy/sell order into the system at their desired rate, after the system accepts the order it will clear any orders that match. For e.g. if there is an order to BUY 100*(Currency A) at 1*(Currency B) and another order of SELL 500*(Currency B) at 1*(Currency A). The BUY order would "Clear" and the SELL order will not have a 400 volume remaining instead of the 500.
Design problems
I would like to have 2 interfaces:-
1. where the user would enter the volume and exchange rate manually and wait for the trade to clear. This should not be too much of an issue as I could easily post the order to a database and then call a function to check for any matching trades and clears them. This shouldn't be too much of an issue.
2. An interface where the user just enters the volume he wishes to buy, this will prompt the user with the total cost of the buy order (Just by checking the lowest sell order orders), and then confirm the order, this will post the order and clear the funds.
The only problem I can see here is that if the price changes between the prompt (with the total cost) there is a possibility that the order would not clear, and this will destroy the whole concept of this second interface where the user just wants to get a "quick" trade.
I would appreciate any suggestions for this problem and/or remarks about the overall design of the system.
I hope I was clear on what I intend to do, but if I wasn't feel free to ask any questions.
Thanks again.
Can someone please help me out with a problem I'm having when designing this live trading script.
Firstly I'll try to explain what I need to accomplish.
Each user can have 2 different virtual currencies in his/her account, I would like to create an script where users could post a buy/sell order into the system at their desired rate, after the system accepts the order it will clear any orders that match. For e.g. if there is an order to BUY 100*(Currency A) at 1*(Currency B) and another order of SELL 500*(Currency B) at 1*(Currency A). The BUY order would "Clear" and the SELL order will not have a 400 volume remaining instead of the 500.
Design problems
I would like to have 2 interfaces:-
1. where the user would enter the volume and exchange rate manually and wait for the trade to clear. This should not be too much of an issue as I could easily post the order to a database and then call a function to check for any matching trades and clears them. This shouldn't be too much of an issue.
2. An interface where the user just enters the volume he wishes to buy, this will prompt the user with the total cost of the buy order (Just by checking the lowest sell order orders), and then confirm the order, this will post the order and clear the funds.
The only problem I can see here is that if the price changes between the prompt (with the total cost) there is a possibility that the order would not clear, and this will destroy the whole concept of this second interface where the user just wants to get a "quick" trade.
I would appreciate any suggestions for this problem and/or remarks about the overall design of the system.
I hope I was clear on what I intend to do, but if I wasn't feel free to ask any questions.
Thanks again.