Update to Technical Price Dashboard

in #utopian-io8 years ago (edited)

8B3A3159-049F-458F-A87C-14A0C0E010C9.jpeg

Summary

I’ve made a number of key updates to the dashboard (located at http://35.229.125.96/ with username: Matt and password: m@tt!) in the last two weeks. If you would like review the previous update and original proposal, click on the links below:

The first update is that I’ve increased the number of currencies included in the dashboard from 25 to all Bitcoin markets on Bittrex (200+ currencies). The original proposal included 25 currencies. This means that the full order history for all Bitcoin markets is being saved to the database. The full list can be viewed in the bittrex.py file in the project Github repository (brophymj/bitgeek). The order history for all coins can be downloaded in the Reports Generator (screenshot below).

991D7813-7242-4D1D-BC9A-686A8F17F820.jpeg

As before, you can enter the start and end date, and coin code to retrieve the order history for that period (see below). The file will be downloaded as a CSV.

B2EE98BC-6374-4F6C-9E30-2DB85841A788.jpeg

Note: the additional coins have been populating the database since yesterday (08/02/2018). The 25 original currencies have been updating since the 23rd January. There are now over 2million records in the DB.

The graph feature is now also available for all 200+ coins. In addition, I spotted an issue with the MACD graph. The first EMA point in the graph should be set as a moving average of the last 26/12 points. In the original dashboard, the first EMA point was assuming the EMA for the previous period was 0 which was creating a distortion in the graph (a hump appearing at the start of the graphs).

Ripple (XRP) was one of the currencies added – I’ve included a screenshot of the MACD using 5-minute intervals below:

20088392-8864-4FD9-A214-B5E4CE3BEA51.jpeg

You can specify the interval of the analysis (1/5/10/30/60mins) and pick a historic end point for the graph (or just get the latest view). The Bearish/Bullish indicator will let you know if the price is trending upwards or downwards.

Addition of Data Centre Menu

This is the main change in this Update post. While it’s very useful to have the order history at the most detailed level, I found I was doing adjustments to the data before I could analyse it properly. After downloading the data, I would normally have to:

  • Summarize the data into intervals of 1 min/ 5 min etc.

  • Calculate a weighted average price for the period

  • Fill in dummy rows where the data was missing. This might seems small but it was a headache to update! There is often data gaps (particularly for the lower volume coins) where there won’t be an order for 5/10 minutes.

  • Download a separate file for each currency

I’ve addressed all of these issues in this update by adding the Data Center menu item, which looks like:

ECE6C5C8-D390-462C-A76F-B7E11DF8672D.jpeg

I’m generally interested in aggregated data i.e. analysing patterns across multiple coins. We can now download the data for all coins together by leaving the Coin Input as blank.

When you download data from the data centre, you can select the interval you want, the date range and a CSV file will be saved the Data Center page for 24 hours. It can take a while to download, so you can log out, get a cup of tea and log back in later to see your downloaded file. The screenshot below shows the file sitting in the Data Center page ready to be downloaded to your computer. In this case, I’ve downloaded data for all coins, using 10-minute intervals in the 24 hour period to 15:39 on the 9th February.

34046906-1876-4CB6-ABCD-0879454082EA.jpeg

The file above has 27k rows and looks like this:

00513D6B-D7DE-4F49-9EA3-5C0EE3AB15A8.jpeg

For the dummy rows, I assume the price is equal to the last traded price and the volume is 0. You will see the download also contains the MACD fields allowing you to graph the MACD (if you’re interested).

Key Code Updates

The code is all available in the GitHub repository. Below are extracts of the key additions:

The code below created dummy records where there are gaps in data.


pipeline =\
            [{"$match":
              {'TimeStamp':
               {"$lt":
                (datetime.strptime(todate,
                                   '%m/%d/%Y %I:%M %p'
                                   ) + timedelta(minutes=1)
                 ).strftime('%Y-%m-%dT%H:%M'),
                "$gte":
                datetime.strptime(fromdate,
                                  '%m/%d/%Y %I:%M %p'
                                  ).strftime('%Y-%m-%dT%H:%M')},
               'Pair': coin
               }
              },
             {"$group":
                {"_id":
                 {'datehours':
                  {"$arrayElemAt":
                   [
                       {"$split":
                        ["$TimeStamp",
                         ':'
                         ]
                        }, 0]
                   },
                  'minutes':
                  {"$arrayElemAt":
                   [
                       {"$split":
                        ["$TimeStamp", ':']
                        }, 1]
                   }
                  },
                 "sum_quantity":
                 {
                     "$sum":
                     "$Quantity"
                 },
                 "sum_total":
                 {
                     "$sum":
                     "$Total"
                 }
                 }
              },
             {"$project":
              {"_id": 1,
               "sum_quantity": 1,
               "sum_total": 1,
               "price":
               {"$divide":
                [
                    "$sum_total",
                    "$sum_quantity"
                ]
                }
               }
              },
             {"$sort": SON([("_id", -1)])
              }
             ]
 

The code below creates the CSV file that sits in the Data Center page for 24 hours:


def datacenter_report(interval, todate, coin, fast, slow, signal, fromdate):
    """Generate report and CSV file for datacenter endpoint."""
    if coin:
        path = [timing(fromdate), timing(todate), coin, str(interval)]
    else:
        path = [timing(fromdate), timing(todate), 'ALL', str(interval)]
    filepath = '-'.join(path).replace(':', '-')
    with open('archive/{}.csv'.format(filepath), 'w') as dump:
        fieldnames = ['pair', 'interval', 'datetime', 'date',
                      'time', 'volume',
                      'price', 'ema_fast', 'ema_slow', 'macd',
                      'signal_line', 'macd_hist']
        writer = csv.DictWriter(
            dump, fieldnames=fieldnames, extrasaction='ignore')
        writer.writeheader()
        if coin:
            [writer.writerow(i) for i in summarize(
                interval, todate, coin, fast, slow, signal, fromdate)]
        else:
            for c in coins_list:
                try:
                    [writer.writerow(i) for i in summarize(
                        interval, todate, c, fast, slow, signal, fromdate)]
                except:
                    pass
    return filepath
 

The code for the bug fix is:


        if not fromdate:
            generator = b[::-1][:interval * 67][::interval]
            summarized = generator[:40]
            ema_basic_slow =\
                sum([Decimal(i['price']) for i in generator[41:]])\
                / Decimal(len(generator[41:]))
            ema_basic_fast =\
                sum([Decimal(i['price']) for i in generator[41:53]])\
                / Decimal(len(generator[41:53]))
        else:
 

Benefits/Uses of this Update

This project started as a personal interest of mine, which is modelling future cryptocurrency prices. The volatility and irrationality of crypo markets creates (in my opinion) opportunities to gain from buying and selling at the rights times. I’m interested in whether huge intra-day spikes are predictive and if there are signals which can be generated that will inform you of a likely upcoming changes in the direction of the price.

So, the main use is data analysis and modelling. You don’t have to be a rocket scientist to do this, you can download the data, create a few graphs and inspect for yourself. You might see something that looks like a predictor and build a model around that predictor and test it.

If I could summarise this phase of the project I would say building a toolkit to do the necessary data analysis. The next stage is modelling and actually parameterising a model that will let you know when (according to your model) to get in or out.

Next Steps

For the next update, I’d like to incorporate additional graphs that will also feed into the data downloads and help with the analysis part. The graphs I intend to add in the next update are:

  • Relative Strength Index

  • Bollinger Bands

How to get involved

As with the previous posts, I’d love to hear your feedback and thoughts on this. In particular, if you had insights into approaches to analysing the data, I’d be really interested in hearing them.

Also, some feedback on the updates (good and bad) would be very welcome.

Many thanks for your attention.


Picture Source: Pixabay.com



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @bitgeek I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

I haven't used this but I do see potential on the tool. Besides being a TA tool, I think it would be best if you run a contest for TAs and post their analysis in STEEMIT using your tool and run a daily or weekly contest for this.

The one with the highest profit at the end of, let's say, 7days will get the prize. Perhaps prizes foe a 2nd and 3rd runner ups as well.

Hi eastmael. Thanks for your suggestion. I hadn’t thought of that but I think it’s an excellent idea and a brilliant way to get people involved in the project and spread the word. I’ll think about how I would go about it.

Also, I'd like to work with this if time permits. I'm kind of frustrated with the limited tools in bittrex particularly as simple as drawing support and resistance lines. As much as possible,I'd like to have live price feeds for charting. Do you have these in the pipeline for this project? Plus the basic of drawing candles.

I'd like to submit these as suggestions to Utopian if you don't mind.

Absolutely! At the moment I’m doing analysis of the data and I hope to build in some mechanism linked to a model to send notifications (by email for example) when the model detects a significant change in price/vol

You’ve been a busy boy. Well done mate thanks for all the time and effort you’ve been putting in

Thanks for the feedback, hopefully some will find it useful. What do you think of eastmael’s suggestion (comment above)?

Yeah, sounds like a good idea. Any thing that creates more interaction on this platform is good for everyone one. If it were me doing it the hardest part would be finding the time to organise and get everything together.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Many Thanks Vladimir-simovic, delighted to get approved!

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.100
BTC 64196.35
ETH 1800.98
USDT 1.00
SBD 0.38