Skip to content

Instantly share code, notes, and snippets.

View KolevDarko's full-sized avatar

Darko Kolev KolevDarko

View GitHub Profile
@KolevDarko
KolevDarko / crypto-winners.py
Created May 25, 2020 08:14
Calculate biggest crypto movers based on price, volume or market cap
def calc_relative_diff(history_price, latest_price):
price_diff = latest_price - history_price
return round(price_diff / history_price, 2)
def calc_volume_diff(history_volume, latest_volume):
return latest_volume - history_volume
def calc_market_cap_diff(market_cap, history_price, latest_price):
@KolevDarko
KolevDarko / bitcoinaverage-crypto-history.py
Created May 22, 2020 10:16
Get crypto history price and circulating supply
def get_coin_supplies():
metadata_url = "https://apiv2.bitcoinaverage.com/metadata"
return make_request(metadata_url)
def get_history_at(days_back):
history_url = "https://apiv2.bitcoinaverage.com/indices/global/history"
history_time = datetime.datetime.utcnow() - datetime.timedelta(days=days_back)
history_timestamp = int(history_time.timestamp())
results = {}
for coin in coins:
import datetime
import operator
import requests
coins = ['BTCUSD', 'ETHUSD', 'LTCUSD', 'XRPUSD', 'XMRUSD']
API_KEY = '<your public api key>'
@KolevDarko
KolevDarko / moving_average.py
Created May 12, 2020 11:16
Moving average calculator
from datetime import datetime
from random import randint
class MovAvgCalculator:
def __init__(self, starting_list=None, window_duration=3600):
self.moving_average = None
if starting_list:
self.my_list = starting_list
self.sum = sum(starting_list)
/**
* npm install -g crypto-js
* npm install -g request
*/
var crypto = require('crypto-js');
var public_key = 'enter your public key';
var secret_key = 'enter your secret key';
var timestamp = Math.floor(Date.now() / 1000);
@KolevDarko
KolevDarko / ba-python-authentication.py
Created February 13, 2019 09:33
BitcoinAverage authentication
import hashlib
import hmac
import requests
import time
secret_key = 'enter your secret key'
public_key = 'enter your public key'
timestamp = int(time.time())
payload = '{}.{}'.format(timestamp, public_key)
hex_hash = hmac.new(secret_key.encode(), msg=payload.encode(), digestmod=hashlib.sha256).hexdigest()
# Install with > pip install bitcoinaverage
from bitcoinaverage import TickerWebsocketClientV2
class MyWebsocketClient(TickerWebsocketClientV2):
def received_message(self, message):
print("Received price update")
print(message)
// Install with: > npm install bitcoinaverage
const ba = require('bitcoinaverage');
var pub = '<your public key>';
var secret = '<your secret key>';
var wsClient = ba.websocketClient(pub, secret);
wsClient.connectToTickerWebsocketV2('global', ['ETHUSD', 'BCHUSD', 'LTCUSD', 'ETCUSD'], function(response) {
console.log(response.data.global);
@KolevDarko
KolevDarko / README.md
Created February 9, 2018 10:35 — forked from mau21mau/README.md
Configure Celery + Supervisor With Django
@KolevDarko
KolevDarko / Architecture.md
Created November 19, 2017 18:33 — forked from evancz/Architecture.md
Ideas and guidelines for architecting larger applications in Elm to be modular and extensible

Architecture in Elm

This document is a collection of concepts and strategies to make large Elm projects modular and extensible.

We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp. You will probably merge a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:

  1. There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo