Bitcoin Forum
May 14, 2024, 05:17:15 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Margin Trading Exchange Software  (Read 4198 times)
hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
January 30, 2014, 05:03:17 PM
Last edit: January 31, 2014, 03:19:44 PM by hexs
 #1

Hello everyone, I’ve been working on creating software which can handle margin-trading of bitcoin-based derivatives. At this point I am not sure if I should try to operate the exchange or try to license the software out to those interested in running it. Nonetheless, I intend to use this thread as a way to get continuous feedback on the service/software. This includes any problems/bugs that may pop up and even requests for additional features and functionality.

Basics
The software is a bare-bone exchange simulator (no fancy user –interfaces). With a thin java desktop application which acts as the customer trading application.

ServerSide:
TreasuryEngine – Controls adding new customers, assigning new deposit address’ and checking balance, withdrawl, gross balance, debit/credits, profitloss, net balance, used margin and free margin for any customer.

MarginEngine – With the assistance of the TreasuryEngine commands, checks to see when free margin balance of any user equals to zero. When it sees that the free margin balance of a customer is equal to zero. The MarginEngine will force liquidate the trader out of any open position based on the current available quotes in the markets a customer holds a position during the margin call.
Margin engine is also called when new trades are being opened to ensure that the trader has enough free margin to open a trade.

OrderEngine – Is the first ‘gate’ when a BUY or SELL command is issued. And handles adding pending orders to the limit order book.

MatchingEngine – Is the second ‘gate’ when a BUY or SELL command is issued. It checks to see if the order being processed is a market order and acts as the primary match-maker for trades. When you buy or sell, matching engine determines which passive orders you get matched with. (as with most modern electronic trading venues, matching occurs in a first-in-first-out basis with price and time priority).

SecurityEngine – Is invoked anytime you do anything as a customer on the exchange. Security engine ensures that you are connected to the exchange with the java thin client using a continuous CRAM-SHA256 handshake. Every command has a unique handshake protocol. If a customer fails any step of the handshake process; the security engine will realize a circumvention attempt and dispose of the user immediately. Customers can also choose which IPs can be connected to the exchange for their desired username to prevent further unauthorized use.

Administrator can add new instruments/symbols, set/change margin requirements and fees per trade without having to reboot/restart the server. The software is also support capable and exchange administrator can hire support staff without needing to worry about any database or customer information breach.

Client Side:
Socket based java thin client which basically responds to the challenge handshake and send encrypted commands to the server.
Current GUI: (again, barebone, would like more feedback from the bitcoin community about this)

Settings View – Basic information about the customer, including name, address, deposit address, withdrawal address. And requesting withdrawals.

Balance view – Displays total deposit, total withdrawal, gross balance, total debit/credits, total profit loss, net balance, used margin and free margin.

Transaction View – displays all matched/filled trades of the customer.

Position View – aggregates all trades and shows a net position by instrument, including total buys and sells, average buy, average sell, closed profit loss and open profit loss.

Pending View – displays all pending/working orders by customer. With the ability to delete all working orders or delete all working on specific instrument.

OrderTicket– displays the 10 best available buy prices and sell prices. With buttons to buy at market, sell at market, buy at a limit price, sell at a limit price, and cancel all working orders. There is also fields where you can type a new symbol and hit enter, and the order book will refresh to show the best bid/ask of that market. (you don’t have to open 10 order books, you can change between order books by typing desired symbol)

I will post screen grabs shortly (as I am finishing up the initial GUI) of the client side GUI and look forward to the feedback.


Cheers!
1715663835
Hero Member
*
Offline Offline

Posts: 1715663835

View Profile Personal Message (Offline)

Ignore
1715663835
Reply with quote  #2

1715663835
Report to moderator
In order to achieve higher forum ranks, you need both activity points and merit points.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715663835
Hero Member
*
Offline Offline

Posts: 1715663835

View Profile Personal Message (Offline)

Ignore
1715663835
Reply with quote  #2

1715663835
Report to moderator
1715663835
Hero Member
*
Offline Offline

Posts: 1715663835

View Profile Personal Message (Offline)

Ignore
1715663835
Reply with quote  #2

1715663835
Report to moderator
1715663835
Hero Member
*
Offline Offline

Posts: 1715663835

View Profile Personal Message (Offline)

Ignore
1715663835
Reply with quote  #2

1715663835
Report to moderator
Duffer1
Full Member
***
Offline Offline

Activity: 227
Merit: 100



View Profile
January 31, 2014, 03:25:46 PM
 #2

Sounds promising so far. 

Following.
hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
February 10, 2014, 12:47:28 AM
 #3

Hello again, some updates on the GUI.

Thin tool bar with some options.

Account

- Settings (view address to deposit BTC (static), change withdrawl address/view currently set withdrawl address)
- Account History
- Transaction History


Trading

- Pending Orders
- Order Ticket

Data
-Charting

Research
(this is a work in progress, I was thinking linking to a collective blog where people put trade ideas)


Support

- Live Support (when support agent is available, the tool bar becomes a chat window)
- FAQ (link to FAQ, knowledge base, etc).

Time for some pics!

Main toolbar:
http://s9.postimg.org/fai5x481b/image.png

Main toolbar becoming a support window:
http://s14.postimg.org/6dlbz2bsx/image.png


Account History:
http://s17.postimg.org/o50g2tf6n/image.png

Transaction History
http://s1.postimg.org/mqp6v59rj/image.png


Order Ticket:
http://s12.postimg.org/9782y5pj1/image.png

The orderticket is dynamic, you can type a new symbol, hit enter, and the order book will reflect that market.

Pending Orders: basically same GUI and column headers as transaction history, minus the position summary, plus the ability to cancel individual orders or all orders.

(the reason the menu is different from the normal mode, and support mode is because i created the support mode in a new project and forgot to change the "markets" header into "data")

I welcome any and all feedback. If there is something not there that you believe is important, let me know!
daybyter
Legendary
*
Offline Offline

Activity: 965
Merit: 1000


View Profile
February 10, 2014, 04:11:15 PM
 #4

I have to admit, that I don't really speak the language of the traders, but it seems we share quite some ideas. I welcome any other java coder anyway, so good luck with your project!

Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
February 10, 2014, 04:49:37 PM
 #5

Make sure to implement an actually used API (not your own implementation) like Bloomberg, OpenMAMDA, FIX or the likes...
It is very unlikely that people will want to use your Java client to trade, no matter how well it is designed.

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
daybyter
Legendary
*
Offline Offline

Activity: 965
Merit: 1000


View Profile
February 10, 2014, 05:14:00 PM
 #6

But it's really tricky to implement FIX and bitcoin exchanges unlike like the gox streaming API in the same app, because the structures are quite different. I was asked to add FIX to my implementations and it's a major task now.

hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
February 10, 2014, 07:47:41 PM
 #7

Make sure to implement an actually used API (not your own implementation) like Bloomberg, OpenMAMDA, FIX or the likes...
It is very unlikely that people will want to use your Java client to trade, no matter how well it is designed.


I don't quite understand the anti-java attitude... the largest derivatives platform in the world has a trader-facing java application as do some FX platforms (like Oanda). It would be no different than if I write a C# trader client. It would serve the same purpose. ie. The only function of the java client here is respond to challenge commands and reply and send one-way encrypted messages to the server.

My plan was to create a websocket API and create API keys such that traders could use the streaming websocket to execute/send/cancel orders as well as view balance information, etc. Kind of like REST without the callbacks and having to deal with http timeouts.

Appreciate the feedback and would like further insight on the anti-java attitude



Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
February 10, 2014, 10:07:50 PM
 #8

I wouldn't use your client if it were hand optimized Assembler written directly on HDD with a magnetized needle! Wink
This is not against Java (you just happen to write your client in Java), but against another API reinventing the wheel again.

Fact is, most people want to use their established trading clients they already know. Realistically people who code these clients will NOT develop a connector to your software with the n-th reinvention of a custom market API any time soon and people trading on your platform also will not have the few thousand USD lying around that it costs to have such a connector built.

There are industry standards out there for market data and trading APIs. Use them.

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
February 10, 2014, 10:19:11 PM
 #9

Thank you for pointing out FIX adapter integration. I will look into it or create a FIX translator between the API that has naturally evolved from writing the software. I understand the developer point-of-view and I will cater to that. But is there anything wrong with a end-user java thin-client for point-and-click trading?

Feedback appreciated.
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1006


View Profile
February 10, 2014, 10:26:07 PM
 #10

In my opinion it is just a waste of ressources to write a client in Java (as most people around here expect to use a browser anyways to trade on an exchange platform) and a web frontend and stanradrd conform API would work much better.

If you use standards, you can use any FIX enabled client anyways and you would have a hard time to compete with these while also coding a high throughput exchange engine that has to match orders etc.

Also please publish some performance numbers and include load tests and simulations, since this is very often a problem with "homemade" exchange engines.

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
February 10, 2014, 11:03:50 PM
 #11

In my opinion it is just a waste of ressources to write a client in Java (as most people around here expect to use a browser anyways to trade on an exchange platform) and a web frontend and stanradrd conform API would work much better.

If you use standards, you can use any FIX enabled client anyways and you would have a hard time to compete with these while also coding a high throughput exchange engine that has to match orders etc.

Also please publish some performance numbers and include load tests and simulations, since this is very often a problem with "homemade" exchange engines.

Why is it a waste of resource to provide a bare-bone client for users who want to point-and-click trade? Why is a browser better than a thin desktop client which would communicate with the server faster and more securely than a web-app using web-sockets which has poor user authentication?

Your stance is a little confusing to me because most of the vulnerabilities in java come from the web plugin.. yet the preference is on the web. Websockets by definition deal with untrusted clients... So what is more important? more security or easy to access and trade via a website?  I am not trying to "compete" in designing a front-end platform. Just bare-bone account statements, trading and handling withdraws. I'll happily provide other developers API access for market data (via websockets) to design custom charting software.


Feedback appreciated.
hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
February 22, 2014, 07:41:46 AM
 #12

Quick update. Been working on user GUI and tweaking for performance. Here's a updated depth of order book ticket and a short Order matching example.

http://www.youtube.com/watch?v=IFuIJUbFsD4


Appreciate any and all feedback

Thanks
BitApparel
Member
**
Offline Offline

Activity: 84
Merit: 10


View Profile
February 22, 2014, 08:08:19 AM
 #13

looks good, keep up good work!

$@$@$@$$@$------------------->>>          trade BTC/LTC leveraged @ bitfinex.com    AND

get 5% lifetime rebate!   use sign-up code   ------->       X1LTTXAjLV       PM after sign up !!!
Fireball
Hero Member
*****
Offline Offline

Activity: 674
Merit: 500


View Profile WWW
February 22, 2014, 09:34:51 PM
 #14

Maybe, you would be interested in developing a good desktop client for margin trading of futures contracts at ICBIT?

Margin trading platform OrderBook.net (ICBIT): https://orderbook.net
Follow us in Twitter: https://twitter.com/orderbooknet
hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
February 22, 2014, 10:48:40 PM
 #15

Maybe, you would be interested in developing a good desktop client for margin trading of futures contracts at ICBIT?

Yea I would be interested, let me know the details by PM.
knightcoin
Full Member
***
Offline Offline

Activity: 238
Merit: 100


Stand on the shoulders of giants


View Profile
February 23, 2014, 03:48:52 AM
 #16

Since I am always struggled to understand what people label as "real time"...; and I really haven't seen the code yet, I apologize any inconvenience of my question... but Is it possible to add a timestamp in order to calculate the time I hit buy/sell on client and the time that server accept it ? also measure network Latency (lag - Round-trip latency) ?

http://www.introversion.co.uk/
mit/x11 licence 18.x/16|o|3ffe ::71
hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
February 23, 2014, 05:33:13 AM
 #17

Since I am always struggled to understand what people label as "real time"...; and I really haven't seen the code yet, I apologize any inconvenience of my question... but Is it possible to add a timestamp in order to calculate the time I hit buy/sell on client and the time that server accept it ? also measure network Latency (lag - Round-trip latency) ?

I've done this and it's about 216 milliseconds.
hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
February 27, 2014, 06:13:31 AM
 #18

Hello again, I've made a lot of progress the last few days with further GUI tweaks to the client terminal and speeding up the server-side order handling. I believe the software is semi-production ready (exception: I need to still add charting functionality and create a automated trading facility-- other than that, the core functions are 100% operational). And thus, I am looking for beta testers (preferably traders) who are interested in testing and providing feedback for additional functionality. You may PM me or give a nod on the thread and I will get back to you with the details on how to get started Smiley

kittucrypt
Sr. Member
****
Offline Offline

Activity: 300
Merit: 253

Ok Check!


View Profile
March 03, 2014, 04:54:46 AM
 #19

Hello again, I've made a lot of progress the last few days with further GUI tweaks to the client terminal and speeding up the server-side order handling. I believe the software is semi-production ready (exception: I need to still add charting functionality and create a automated trading facility-- other than that, the core functions are 100% operational). And thus, I am looking for beta testers (preferably traders) who are interested in testing and providing feedback for additional functionality. You may PM me or give a nod on the thread and I will get back to you with the details on how to get started Smiley



I can help you with beta testing. Real life trader.

hexs (OP)
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
March 04, 2014, 12:09:06 AM
 #20

Since I am always struggled to understand what people label as "real time"...; and I really haven't seen the code yet, I apologize any inconvenience of my question... but Is it possible to add a timestamp in order to calculate the time I hit buy/sell on client and the time that server accept it ? also measure network Latency (lag - Round-trip latency) ?

I've done this and it's about 216 milliseconds.


Server side response has been significantly improved from 216 millisecond on average to roughly ~4 millisecond response. (be aware that both of these tests were run from a client on the local network (on one PC) testing the server (which is also on the local network, but separate PC).

Also, I am in the process of acquiring a dual-core XEON with 72Gb memory as 1-node of the exchange back-end with offline storage of private information.
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!