This file contains hidden or 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
const MetaCoin = artifacts.require("./MetaCoin.sol"); | |
const utils = require('./utils.js'); | |
contract('MetaCoin', (accounts) => { | |
describe('Token', () => { | |
let balance; | |
let instance; | |
const [alice, bob] = accounts; | |
before(async () => { |
This file contains hidden or 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
const MetaCoin = artifacts.require("./MetaCoin.sol"); | |
const utils = require('./utils.js'); | |
contract('MetaCoin', (accounts) => { | |
describe('Token', () => { | |
let balance; | |
let instance; | |
const [alice, bob] = accounts; | |
before(async () => { |
This file contains hidden or 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
CREATE EXTERNAL TABLE IF NOT EXISTS <Database>.<Table> ( | |
host STRING, | |
identity STRING, | |
user STRING, | |
time STRING, | |
request STRING, | |
status STRING, | |
size STRING, | |
referer STRING, | |
agent STRING |
This file contains hidden or 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
#!/usr/bin/python | |
import json | |
import pandas as pd | |
import seaborn as sns | |
import python_bitbankcc | |
# Ticker information | |
def get_btc(obj): | |
ret = obj.get_ticker('btc_jpy') | |
return ret |
This file contains hidden or 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
# df copy | |
df_ = df.copy() | |
df_["ma25"] = df_.close.rolling(window=25).mean() | |
df_["ma75"] = df_.close.rolling(window=75).mean() | |
df_["diff"] = df_.ma25-df_.ma75 | |
df_["unixtime"] = [datetime.timestamp(t) for t in df.index] | |
# line and Moving Average | |
xdate = [x.date() for x in df_.index] | |
plt.figure(figsize=(15,5)) |
This file contains hidden or 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 Bollinger(df, window=25): | |
df1 = df.copy() | |
df1["ma"] = df1.close.rolling(window=window).mean() | |
df1["sigma"] = df1.close.rolling(window=window).std() | |
df1["ma+2sigma"] = df1.ma + 2*df1.sigma | |
df1["ma-2sigma"] = df1.ma - 2*df1.sigma | |
df1["diffplus"] = df1.close - df1["ma+2sigma"] | |
df1["diffminus"] = df1["ma-2sigma"] - df1.close | |
s_up = df1[df1["diffplus"] > 0]["close"] | |
s_down = df1[df1["diffminus"] > 0]["close"] |
This file contains hidden or 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 MACD(df): | |
df1 = df.copy() | |
df1["MACD"] = df1.close.ewm(span=12, min_periods=1).mean() - df1.close.ewm(span=26, min_periods=1).mean() | |
df1["signal"] = df1.MACD.ewm(span=9, min_periods=1).mean() | |
df1["macd_diff"] = df1["MACD"] - df1["signal"] | |
xdate = [x.date() for x in df1.index] | |
plt.figure(figsize=(15,10)) | |
# plot the original | |
plt.subplot(211) |
This file contains hidden or 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 plot_RSI(df, window): | |
df1 = df.copy() | |
diff = df1.close.diff(periods=1).values | |
xdate = [x.date() for x in df1.index] | |
RSI = [] | |
for i in range(window+1, len(xdate)): | |
neg = 0 | |
pos = 0 | |
for value in diff[i-window:i+1]: | |
if value > 0: |
This file contains hidden or 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 Ichimoku(df): | |
df1 = df.copy() | |
max_9 = df1.high.rolling(window=9).max() | |
min_9 = df1.high.rolling(window=9).min() | |
df1["tenkan"] = (max_9+min_9)/2 | |
df1["base"] = (df1.high.rolling(window=26).max()+df1.high.rolling(window=26).min())/2 | |
xdate = [x.date() for x in df1.index] | |
plt.figure(figsize=(15,5)) | |
plt.grid() | |
plt.plot(xdate, df1.close, color="b", lw=1, linestyle="dotted", label="original") |
This file contains hidden or 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
from pubnub.pubnub import PubNub | |
from pubnub.enums import PNStatusCategory | |
from pubnub.callbacks import SubscribeCallback | |
from pubnub.pnconfiguration import PNConfiguration | |
SUBSCRIBE_KEY = 'sub-c-e12e9174-dd60-11e6-806b-02ee2ddab7fe' | |
TICKER_CHANNEL = 'ticker_btc_jpy' | |
class BitbankSubscriberCallback(SubscribeCallback): | |
def presence(self, pubnub, presence): |