-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_priceticker_all.py
46 lines (34 loc) · 1.27 KB
/
get_priceticker_all.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
import json
import sys
import time
import mariadb
import botfunction as func
from botclass import BinanceExchangeInfo as symbolClass
from botclass import BinanceSymbolPriceTicker as priceTickerClass
#
# Anlık coin fiyatlarını çekme
#
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()
symbol = symbolClass()
symbol.dbCursor = dbCursor
symbolRows = symbol.readAllSymbol()
if (symbolRows is not None) and (len(symbolRows) > 0):
for symbolRow in symbolRows:
coin = json.loads(symbolRow[0])
priceTicker.symbol = coin["symbol"]
# coin için anlık fiyat bilgisi getirilir
priceRecord = priceTicker.getData(url_price_ticker)
priceTicker.symbol = priceRecord["symbol"]
priceTicker.price = priceRecord["price"]
priceTicker.addData()
print(f"Toplam süre: {time.time() - start_time} saniye")
print(f"Çekilen kayıt sayısı: {len(symbolRows)}")
main()