-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_pair_ticker.py
67 lines (53 loc) · 2.3 KB
/
get_pair_ticker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import json
import time
from decimal import Decimal
import botfunction as func
from botclass import BinanceSymbolPriceTicker as priceTickerClass
from botclass import TriangularPair as pairClass
#
# Uclu arbitraj icin anlik fiyatları çekme
# Silinecek arbitraj_01 yazildi bunun yerine
#
def main():
db = func.connectDB()
dbCursor = db.cursor()
# Read binance section from config.ini
binanceConfig = func.readConfig(filename="config.ini", section="binance")
url_price_ticker = binanceConfig["url_base"] + binanceConfig["url_price_ticker"]
priceTicker = priceTickerClass()
priceTicker.dbCursor = dbCursor
start_time = time.time()
toplam = 0
adet = 0
pair = pairClass()
pair.dbCursor = dbCursor
pairRows = pair.readAllPair(exchangeId=1, refSymbol="USDT")
if (pairRows is not None) and (len(pairRows) > 0):
for pairRow in pairRows:
rec = json.loads(pairRow[0])
aPairSymbol = rec["pair_a_symbol"]
bPairSymbol = rec["pair_b_symbol"]
cPairSymbol = rec["pair_c_symbol"]
# coin için anlık fiyat bilgisi getirilir
priceTicker.symbol = aPairSymbol
priceRecord = priceTicker.getData(url_price_ticker)
aPairPrice = Decimal(priceRecord["price"])
priceTicker.symbol = bPairSymbol
priceRecord = priceTicker.getData(url_price_ticker)
bPairPrice = Decimal(priceRecord["price"])
priceTicker.symbol = cPairSymbol
priceRecord = priceTicker.getData(url_price_ticker)
cPairPrice = Decimal(priceRecord["price"])
caprazOran = (1/aPairPrice) * (1/bPairPrice) * cPairPrice
if caprazOran > (1 + Decimal(0.00225)):
toplam = toplam + caprazOran - (1 + Decimal(0.0025))
adet = adet + 1
print(f"aPair: {aPairSymbol} bPair: {bPairSymbol} cPair: {cPairSymbol} oran: {caprazOran} "
f"-> Toplam tutar: {toplam} adet: {adet}")
# priceTicker.symbol = priceRecord["symbol"]
# priceTicker.price = priceRecord["price"]
# priceTicker.addData()
print(f"Toplam süre: {time.time() - start_time} saniye")
print(f"Toplam tutar: {toplam} adet: {adet}")
# print(f"Çekilen kayıt sayısı: {len(symbolRows)}")
main()