This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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': [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import json | |
import time | |
import requests | |
from flask import Flask, request | |
prior_payload = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
[] & [] | |
except TypeError as exc: | |
print(exc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)] | |
) |
NewerOlder