It’s been a week! Fees and a script

Hi Guys,

7th post after seven days, means I’m writing every day since a week! Yay! Super first milestone achieved.

Let’s analyze fees used on GDax exchange:

When you place an order at the market price that gets filled immediately, you are considered a taker and will pay a fee between 0.10% and 0.30%.

When you place an order which is not immediately matched by an existing order, that order is placed on the order book. If another customer places an order that matches yours, you are considered the maker and your fee will be 0%.

When you place an order that gets partially matched immediately, you pay a taker fee for that portion. The remainder of the order is placed on the order book and, when matched, is considered a maker order. The fee is 0% for that part of the total order.

So in theory if I understand above correct if I place a sell order with slightly higher price than maximum buy price and after some time my order is cleared (assuming price is rising) fee won’t be charged. And vice versa if I place a buy order with slightly smaller price than minimal sell price and after some time price drops I’m also not charged any fees.

It sounds good. I actually would like to verify that on my own, so once I’m ready to invest first amount I’ll ensure to make a few manual transactions and carefully analyze numbers.

Coming back to an idea from yesterday I also want to verify with a very simplified assumptions if it makes sense to make a lot of transactions over a period of let’s say 48 hours. Yes – data is still comming in and I have more and more data. As of now database holds information of more than 240 thousands of trades that took place. So the script would be as simple as that:

  • start 48 hours ago
  • buy crypto for $100 at a price of closest transaction (im ignoring volume for this POC)
  • sell all crypto if price goes up by X%  (let’s say 0.1%)
  • buy cryptocoins when price goes down below or equal of first transaction
  • repeat

I’m also ignoring rising or falling trends and much more, but for the sake of this super simple little POC I’m willing to quickly create a script and find out results on real transactional, historical data. Let’s do it.

Body of the script:

(pasting image as I can’t force wordpress to properly format php code. I would need to upgrade to a paid plan in order to have php formatting plugin. I’ll do that after reaching 30 posts.)

Przechwytywanie

And output:

Starting at time = 2018-07-09 20:41:07, balanceUSD=100
Buying at price 6702.10009766, new balanceBTC=0.014920696280695
Selling at price 6709.08984375, new balanceUSD = 100.10429187849, time = 2018-07-09 21:44:22
I got 100.10429187849 dollars
Buying at price 6702.00000000, new balanceBTC = 0.014936480435465, time = 2018-07-09 21:51:34
Selling at price 6709.99023438, new balanceUSD = 100.22363785798, time = 2018-07-09 21:59:39
I got 100.22363785798 dollars
Buying at price 6701.20996094, new balanceBTC = 0.014956050988129, time = 2018-07-09 22:26:30
Selling at price 6708.04003906, new balanceUSD = 100.3257888546, time = 2018-07-09 22:40:24
I got 100.3257888546 dollars
Buying at price 6701.97021484, new balanceBTC = 0.014969596348317, time = 2018-07-09 22:42:21

Well. I definetely need to tweak this very first assumptions, as results are not encouraging to say the most.. Virtual profit of 0.3% after 2 days of trading.. Not good!

That being said I modified buy condition from:

if( $row[ 'price' ] <= $firstPrice && $balanceUSD > 0 ) { // buying

to:

if( $row[ 'price' ] <= $lastPrice && $balanceUSD > 0 ) { // buying

and results are as follows:


Starting at time = 2018-07-09 20:53:01, balanceUSD=100
Buying at price 6701.00976562, new balanceBTC=0.014923124051103
Selling at price 6709.08984375, new balanceUSD = 100.12058000828, time = 2018-07-09 21:44:22
I got 100.12058000828 dollars
Buying at price 6709.08984375, new balanceBTC = 0.014923124051103, time = 2018-07-09 21:44:22
Selling at price 6716.99023438, new balanceUSD = 100.2384785177, time = 2018-07-09 22:00:45
I got 100.2384785177 dollars
Buying at price 6716.99023438, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:00:45
Selling at price 6723.70996094, new balanceUSD = 100.33875783074, time = 2018-07-09 22:09:58
I got 100.33875783074 dollars
Buying at price 6723.70996094, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:09:58
Selling at price 6730.45019531, new balanceUSD = 100.43934318438, time = 2018-07-09 22:10:12
I got 100.43934318438 dollars
Buying at price 6730.45019531, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:10:12
Selling at price 6738.25000000, new balanceUSD = 100.55574063734, time = 2018-07-09 22:10:19
I got 100.55574063734 dollars
Buying at price 6738.25000000, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:10:19
Selling at price 6745.29980469, new balanceUSD = 100.66094574727, time = 2018-07-09 22:10:32
I got 100.66094574727 dollars
Buying at price 6745.29980469, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:10:32
Selling at price 6757.75976562, new balanceUSD = 100.8468872899, time = 2018-07-09 22:10:39
I got 100.8468872899 dollars
Buying at price 6757.75976562, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:10:39
Selling at price 6776.99023438, new balanceUSD = 101.13386596077, time = 2018-07-09 22:10:44
I got 101.13386596077 dollars
Buying at price 6776.99023438, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:10:44
Selling at price 6787.99023438, new balanceUSD = 101.29802032533, time = 2018-07-09 22:11:00
I got 101.29802032533 dollars
Buying at price 6787.99023438, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:11:00
Selling at price 6794.81982422, new balanceUSD = 101.39993914173, time = 2018-07-09 22:11:21
I got 101.39993914173 dollars
Buying at price 6794.81982422, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:11:21
Selling at price 6805.87988281, new balanceUSD = 101.56498976808, time = 2018-07-09 22:11:26
I got 101.56498976808 dollars
Buying at price 6805.87988281, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:11:26
Selling at price 6813.35009766, new balanceUSD = 101.67646871098, time = 2018-07-09 22:11:41
I got 101.67646871098 dollars
Buying at price 6813.35009766, new balanceBTC = 0.014923124051103, time = 2018-07-09 22:11:41l

Much better. I virtually just made 1% profit 🙂

Thanks for reading,
Łukasz.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s