Author

Topic: Margin Trading Exchange Software (Read 4202 times)

newbie
Activity: 41
Merit: 0
June 27, 2014, 06:17:18 PM
#36
Websocket API is now available.

Create a websocket variable in javascript and send messages in this format:

EKEY||||

IN this example, API_KEY = 1.


1). Request Orderbook:

Send this message to websocket server: EKEY|1|RFQ|XBT.USD|


And the response will be:


Acknowledged
{"XBT.USD":[{"sellOrder":[]},{"buyOrder":[]}]}



2). Request Account Snapshot:

Send this message to websocket server: EKEY|1|BALANCE|

And the response will be:


Acknowledged
{"account_snapshot":[{"gross_balance":"500"},{"profit_loss":"0"},{"total_fees":"0"},{"net_balance":"500"},{"used_margin":"0"},{"free_margin":"500"}]}



ORDER ENTRY MESSAGE FORMAT: EKEY|||||

3). Limit Buy Order Request:


Send this message to websocket server: EKEY|1|LIMITBUY|2.55|1|XBT.USD|

And the response will be:


Acknowledged
{"XBT.USD":[{"sellOrder":[]},{"buyOrder":[{"p":"2.55","q":"1"}]}]}
{"account_snapshot":[{"gross_balance":"500"},{"profit_loss":"0"},{"total_fees":"0"},{"net_balance":"500"},{"used_margin":"25"},
{"free_margin":"475"}]}





4). Limit Sell Order Request:

Send this message to websocket server  EKEY|1|LIMITSELL|2.65|1|XBT.USD|
The response will be:



Acknowledged
{"XBT.USD":[{"sellOrder":[{"p":"2.65","q":"1"}]},{"buyOrder":[{"p":"2.55","q":"1"}]}]}
{"account_snapshot":[{"gross_balance":"500"},{"profit_loss":"0"},{"total_fees":"0"},{"net_balance":"500"},{"used_margin":"0"},{"free_margin":"500"}]}




5). Stop Buy & Stop Sell Request: Similar to above, but replace with
The response will only include the account_snapshot response.


Now, in this example, lets say another trader put an offer below the current best. 2 contracts @ 2.64 (through the platform). The websocket will push this message to you when a limit orderbook has been modified.

{"XBT.USD":[{"sellOrder":[{"p":"2.64","q":"2"},{"p":"2.65","q":"1"}]},{"buyOrder":[{"p":"2.55","q":"1"}]}]}


6). Market Buy & Market Sell Request: Again, similar to above, replace with -- You must still include a price, quantity and symbol parameter. If the best market offer is 2.65 and you instead send "EKEY||MARKETBUY|7|1|XBT.USD| -- you will still be executed at 2.65. (ie. the price parameter is ignored, but MUST still be included).

So using the API key, you send an order to buy 1 lot at market.

EKEY|1|MARKETBUY|2.90|1|XBT.USD|

The response will be:

Acknowledged
{"last_trade":[{"execTime":"1403910347545"},{"productSymbol":"XBT.USD"},{"execSide":"true"},{"execPrice":"2.64"},{"execQty":"1"}]}
{"XBT.USD":[{"sellOrder":[{"p":"2.64","q":"1"},{"p":"2.65","q":"1"}]},{"buyOrder":[{"p":"2.55","q":"1"}]}]}


The socket does not push your position information to you. You must populate your position by requesting all executed transactions on your account by doing the following:

7). Viewing transaction history:
Send this message to websocket server  EKEY|1|FILLED|
The response will be:


Acknowledged
{"tx_filled":[{"4c1593f619fa259ceb517ccdcce1fd96":[{"entry_time":"1403910347545","productSymbol":"XBT.USD","exec_side":"true","exec_price":"2.64","exec_qty":"1","exec_margin":"25","exec_fee":"1"}]},{"4c1593f619fa259ceb517ccdcce1fd96":[{"entry_time":"1403917072567","productSymbol":"XBT.USD","exec_side":"true","exec_price":"2.64","exec_qty":"1","exec_margin":"25","exec_fee":"1"}]}]}



8 ). Viewing Pending Orders

Send this message to websocket server  EKEY|1|PENDING|
The response will be:



Acknowledged
{"tx_pending":[{"cc84f039526ac12fab12cc7d6c4577d7":[{"entry_time":"1403918865034","productSymbol":"XBT.USD","tx_side":"true","tx_price":"2.55","tx_qty":"1","tx_margin":"25","tx_fee":"1"}]},{"678d648f1b8b8c9b1fc28a6fc276ec1":[{"entry_time":"1403918867612","productSymbol":"XBT.USD","tx_side":"false","tx_price":"2.65","tx_qty":"1","tx_margin":"25","tx_fee":"1"}]}]}



9. Cancelling Orders

To cancel a single order you must pass the tx_id of the pending order

EKEY|1|CANCEL_ID|f566025b38ac54b6dfa13d46f20d22c8|

The response will be:

Acknowledged
{"XBT.USD":[{"sellOrder":[{"p":"2.64","q":"1"}]},{"buyOrder":[{"p":"2.55","q":"1"}]}]}
{"account_snapshot":[{"gross_balance":"500"},{"profit_loss":"0"},{"total_fees":"1"},{"net_balance":"499"},{"used_margin":"25"},{"free_margin":"474"}]}


To cancel all orders, just pass this message:

EKEY|1|CANCEL_ALL|

The response will be:
Acknowledged
{"XBT.USD":[{"sellOrder":[{"p":"2.64","q":"1"}]},{"buyOrder":[]}]}
{"XBT.CAD":[{"sellOrder":[]},{"buyOrder":[]}]}
{"XBT.EUR":[{"sellOrder":[]},{"buyOrder":[]}]}
{"XBT.GBP":[{"sellOrder":[]},{"buyOrder":[]}]}
{"XBT.AUD":[{"sellOrder":[]},{"buyOrder":[]}]}
{"XBT.CHF":[{"sellOrder":[]},{"buyOrder":[]}]}
{"XBT.NZD":[{"sellOrder":[]},{"buyOrder":[]}]}
{"XBT.JPY":[{"sellOrder":[]},{"buyOrder":[]}]}
{"BTC.USD":[{"sellOrder":[]},{"buyOrder":[]}]}
{"account_snapshot":[{"gross_balance":"500"},{"profit_loss":"0"},{"total_fees":"1"},{"net_balance":"499"},{"used_margin":"25"},{"free_margin":"474"}]}


Keeping it very simple, all messages encrypted with SSL 128 bit encryption using TLS 1.2.

Let me know if you have questions!
newbie
Activity: 41
Merit: 0
June 26, 2014, 03:15:51 AM
#35
is this only for windows?


Java is platform independent; this means you don't need windows to operate Smiley. Any machine where you can install Java/JVM will work!

Let me know if you have any more questions
hero member
Activity: 882
Merit: 501
Ching-Chang;Ding-Dong
June 22, 2014, 02:04:19 PM
#34
is this only for windows?
full member
Activity: 238
Merit: 100
Stand on the shoulders of giants
June 10, 2014, 04:21:18 PM
#32
Gosh, I made acompliment to supporting the developer I have my post deleted .. if you check there is another post witch did the same .. I think it's getting personal ... I don't even not interested anymore .. I could be a client or new user, customer ... People should learn how to run a business..

PS-going to buy a voodoo doll just in case ...

Now this is off topic
newbie
Activity: 41
Merit: 0
June 10, 2014, 01:55:28 PM
#31
interesting

thank you; is there anything I can do to make it more interesting ? Smiley


Features of the Platform:

1). Web of Trust '2FA' - Link web of trust ID# to your exchange account, all trading and account functions are rejected unless you are currently verified with 'gribble' on web of trust.  Web of trust ID and exchange account ID do not need to be the same.

2). Every command (from buy, sell, view position, view pending orders) initiated through the platform triggers a handshake protocol with the server which is unique to that session. At every moment the server 'knows' what commands the client is able to send to the server; and thus attempts to circumvent the system is immediately detected and user punished swiftly.

3). Automated trading - if you don't want to use the platform and want to make your own, you can request API trading to be enabled for your account an API key will be issued which you can link via COINIGY and use their main trading API (which handles order execution for several crypto exchanges) to submit or cancel trades. You cant request withdraws using the key... only trade related functions and execution reports are allowed.

4). Very 'brand-able'; can plug in just about any crypto currency and enable margin trading. ( I plan to do the top 5 cryptos )


If anyone is interested in leasing the exchange for a particular *coin , let me know and we can work something out. I will also consider selling exclusive rights to software for the right price.
newbie
Activity: 41
Merit: 0
June 09, 2014, 08:41:02 PM
#30
Latest updates and screenshots on this project... i am planning on taking this live soon as i've gotten good feedback from the users who have demoed.

Below is the main dock window which fits in everything you would need to trade on one screen. Tabs on buttom (transfers, position, history, etc) cycle through the views ('position view' is selected in the screen shot). You can also 'popup' the transfer, position, history and pending views on their own separate windows, same with orderbooks. The data panel also shows the 24 hr average prices for BTC against 8 different currencies. These prices would used as settlement prices when contracts expire.

http://s27.postimg.org/9mvfjmm9v/main1.png


The un-docked orderbook has a time & sales window.

http://s28.postimg.org/g4s485y65/main2.png




comments / feedback appreicted
newbie
Activity: 41
Merit: 0
May 10, 2014, 05:57:29 PM
#29
slight update;

1). I intend to run a simulated version as well as a production version. both will be available soon. I am getting everything in order, (compliance, ddos-mitigation, etc).

2). Because the focus of this project was fast & reliable order matching. I've created a bare-bone java desktop application client to connect to the server for execution purposes only. and again there are no fancy bells and whistles, just basic account information and order execution. Charting and web execution (for the java paranoid) will be provided by coinigy; working with them currently to support the exchange feed. I believe they are launching the beta soon and are a exchange-neutral platform.

3). Because I am located in the USA, production version will require customer compliance with verification/KYC policies before account can be opened. In a nutshell: the information that will be required from a patron is basically the same information required to open a library card.
newbie
Activity: 41
Merit: 0
April 28, 2014, 04:01:57 AM
#28
Count me in hexs.

Will beta be with real funds we bring in or simulated funds?


simulated. no real funds at risk
full member
Activity: 198
Merit: 102
April 27, 2014, 07:16:56 AM
#27
Count me in hexs.

Will beta be with real funds we bring in or simulated funds?
newbie
Activity: 41
Merit: 0
April 12, 2014, 02:37:46 PM
#26
need 10 more testers. 40/50 filled and don't mind over filling

Finalized front-end GUI and now porting it back to the core exchange engine. notification for those who opt'ed in for beta will go out shortly. beta will run for 2 - 6 weeks to collect user-feed back which will be used to finalize the production version.

newbie
Activity: 41
Merit: 0
March 16, 2014, 10:09:45 PM
#25
bump

still looking for more testers, expecting beta to be running by next saturday. total 19 signed up so far, looking to have atleast 50. PM me for details! thx
newbie
Activity: 41
Merit: 0
March 09, 2014, 08:20:59 PM
#24
Are you still looking for testers? Do you have the updated screenshots?


Added you to the list. Screenshots coming soon...
hero member
Activity: 882
Merit: 501
Ching-Chang;Ding-Dong
March 09, 2014, 04:38:55 PM
#23
I'm down to help beta test, i think this could be useul.
newbie
Activity: 1
Merit: 0
March 09, 2014, 02:47:17 PM
#22
Are you still looking for testers? Do you have the updated screenshots?
newbie
Activity: 41
Merit: 0
March 06, 2014, 12:59:13 AM
#21
I have total of 11 people interested so far. I would like to reach minimum 50 testers, if possible, so let me know if you are interested. The new version will not be a tool bar anymore, and will be 1 window full screen application.

Functionality added/pending: (from feedback testing with friends and family):

1). Client Application is now a full-screen window with the option to show information in separate windows.
2). Master and sub accounts. \ seperate accounts by strategy, etc.
3). Market states (halted, trading, settled/expired)
4). YubiKEY integration (pending)
5). WoT gribble verification (optional setting)
6). Automated Trading System facility
7). Community generated news/research portal
Cool. Working on charting option with studies, may integrate chartiq (looking at options)


Screens coming soon  Smiley
newbie
Activity: 41
Merit: 0
March 03, 2014, 07:09:06 PM
#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.
sr. member
Activity: 300
Merit: 253
Ok Check!
March 02, 2014, 11:54:46 PM
#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.
newbie
Activity: 41
Merit: 0
February 27, 2014, 01: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

newbie
Activity: 41
Merit: 0
February 23, 2014, 12: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.
full member
Activity: 238
Merit: 100
Stand on the shoulders of giants
February 22, 2014, 10:48:52 PM
#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) ?
newbie
Activity: 41
Merit: 0
February 22, 2014, 05: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.
hero member
Activity: 674
Merit: 500
February 22, 2014, 04:34:51 PM
#14
Maybe, you would be interested in developing a good desktop client for margin trading of futures contracts at ICBIT?
member
Activity: 84
Merit: 10
February 22, 2014, 03:08:19 AM
#13
looks good, keep up good work!
newbie
Activity: 41
Merit: 0
February 22, 2014, 02: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
newbie
Activity: 41
Merit: 0
February 10, 2014, 06: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.
legendary
Activity: 2618
Merit: 1007
February 10, 2014, 05: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.
newbie
Activity: 41
Merit: 0
February 10, 2014, 05: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.
legendary
Activity: 2618
Merit: 1007
February 10, 2014, 05: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.
newbie
Activity: 41
Merit: 0
February 10, 2014, 02: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



legendary
Activity: 965
Merit: 1000
February 10, 2014, 12: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.
legendary
Activity: 2618
Merit: 1007
February 10, 2014, 11:49:37 AM
#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.
legendary
Activity: 965
Merit: 1000
February 10, 2014, 11:11:15 AM
#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!
newbie
Activity: 41
Merit: 0
February 09, 2014, 07:47:28 PM
#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!
full member
Activity: 227
Merit: 100
January 31, 2014, 10:25:46 AM
#2
Sounds promising so far. 

Following.
newbie
Activity: 41
Merit: 0
January 30, 2014, 12:03:17 PM
#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!
Jump to: