Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions scrape.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env python
import sys
import os
import argparse
import requests
import time
from datetime import datetime
import datetime
from random import random
import logging
import pandas as pd
Expand All @@ -14,8 +16,10 @@
parser = argparse.ArgumentParser(description='Scraping Tokens and Coins')
parser.add_argument('min_market_cap', metavar='min_cap', type=int, nargs='?', default=0,
help='minimum market cap [usd] for currency to be scraped (default: scrape all)')
parser.add_argument('max_date', metavar='max_date', type=str, nargs='?', default="90",
help='Get data from the request time between the request and the current day. (default 90) Example: 90 day from the current time. (D= Day)')

args = parser.parse_args()
args = parser.parse_args([])

# Configuration
timestamp_0 = 1367174841000
Expand Down Expand Up @@ -86,10 +90,24 @@ def LoopandFilterListData(html):
data.append(datum)
return data

def filterTimeFrom(df):
dataString = args.max_date
number = args.max_date

if number.isdigit():
number = int(number)
else:
logging.info("invalid max_date")
sys.exit()
d = datetime.timedelta(days=number).total_seconds()*1000
threeMonth = df['time'].iloc[-1] - d
df = df[df['time']>threeMonth]
return df

def getDetailandGraphData(token):
URL = "{0}/currencies/{1}/".format(graphBASE_URL, token['slug'])
rawData = pd.read_json(URL)
#rawData['time'] = rawData['market_cap_by_available_supply'].apply(lambda x: datetime.utcfromtimestamp(float(x[0]/1000)).strftime('%Y-%m-%d %H:%M:%S')) #convert UNIX TIMEstamp into readable data
#rawData['time'] = rawData['market_cap_by_available_supply'].apply(lambda x: datetime.datetime.utcfromtimestamp(float(x[0]/1000)).strftime('%Y-%m-%d %H:%M:%S')) #convert UNIX TIMEstamp into readable data
rawData['time'] = rawData['market_cap_by_available_supply'].apply(lambda x: x[0])
rawData['market_cap_by_available_supply'] = rawData['market_cap_by_available_supply'].apply(lambda x: x[1])
rawData['price_btc'] = rawData['price_btc'].apply(lambda x: x[1])
Expand All @@ -99,7 +117,7 @@ def getDetailandGraphData(token):
rawData.to_csv("{0}.csv".format(token['slug']), sep=',',index=False)
return rawData


def main():
##logging.info("Attempting to scrape token list.")
tokens = scrapeTokenList()
Expand All @@ -108,6 +126,8 @@ def main():
for token in tokens:
logging.info("> Starting scrape of token {0}...".format(token['slug']))
df = getDetailandGraphData(token)
df = filterTimeFrom(df)

#TechnicalAnalysis(df)

#rawData.to_csv("testing2.csv", sep=',',index=False)
Expand All @@ -122,8 +142,11 @@ def main():
#print coins

def testing():

df = pd.read_csv('eos.csv')
trading.technicalAnalysis(df)

df = filterTimeFrom(df)
trading.volumeAnalysis(df)

#def main():
# d = get_historical_data(COIN)
Expand All @@ -137,4 +160,4 @@ def testing():

if __name__=='__main__':
#main()
testing()
testing()
Loading