Skip to content

Instantly share code, notes, and snippets.

View mempirate's full-sized avatar
🏃
Sprinting

Jonas Bostoen mempirate

🏃
Sprinting
  • Chainbound
  • Antwerp, Belgium
  • 05:36 (UTC +02:00)
  • X @mempirate
View GitHub Profile
# Visualizing the test set results
plt.figure(figsize = (12, 6))
plt.scatter(X_test, y_test, alpha = 0.4, label = 'Observation Points')
plt.plot(X_train, regressor.predict(X_train), color = 'green', lw = 0.7, alpha = 0.8, label = 'Best Fit Line')
plt.title('Linear Regression (Test Set)')
plt.xlabel('Years of Experience')
plt.ylabel('Salary')
plt.legend()
new_prediction = regressor.predict(1.5)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from logbook import Logger
from math import floor, ceil
from catalyst import run_algorithm
from catalyst.api import order_target_percent, record, symbol
from catalyst.exchange.utils.stats_utils import extract_transactions
def initialize(context):
context.asset = symbol("btc_usd")
context.i = 0
context.base_price = None
def handle_data(context, data):
RSI_periods = 14
context.i += 1
if context.i < RSI_periods:
return
RSI_data = data.history(context.asset,
"price",
if __name__ == "__main__":
run_algorithm(
capital_base = 1000,
data_frequency = "minute",
initialize = initialize,
handle_data = handle_data,
analyze = analyze,
exchange_name = "bitfinex",
algo_namespace = NAMESPACE,
base_currency= "usd",
const Web3 = require('web3');
class TransactionChecker {
web3;
account;
constructor(projectId, account) {
this.web3 = new Web3(new Web3.providers.HttpProvider('https://rinkeby.infura.io/v3/' + projectId));
this.account = account.toLowerCase();
}
const Web3 = require('web3');
class TransactionChecker {
web3;
web3ws;
account;
subscription;
constructor(projectId, account) {
this.web3ws = new Web3(new Web3.providers.WebsocketProvider('wss://rinkeby.infura.io/ws/v3/' + projectId));
'use strict'
module.exports = Web3 => {
const provider = new Web3.providers.HttpProvider('https://rinkeby.infura.io/v3/YOUR_INFURA_API_KEY_HERE')
return new Web3(provider)
}
'use strict'
module.exports = web3 => {
const account = 'YOUR_ETH_ADDRESS'.toLowerCase()
return async function checkLastBlock() {
let block = await web3.eth.getBlock('latest')
console.log(`[*] Searching block ${ block.number }...`)
if (block && block.transactions) {
for (let txHash of block.transactions) {