Arbitrage Bot UML Diagram

In a nutshell.

  1. Bot Class will be the main class.
  2. Bot will call the constructor for Exchange(Both subclass).
  3. Exchange Subclass will call the fileHandler class to get its endPoint, ApiKey and API secret which it will than go into the garbage collector once Exchange subclass is being instantiated.
  4. Bot Class will then call the getOrderBook Method for both exchanges .
  5. The methods of the subclasses for exchanges might need to go through the hashingAndEncoding class to hash and encode their HTTP Request before posting.
  6. Once the JSON returns back, and goes back into the Bot Main class, decision maker will be called to place order, cancel order or do nothing.



Working With API – Part 2

So far working with the Gemini APIs sample codes are all python codes, shell scripts samples in Gemini. These 2 are not the most popular coding languages and they are environment specific. Yesterday as I was browsing FYB-SG website, I noticed that there were code samples for Java, Ruby, Go etc being automatically generated by a software called Apiary for it’s API



In order to understand more about how API works, and for generating the source codes automatically, download the program POSTMAN

Postman link

The below shows how to navigate Gemini for it’s more complicated API for eg some orders which require authentication to the server.

  1. Let us use 1 example (Get available balance), the rest of the examples will be similar except the changing of some variables. From the API below, you know that in order to get available balance, you will need to post to /v1/balances

get_avail-balance2. Next let us see how the POST request is being structured. Because the private API requires authentication, this will be more complicated than compared to the previous public API. The instructions on Gemini website states that the request need to be send with a payload, the structure of the sample payload is below. Do note that the below is just a sample payload and not all payload will need an order_id. We will also need a nounce and they explained what a nounce is below. A nounce is simply just a number generated programatically and must increase incrementally as and when my API connects to Gemini. You can simply just use a running number counter for testing purposes.


3. After constructing the payload. The documentation informs us that the payload created in step 2 will need to be encoded in base64 and then passed to a key  of X-Gemini-Payload of the header in JSON format. We will need to pass the JSON created in step 2 to a program to encode it in base64.

payload - api 2

4. After encoding in base64, we use the string and copy into POSTMAN to get ready for testing purposes. We change the function to POST as Gemini tells us that this private API uses the post request. from the header, we enter in the format that gemini tells us from the documentation and pass in the encoded payload.



5. Now from the documentation, there are 2 more variables to fill in, the api key and the signature.

api key and secret


6. Now make sure all the variables are placed correctly and then click on send to test out this Request.

postman good to go


7. If it is successful, the body of the response will have a JSON reply

json reply

8.Now POSTMAN can generate out the source code of this request automatically. Click on the code and you can copy the code to be used

postman generate code





Working with API – Part 1

Working with API has been a tremendous steep learning curve so far. This is to document the How to work with API.

The example that is shown below is from Gemini API. Part 1 will be the usage of the public API. The Public API does not require authentication to the Gemini Server which means that you will not need to create an API key for this tutorial.

What is an API

There is a comprehensive article on API on medium below.

What is an API

What is REST

There is a comprehensive article on what is REST on medium below.

What is REST

If you TLDR :  Just know that it is simply just an architecture which is stateless,  meaning that the server does not need to know anything about what state the client is in and vice versa. In this way, both the server and the client can understand any message received, even without seeing previous messages.

There are other architecture such as SOAP or GraphQL which some crypto exchanges are using.

Why API?

Why is there a need for an API. Let us go into an example.

  1. When you go into the website : browser knows that you are requesting for this page from and there will be a request to get the page from stackoverflow.
  2. Now go to right click on the web page and click on view page source. The page is rendered like this with the proper alignment etc so the viewer can view the page in human readable format.

browser http request

3. However even though it is in human readable format, for the programmer, or program, there are too many extra things such as the alignment of buttons etc which we do not need if we want to program a software to do automation. These extra stuff are the things which are making it difficult for us to Parse the whole HTML document.

4. So here comes API to the rescue. API is merely something coded at the back end by the server owner to open up some resources back to the querier in machine readable format such as XML or JSON.


5. To start navigating APIs, you will need to know what is the endpoint. Using gemini exchange as an example, You can browse to this link below.

What this means is that Gemini have coded a method that if you tell the computer browser / program to access this end point, it will return the computer some machine readable data.


Let’s try this example. The browser returns back a JSON file which can be easily parsed by a JSON parser program. The Sandbox means it is a test environment for people to play around before deployment to production.

api return JSON


6. For another example, if I want to create an arbitrage bot which checks Gemini for its bid and ask spread. I will need to browse to Gemini API documentation on current book order. I know that the end point is

based on the documentation. However when we try we get a error. The API replies us with the supplied symbol is not a valid symbol. We then know that :symbol is a variable which we need to change to access the correct order book.



7. Let us change the :symbol to ethusd, as we wish to arbitrage eth usd. The program then returns a JSON file which the square brackets is being encapsulated by the Bids are all buy orders. The square brackets encapsulating the Asks are all sell orders. We can then parse this JSON file in our program to create our arbitrage bot.


I will be using Python 3.6 to program the Gemini API connectors etc

The connection to the respective API are created in my Gists. This is just bare connection codes to the respective exchanges, Coinut and Gemini




Bitcoin Dominance

Just got to know this index called the bitcoin dominance index.

  1. For the most part of its existence it was hovering at 80 plus % with only slight decline.
  2. It broke out of the gradual declining slope at around June 2017 and this coincides with Ethereum and Alt coins gaining dominance around the same periods.
  3. What is worth noting is that after breaking down, it went to to the previous support, the 4th lower low and this became resistance. At this point, it had a higher high and a higher low which looks like a breakout
  4. However the breakout was short lived as it was what in TA we consider as a false breakout. It went on to create lower highs and lower lows after the false breakout.

bitcoin dominance


btc dominance zoom in

Black arrow zoom in on Total Market Cap

mar-2017 to jun-2017

Black arrow zoom in on BTC Price

mar-2017 to jun-2017 - btc price

Summary on black arrow : BTC and Market cap was both rising when its dominance crashed. Haha this looks like some risk on when playing FX.


Green arrow zoom in on both total market cap and btc price

july-2017 todec-2017 - btc price

Summary on green arrow : BTC price and market cap was both increasing. However this increase caused the BTC dominance to crash

Red arrow zoomed in on BTC price and total market cap

Dec-2017 tojan-2018 - btc price

Summary on red arrow : BTC price and market cap was both sideways. However this increase caused the BTC dominance to crash


Summary :

  1. BTC dominance takes a long time to build up but just a short while to crash
  2. There is no reason of why the dominance crashed as all 3 scenarios are kinda random in nature
  3. When sideways price is causing the dominance to crash it might mean one thing. It’s freaking risk on and people are feeling lucky to roll the dice at the casino.
  4. Overall the trend is lower. Based on this dominance chart, it makes sense to reduce your BTC, however the crypto market is full of black swans, there is a high chance this statement will not hold for long.
  5. BTC dominance hit previous support and it became resistance and crashed down. Will it be likely that was due to “old minds” still hanging onto the belief that BTC is still king and wanted to make a quick punt? As the crash down was too rapid.

Only time can tell. Lets analyse and stay tune.

Neo / Gas Ratio Analysis

Gas to neo ratio has been on a downward trend, making lower lows and lower highs until recently where it broke out of the lower high. Judging from the almost similar low, it is poised to go to either a sideways of a breakout trade.

gas to neo ratio

There were a few instances where gas price hit 90% -102% of neo price.

gas anomaly price

Lets try finding out in august, september and october what was causing the spike in gas price.


Gas listed in binance

September / October

Palm beach report on Gas being the most undervalued crypto

These both are very black swan events and are unlikely to reoccur, so the odds of it hitting 1-1 to Neo for these exact 2 events are very low. However as crypto is a very black swan market, it is safe to say that it is damn possible for them to cook up another story of how Gas is damn useful etc……

Now for the purists who prefer the neo to gas chart

neo to gas

View story at

View story at

View story at

View story at

View story at