Git Product home page Git Product logo

prices's People

Contributors

dependabot[bot] avatar zahin-mohammad avatar

Stargazers

 avatar  avatar

Forkers

javiercaamano

prices's Issues

Dockerize the App

Create a docker file for the application to docker-ize the entire application and all it's dependencies.

Implement Better Logging

Currently we are using the default golang logger. I need to research what other logging frameworks exist.

Handle Fiat Currencies

Currently, we convert USD to USDT. This is clumsy, especially if an exchange supports both (FTX). We should instead just store both currencies.
The original thought behind converting USD to USDT was for ease of visualization, but thinking on it further, we should not actually modify the data like this.

Fail CB Tests

Currently, coinbase is failing the tests but the CI doesn't fail on these events.

--- FAIL: TestExchangeClients (113.54s)
    --- FAIL: TestExchangeClients/TestGetAllOHLCMarketData#02 (87.63s)
        exchange_clients_****.go:60: 
            	Error Trace:	exchange_clients_****.go:60
            	Error:      	Not equal: 
            	            	expected: 12000
            	            	actual  : 11951
            	Test:       	TestExchangeClients/TestGetAllOHLCMarketData#02
            	Messages:   	COINBASE
        exchange_clients_****.go:61: 
            	Error Trace:	exchange_clients_****.go:61
            	Error:      	Not equal: 
            	            	expected: "2021-01-01 00:00:00 +0000 UTC"
            	            	actual  : "2020-12-31 23:59:00 +0000 UTC"
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1 +1 @@
            	            	-2021-01-01 00:00:00 +0000 UTC
            	            	+2020-12-31 23:59:00 +0000 UTC
            	Test:       	TestExchangeClients/TestGetAllOHLCMarketData#02
            	Messages:   	COINBASE
    exchange_clients_****.go:64: 
        	Error Trace:	exchange_clients_****.go:64
        	            				value.go:476
        	            				value.go:337
        	            				dig.go:284
        	            				dig.go:439
        	            				app.go:692
        	            				app.go:471
        	            				exchange_clients_****.go:15
        	            				exchange_clients_****.go:30
        	Error:      	Not equal: 
        	            	expected: true
        	            	actual  : false
        	Test:       	TestExchangeClients
        	Messages:   	COINBASE
FAIL

Fill out README Prerequisites

We need to document the steps needed for someone to be able to run this project for the first time (dependencies, running the docker images for the data services).
Rough steps:

  • clone repo
  • run the docker-compose to start influxdb and psql
  • run psql migrations
  • run app

Cleanup secrets.go

Currently we store API-Keys like this:

type APIKeys struct {
	BinanceApiKey            string
	CoinbaseProApiKey        string
	CoinbaseProApiSecret     string
	CoinbaseProApiPassphrase string
	KrakenApiKey             string
	KucoinApiKey             string
}

With more exchanges, this will get messy quickly. We should instead make a new struct/exchange.

Clean Repository Types

Currently defined as:

package impl

import (
	influxdb2 "github.com/influxdata/influxdb-client-go/v2"
	"github.com/jmoiron/sqlx"
	"github.com/mochahub/coinprice-scraper/config"
)

type RepositoryImpl struct {
	db           *sqlx.DB
	influxClient *influxdb2.Client
	influxOrg    string
	ohlcBucket   string
}

func NewRepositoryImpl(
	config *config.Secrets,
	db *sqlx.DB,
	influxClient *influxdb2.Client,
) *RepositoryImpl {
	return &RepositoryImpl{
		db:           db,
		influxClient: influxClient,
		influxOrg:    config.Org,
		ohlcBucket:   config.Bucket,
	}
}

Instead of a single repository type, maybe we should have a repository per data model. This would result in more files but seems cleaner.

Make WriteAPI A Part of the Repository Impl

func (repo *RepositoryImpl) UpsertOHLCData(
	ohlcData []*models.OHLCMarketData,
	exchange string,
	pair *models.Symbol,
) {
	writeAPI := (*repo.influxClient).WriteAPI(repo.influxOrg, repo.ohlcBucket)
	tags := map[string]string{
		"quote":    pair.NormalizedQuote,
		"exchange": exchange,
	}
	for index := range ohlcData {
		ohlc := ohlcData[index]
		fields := map[string]interface{}{
			"open":   ohlc.OpenPrice,
			"high":   ohlc.HighPrice,
			"low":    ohlc.LowPrice,
			"close":  ohlc.ClosePrice,
			"volume": ohlc.Volume,
		}
		p := influxdb2.NewPoint(
			pair.NormalizedBase,
			tags,
			fields,
			ohlc.StartTime)
		writeAPI.WritePoint(p)
	}
}

We create a new writeAPI each time we upsert OHLC data, we should instead just make this a part of the RepositoryImpl type.

Add "ProductID" To Symbol Struct

We currently construct an exchange product (traded pair) from the raw base and raw quote. We should store the product pair as well as some exchanges have multiple product pairs for the same base/quoute (Kraken).

type Symbol struct {
        ProductID              string
	RawBase                string
	NormalizedBase         string
	RawQuote               string
	NormalizedQuote        string
}

Use Database to Store Supported Assets

Currently, we hardcode supported assets in supported.go

// TODO: Move these to a table in PSQL
func GetSupportedAssets() map[string]bool {
	return map[string]bool{
		"BTC":  true,
		"ETH":  true,
		"USDT": true,
		"USD":  true,
	}
}

By moving this to the database, we can easily create a script to update/remove supported coins (ex. top 100 coins).

Change Cover Image

We have rebranded to chain-bot, so let's change the cover image to reflect that.

Create Repository Module

Repository Interfaces to abstract away:

  • sqlboiler
  • influxdb2

Additionally, this makes testing easier by injecting mock implementations via uber.fx.

Refactor API Client Interfaces

Something similar to what is discussed here: #44 (comment)

This will let us scale out clients even if they don't implement specific functions (some have klines, some only have raw trades, some only have websockets, etc).

Migrate OHLC Data to Postgress

For the purpose of this project, we don't actually need all the pricing data all the time. If the goal is to use the data for training a model, then we can store the data, train, and then flush the data on a set schedule. It should be enough to store the past 60 days worth of data, a big enough overlap of the last training time.

Pros:

  • don't need two data stores
  • simplifies code as we already use postgress
    Cons:
  • lose out on the cool influx dashboard
  • can't create a pricing server (not really a goal ATM)

Support Poloniex

Candles
Supported Assets

Making more than 6 calls per second to the API, or repeatedly and needlessly fetching excessive amounts of data, can result in rate limit. Please be careful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.