Skip to content

Instantly share code, notes, and snippets.

View shredding's full-sized avatar

chp shredding

  • Berlin
View GitHub Profile
def connect_to_stream(self, callback):
self.order_book = GDAXOrderBook(api=self, callback=callback, product_id=self.currency_pair)
self.order_book.start()
return self
class GDAXOrderBook(gdax_api.OrderBook):
def __init__(self, api, callback, *args, **kwargs):
super().__init__(*args, **kwargs)
self.api = api
# coding=utf-8
import logging
from django.core.management import BaseCommand
from backend.engine.tasks import get_strategies, get_strategy_by_currency_pair
log = logging.getLogger('notifications')
VERSION = '1.4.2'
import mandrill
API_KEY = 'your_api_key'
def send_mail(template_name, email_to, context):
mandrill_client = mandrill.Mandrill(API_KEY)
message = {
'to': [],
'global_merge_vars': []
}
import os
import sys
import json
import time
import requests
from flask import Flask, request
prior_payload = {}
import matplotlib.pyplot as plt
def gto_strategy():
return random.choice(Selection.OPTIONS)
gto_wins = 0
def rock_is_the_thing_strategy():
return 'rock'
rock_wins = 0
class Selection():
OPTIONS = ('paper', 'scissor', 'rock')
def __init__(self, selection):
if selection not in self.OPTIONS:
raise ValueError('selection must be one of {}.'.format(', '.join(self.OPTIONS)))
self.selection = selection
# implement a does_beat method on the class
if my_hand.does_beat(other_hand):
pot.raise()
# implement __ge__, __gt__, __lt__ and __le__ methods on that class
# (greater than or equal, greater than etc.)
if my_hand > other:
pot.raise()
try:
[] & []
except TypeError as exc:
print(exc)
import pandas as pd
s = pd.Series(range(0, 6))
print(
# bitwise and: &
s[(s > 0) & (s % 2 == 0)],
# bitwise or: |
s[(s > 4) | (s < 2)]
)