[26.06.20] Ask bid additions
This commit is contained in:
parent
12858eb148
commit
24ad9d845d
@ -41,7 +41,7 @@ try {
|
||||
)]
|
||||
) {
|
||||
sh "doctl auth init --access-token ${DOCTL_TOKEN}"
|
||||
sh "doctl kubernetes cluster kubeconfig save cryptosky-kubernetes-cluster-production"
|
||||
// sh "doctl kubernetes cluster kubeconfig save cryptosky-kubernetes-cluster-production"
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,8 +87,8 @@ try {
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
executeShellScript("configuration/scripts/deployToKubernetes.sh",
|
||||
env.APPLICATION_NAME)
|
||||
// executeShellScript("configuration/scripts/deployToKubernetes.sh",
|
||||
// env.APPLICATION_NAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ def bitfinexPublicTicker(type, logger):
|
||||
response = requests.request("GET", uri)
|
||||
response = json.loads(response.text)
|
||||
|
||||
price = (float(response[0][1])+ float(response[0][3]) + float(response[0][7]))/3
|
||||
price = (float(response[0][7])+ float(response[0][9]) + float(response[0][10]))/3
|
||||
price = round(price, 3)
|
||||
return price
|
||||
except KeyError as e:
|
||||
@ -29,7 +29,10 @@ def bitfinexHighLowVol(type, logger):
|
||||
low = round(float(response[0][10]), 3)
|
||||
vol = round(float((response[0][8]))/24, 3)
|
||||
|
||||
return high, low, vol
|
||||
ask = round(float(response[0][1]), 3)
|
||||
bid = round(float(response[0][3]), 3)
|
||||
|
||||
return high, low, vol, ask, bid
|
||||
except KeyError as e:
|
||||
logger.error("Bitfinex High Low Volume Error: {}".format(e))
|
||||
return 0, 0, 0
|
||||
@ -50,10 +50,11 @@ def averager(type):
|
||||
return averagePrice, timestamp
|
||||
|
||||
def getHighLowVol(type):
|
||||
bH, bL, bV = bitfinexHighLowVol(type, logger)
|
||||
gH, gL, gV = geminiHighLowVol(type, logger)
|
||||
bH, bL, bV, bA, bB = bitfinexHighLowVol(type, logger)
|
||||
gH, gL, gV, gA, gB = geminiHighLowVol(type, logger)
|
||||
|
||||
if ( bH == 0 or bL == 0 or bV == 0 ) or ( gH == 0 or gL == 0 or gL == 0):
|
||||
if ( bH == 0 or bL == 0 or bV == 0 or bA == 0, bB == 0 ) \
|
||||
or ( gH == 0 or gL == 0 or gL == 0 or gA == 0 or gB == 0):
|
||||
if bH == 0:
|
||||
high = gH
|
||||
elif gH == 0:
|
||||
@ -66,14 +67,24 @@ def getHighLowVol(type):
|
||||
vol = gV
|
||||
elif gV == 0:
|
||||
vol = bV
|
||||
if bA == 0:
|
||||
ask = gA
|
||||
elif gA == 0:
|
||||
ask = bA
|
||||
if bB == 0:
|
||||
bid = gB
|
||||
elif gB == 0:
|
||||
bid = bB
|
||||
else:
|
||||
high = (bH + gH)/2
|
||||
low = (bL + gL)/2
|
||||
vol = (bV + gV)/2
|
||||
ask = (bA + gA)/2
|
||||
bid = (bB + gB)/2
|
||||
|
||||
return high, low, vol
|
||||
return high, low, vol, ask, bid
|
||||
|
||||
def sendToGateway(c_type, timestamp, av_price, high, low, vol, o_price, c_price):
|
||||
def sendToGateway(c_type, timestamp, av_price, high, low, vol, ask, bid, o_price, c_price):
|
||||
|
||||
with open(btc_usd, 'r') as file:
|
||||
data = file.read()
|
||||
@ -81,7 +92,7 @@ def sendToGateway(c_type, timestamp, av_price, high, low, vol, o_price, c_price)
|
||||
timestamp = '"'+timestamp.strftime('%Y-%m-%dT%H:%M:%S')+'"'
|
||||
type = '"'+c_type+'"'
|
||||
|
||||
query = data % (timestamp, type, av_price, high, low, o_price, c_price, vol)
|
||||
query = data % (timestamp, type, av_price, high, low, ask, bid, o_price, c_price, vol)
|
||||
|
||||
logger.info("Query sending down to db-gateway -- ({})".format(query))
|
||||
|
||||
@ -104,9 +115,9 @@ def collector(c_type):
|
||||
|
||||
while True:
|
||||
av_price, timestamp = averager(c_type)
|
||||
high, low, vol = getHighLowVol(c_type)
|
||||
high, low, vol, ask, bid = getHighLowVol(c_type)
|
||||
o_price, c_price = getOpenClose(c_type)
|
||||
|
||||
sendToGateway(c_type, timestamp, av_price, high, low, vol, o_price, c_price)
|
||||
sendToGateway(c_type, timestamp, av_price, high, low, vol, ask, bid, o_price, c_price)
|
||||
|
||||
sleep(3596)
|
||||
@ -28,12 +28,15 @@ def geminiHighLowVol(type, logger):
|
||||
high = float(response['high'])
|
||||
low = float(response['low'])
|
||||
|
||||
ask = float(response['ask'])
|
||||
bid = float(response['bid'])
|
||||
|
||||
uri = "https://api.gemini.com/v1/pubticker/" + type.lower().replace('_', '')
|
||||
response = requests.request("GET", uri)
|
||||
response = json.loads(response.text)
|
||||
vol = float(response['volume']['BTC'])/24
|
||||
|
||||
return high, low, vol
|
||||
return high, low, vol, ask, bid
|
||||
except KeyError as e:
|
||||
logger.error("Gemini High Low Volume Error: {}".format(e))
|
||||
return 0, 0, 0
|
||||
|
||||
@ -1 +1 @@
|
||||
mutation { createBtc(createdDate: %s, type: %s, average_price: %f, high_price: %f, low_price: %f, open_price: %f, close_price: %f, volume: %f){ id } }
|
||||
mutation { createBtc(createdDate: %s, type: %s, average_price: %f, high_price: %f, low_price: %f, ask_price: %f, bid_price: %f, open_price: %f, close_price: %f, volume: %f){ id } }
|
||||
Loading…
x
Reference in New Issue
Block a user