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_3(start_date=None, sleep=False, sleep_time=1, plot=False, output=True, miss_output=False, miss_plot=False, kind='line'):
user_key, day_info, amount, invested, profit, loss, game_active = stock_game(start_date=start_date)
miss_colors = ['g']
while game_active == False:
predict = clf.predict(day_info[['Value USD', 'Max 7', 'Min 7', 'Change', 'Mean Change 7', 'Drop 7', 'Up 7']].values.reshape(1, -1))[0]
state = abs(day_info['Predict'])
if state == 0:
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['Value'] > row['Open 2']:
return 0
return 1
import requests
import time
import datetime
import pandas as pd
df = pd.DataFrame(columns=['Date', 'Value'])
def data_retriever(sleep=30):
global df
while True:
from sklearn.ensemble import RandomForestClassifier
X = df[['Open', 'Max 7', 'Min 7', 'Change', 'Mean Change 7', 'Drop 7', 'Up 7']].values
y = df['Actual'].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 keras
from keras import layers
from keras.layers.core import Dense, Activation
from keras.models import Sequential
from keras.callbacks import EarlyStopping
from keras.callbacks import ModelCheckpoint
import pandas as pd
from sklearn.model_selection import train_test_split
import numpy as np
from sklearn.metrics import accuracy_score
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
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
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)
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)
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