Skip to content

Instantly share code, notes, and snippets.

View sam-thecoder's full-sized avatar

Samuel M. sam-thecoder

View GitHub Profile
def player_2(start_index=0, sleep=False, sleep_time=1, plot=False, output=True, miss_output=False, miss_plot=False, show_exception=True):
user_key, day_info, amount, invested, profit, loss, game_active = bitcoin_game(start_index=start_index)
peak_price = day_info[1]
min_price = day_info[4]
max_price = day_info[5]
mean_price = day_info[6]
invest = None
max_profit = invested
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import linear_model
df = pd.read_csv('data/BCHAIN.csv')
df_copy = df.copy()
#Not needed for prediction
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
df = pd.read_csv('data/BCHAIN.csv')
df_copy = df.copy()
#Not needed for prediction
main_key = 0
game_record = {}
predictions = {
2: {'loss': 0, 'profit': 0, 'draw': 0},
1: {'loss': 0, 'profit': 0, 'draw': 0},
0: {'loss': 0, 'profit': 0, 'draw': 0},
-1: {'loss': 0, 'profit': 0, 'draw': 0},
-2: {'loss': 0, 'profit': 0, 'draw': 0}
}
##Add Reward Cycle last
def count_drop(numbers):
return len([x for x in numbers if x < 0])
def count_up(numbers):
return len([x for x in numbers if x > 0])
df.rename(columns={'Value': 'Value USD'}, inplace=True)
df['Value 2'] = df['Value USD'].shift(-1)
df['Max 7'] = df['Value USD'].rolling(7).max()
df['Min 7'] = df['Value USD'].rolling(7).min()
def player_1(start_date=None, miss_output=False, miss_plot=False, sleep=False, sleep_time=1, plot=False, output=True, hold_max=1000, withdraw_max=500, withdraw_min=10):
user_key, day_info, amount, invested, profit, loss, game_active = bitcoin_game(start_date=start_date)
#print(user_key)
prev_predict = day_info[-1]
miss_colors = ['g']
while game_active == False:
#print(day_info[-1])
if day_info[-1] == 2: #equilavent of 100 i.e. good odds
#print('first option')
if invested < 100: #invest 100
from sklearn.model_selection import train_test_split
from sklearn import linear_model
y = df['Predict'].values
X = df[['Value USD', 'Drop 7', 'Up 7', 'Mean Change 7', 'Change']].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=42)
clf = linear_model.SGDClassifier()
clf.fit(X_train, y_train)
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
y = df['Predict'].values
X = df[['Value USD', 'Drop 7', 'Up 7', 'Mean Change 7', 'Change']].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=42)
clf = RandomForestClassifier(max_depth=2, random_state=0)
clf.fit(X_train, y_train)
import sys
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="semi")
from geopy.distance import geodesic
def distance_calc():
'''
Calculate distance between two places
'''
loc_1, loc_2 = False, False
def count_drop(numbers):
return len([x for x in numbers if x < 0])
def count_up(numbers):
return len([x for x in numbers if x > 0])
def actual_calc(row):
if row['Open'] > row['Adj Close']:
return 0
return 1