Skip to content

Commit 7d72086

Browse files
author
unknown
committed
FIRST
0 parents  commit 7d72086

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+70919
-0
lines changed

API/CoinCap.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import requests
2+
#@Author Ethen Pociask
3+
#DATA API REQUEST CLASS
4+
class CoinCap:
5+
6+
#TAKES COIN NAME AS PARAM
7+
def __init__(self, asset):
8+
9+
self.asset = asset
10+
self.APIURL = "http://api.coincap.io/v2/assets/" + self.asset
11+
12+
13+
14+
def getData(self):
15+
16+
17+
PARAMS = {'limit': 1}
18+
try:
19+
r = requests.get(url = self.APIURL, params = PARAMS)
20+
21+
except:
22+
self.getData()
23+
24+
l = []
25+
26+
dic = {}
27+
data = str(r.json())
28+
l = data.split("{")
29+
l = l[2].split(",")
30+
31+
for val in l:
32+
33+
for letter in val:
34+
val = val.replace(" ", "")
35+
dic[val[1:val.index(':')-1]] = val[val.index(':')+2 : len(val)-1]
36+
#crytoData = parser.toCrypto()
37+
return str(dic)
38+
39+

API/__init__.py

Whitespace-only changes.
954 Bytes
Binary file not shown.
131 Bytes
Binary file not shown.

AverageCalculator.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#Property of TrendSellers LLC
2+
#@author Ethen Pociask
3+
4+
class AverageCalculator:
5+
6+
def __init__(self, priceSet):
7+
self.priceSet = priceSet
8+
print(priceSet)
9+
10+
#finds Simple Moving Average for given timeFrame passed in init
11+
#assigns equal weighting to all values
12+
def calculateSMA(self):
13+
priceTotal = self.sum(self.priceSet)
14+
15+
16+
return priceTotal/len(self.priceSet)
17+
18+
19+
def sum(self, priceSet):
20+
priceTotal = 0
21+
for price in priceSet:
22+
price = float(price)
23+
priceTotal += price
24+
return priceTotal
25+
26+
def calculateEMA(self, length):
27+
28+
multiplier = (2 / (length + 1))
29+
30+
firstEMA = self.sum(self.priceSet)
31+
32+

CalculateSMA.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#@author Ethen Pociask
2+
3+
from AverageCalculator import *
4+
from Time import *
5+
class CalculateSMA:
6+
7+
def __init__(self):
8+
pass
9+
10+
11+
def calculateSMA(self, currencyName, timePeriod):
12+
13+
time = Time()
14+
name = currencyName
15+
16+
file = open("DataBase/"+name+"/"+name+"priceUsd.txt").read()
17+
Set = file.split("\n")
18+
19+
step = time.calculateTime(timePeriod)
20+
21+
dataSet = Set[len(Set)-step : len(Set)]
22+
23+
justPrice = dataSet
24+
25+
26+
timeStamp = justPrice[len(justPrice)-1]
27+
for data in justPrice:
28+
justPrice[justPrice.index(data)] = data[data.find(",")+1 : len(data)-1]
29+
30+
31+
calc = AverageCalculator(justPrice)
32+
SMA = calc.calculateSMA()
33+
f = open('DataBase/'+name+"/SMA/"+timePeriod+".txt", "a")
34+
35+
f.write(timeStamp[0 : 15] + ", " +str(SMA) + "\n")
36+
37+
f.close()
38+
39+
40+
41+

Candles.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Candle:
2+
3+
4+
def __init__(self, coinName):
5+
6+
self.coinName = coinName
7+
8+
9+
def generateCandle(self, timeLength):
10+
readFile = open('DataBase/' + coinName + '/' + 'priceUsd').read()
11+
12+
mini = 100000000000000
13+
maxi = 0
14+
for line in readFile:
15+
price = line[0 : line.find(",")]
16+
17+
if price > maxi:
18+
maxi = price
19+
20+
if price < mini:
21+
mini = price
22+
23+
self.high = maxi
24+
self.low = mini

DataBase/Distributor.go

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//Property of TrendSellers LLC
2+
//@author Ethen Pociask
3+
package main
4+
5+
6+
import (
7+
"os"
8+
"bytes"
9+
"strings"
10+
"time"
11+
"fmt"
12+
)
13+
14+
func updateFile(name string, variable string, value string){
15+
16+
fileName := name + "/" + name + variable + ".txt"
17+
file, err := os.OpenFile(fileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
18+
19+
if err != nil {
20+
21+
panic(err)
22+
}
23+
time := time.Now()
24+
timeS := time.String()
25+
timeS = timeS[0 : len(timeS)- 26]
26+
27+
formatString := "\n" + timeS + ", " + value
28+
29+
_, err = file.Write([]byte(formatString))
30+
31+
32+
if err != nil{
33+
panic(err)
34+
}
35+
36+
file.Close()
37+
}
38+
39+
40+
func distribute(name string){
41+
42+
file, err := os.Open(name+ "/" + name + ".txt")
43+
44+
if err != nil {
45+
panic(err)
46+
}
47+
48+
buf := new(bytes.Buffer)
49+
buf.ReadFrom(file)
50+
contents := buf.String()
51+
52+
jsonStr := contents
53+
54+
file.Close()
55+
jsonStr = jsonStr[1 : len(jsonStr)-1]
56+
57+
58+
list := strings.Split(jsonStr, ",")
59+
list[2] = list[len(list)-1]
60+
list[len(list)-1] = ""
61+
list = list[:len(list) -1]
62+
63+
m := make(map[string]string)
64+
for i := 4; i <= 10; i++ {
65+
temp := list[i]
66+
key := temp[2 : strings.Index(temp, ":")-1]
67+
value := temp[strings.Index(temp, ":") + 3: len(temp)-1]
68+
value = strings.Replace(value, "'", "", 1)
69+
m[key] = value
70+
}
71+
72+
73+
for key, value := range m{
74+
75+
updateFile(name, key, value)
76+
}
77+
}
78+
79+
func main(){
80+
81+
for{
82+
tick := time.Tick(5000 * time.Millisecond)
83+
for range tick {
84+
fmt.Println("Tick")
85+
distribute("ethereum")
86+
distribute("bitcoin")
87+
}
88+
}
89+
}
90+

DataBase/bitcoin/SMA/five-minute.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2019-10-18 13:0, 7997.953999766717
2+
2019-10-18 13:1, 7998.762379442789
3+
2019-10-18 13:1, 7990.062845363736
4+
2019-10-18 13:2, 7987.583930337886
5+
2019-10-18 13:2, 7982.3936160348685
6+
2019-10-18 13:3, 7989.182826749956
7+
2019-10-18 13:3, 7989.151677492743
8+
2019-10-18 13:4, 7996.539547701751
9+
2019-10-18 13:4, 7993.7938835021205
10+
2019-10-18 13:5, 7993.432059760954
11+
2019-10-18 13:5, 7993.432059760954
12+
2019-10-18 13:5, 7993.432059760954
13+
2019-10-18 13:5, 7993.432059760954
14+
2019-10-18 13:5, 7993.432059760954

DataBase/bitcoin/SMA/one-minute.txt

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2019-10-18 13:0, 7998.709695145444
2+
2019-10-18 13:0, 7997.409223792706
3+
2019-10-18 13:0, 7998.458377516629
4+
2019-10-18 13:0, 7998.549185068659
5+
2019-10-18 13:0, 7997.953999766717
6+
2019-10-18 13:0, 7996.202482303903
7+
2019-10-18 13:0, 7998.814416630103
8+
2019-10-18 13:0, 7999.791733747028
9+
2019-10-18 13:0, 7999.83155660702
10+
2019-10-18 13:1, 7999.210190032055
11+
2019-10-18 13:1, 7996.488551067067
12+
2019-10-18 13:1, 7992.972265468874
13+
2019-10-18 13:1, 7992.214207997712
14+
2019-10-18 13:1, 7990.985041720036
15+
2019-10-18 13:1, 7989.903348024571
16+
2019-10-18 13:1, 7990.309996769265
17+
2019-10-18 13:1, 7990.326368035359
18+
2019-10-18 13:1, 7988.376765084875
19+
2019-10-18 13:2, 7987.597932241058
20+
2019-10-18 13:2, 7987.239437207109
21+
2019-10-18 13:2, 7983.940755518594
22+
2019-10-18 13:2, 7984.395327161285
23+
2019-10-18 13:2, 7980.908040806565
24+
2019-10-18 13:2, 7980.909459255068
25+
2019-10-18 13:2, 7984.32948684201
26+
2019-10-18 13:2, 7984.428533496713
27+
2019-10-18 13:2, 7986.403600590619
28+
2019-10-18 13:2, 7988.324956123641
29+
2019-10-18 13:3, 7989.079774221533
30+
2019-10-18 13:3, 7990.054481129874
31+
2019-10-18 13:3, 7989.151677492743
32+
2019-10-18 13:3, 7989.151677492743
33+
2019-10-18 13:3, 7989.151677492743
34+
2019-10-18 13:3, 7989.151677492743
35+
2019-10-18 13:3, 7989.151677492743
36+
2019-10-18 13:3, 7994.981163271466
37+
2019-10-18 13:3, 7997.728275364821
38+
2019-10-18 13:3, 7997.622567145926
39+
2019-10-18 13:4, 7996.753829809338
40+
2019-10-18 13:4, 7995.675739859803
41+
2019-10-18 13:4, 7995.451631581568
42+
2019-10-18 13:4, 7993.640869396073
43+
2019-10-18 13:4, 7994.02678826473
44+
2019-10-18 13:4, 7993.955642830184
45+
2019-10-18 13:4, 7992.604103220721
46+
2019-10-18 13:4, 7992.260083116518
47+
2019-10-18 13:4, 7994.050876446291
48+
2019-10-18 13:4, 7993.746824452283
49+
2019-10-18 13:5, 7993.432059760954
50+
2019-10-18 13:5, 7993.432059760954
51+
2019-10-18 13:5, 7993.432059760954
52+
2019-10-18 13:5, 7993.432059760954
53+
2019-10-18 13:5, 7993.432059760954
54+
2019-10-18 13:5, 7993.432059760954
55+
2019-10-18 13:5, 7993.432059760954
56+
2019-10-18 13:5, 7993.432059760954
57+
2019-10-18 13:5, 7993.432059760954
58+
2019-10-18 13:5, 7993.432059760954
59+
2019-10-18 13:5, 7993.432059760954
60+
2019-10-18 13:5, 7993.432059760954
61+
2019-10-18 13:5, 7993.432059760954
62+
2019-10-18 13:5, 7993.432059760954
63+
2019-10-18 13:5, 7993.432059760954
64+
2019-10-18 13:5, 7993.432059760954
65+
2019-10-18 13:5, 7993.432059760954
66+
2019-10-18 13:5, 7993.432059760954
67+
2019-10-18 13:5, 7993.432059760954
68+
2019-10-18 13:5, 7993.432059760954
69+
2019-10-18 13:5, 7993.432059760954
70+
2019-10-24 01:4, 7469.810005589713
71+
2019-10-24 01:4, 7469.810005589713

DataBase/bitcoin/SMA/ten-minute.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2019-10-18 13:1, 7998.445320623606
2+
2019-10-18 13:2, 7990.999500643744
3+
2019-10-18 13:3, 7984.971092483536
4+
2019-10-18 13:4, 7991.408910292861
5+
2019-10-18 13:5, 7994.033890534148
6+
2019-10-18 13:5, 7994.033890534148
7+
2019-10-18 13:5, 7994.033890534148

DataBase/bitcoin/bitcoin.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{'id': 'bitcoin', 'rank': '1', 'symbol': 'BTC', 'name': 'Bitcoin', 'supply': '18014675.0000000000000000', 'maxSupply': '21000000.0000000000000000', 'marketCapUsd': '164132268019.4020358132141600', 'volumeUsd24Hr': '14899987218.8081393466071143', 'priceUsd': '9111.0313130490578272', 'changePercent24Hr': '5.2492126712938617', 'vwap24Hr': "9378.3576300134828591'", 'timestamp': '572124456308'}

0 commit comments

Comments
 (0)