示例#1
0
文件: B_time.py 项目: AnDsergey13/Bot
import json
from binance_api import Binance

bot = Binance(API_KEY='', API_SECRET='')


def record_in_file():
    my_file = open('B_time.txt', 'w')
    my_file.write(str(binance_time))
    my_file.close()
    print('Данные записаны в файл')


response_from_binance = bot.time()
print(response_from_binance)
binance_time = response_from_binance['serverTime']
print(binance_time)
record_in_file()
示例#2
0
import csv
import json

from binance_api import Binance
bot = Binance(API_KEY='', API_SECRET='')


#запись данных в файл
def rec():
    i = bot.time('serverTime')
    my_file = open('time.txt', 'w')
    my_file.write(str(i))
    my_file.close()


print(bot.time())

json_string = bot.time()
#parsed_string = json.load(json_string)
print(json_string['serverTime'])
#parsed_string = ['serverTime']
'''
json_str = '{"serverTime": 1542267149637}'
json_prs = json.load(json_str)
print(json_prs['serverTime'])
'''
spisok_pokupok = {
    'Сметана': {
        'Name': "Сметана",
        'Price': 1.5,
        'Date': "11 ноября"
            return 'hold', ''


#Setup new history file
filename = f"./logs/ticker_{time.time()}.csv"

#with open(filename, 'w', newline='\n') as myfile:      #commented out to append instead
#     wr = csv.writer(myfile)
#     wr.writerow(history_header)
# Check open orders
res = bot.openOrders()
#### Do something with that
#print(res)

print(
    'Pair:      Open:          Close:         Volume:   Trades:  %Change    Recommendation:  BTC:   ETH:      BNB:      AION:             Avail Buy:     Avail Sell:'
)

while True:
    #Check server time and set bot offset to counter any discrepency between server and local
    bot.shift_seconds = bot.time()['serverTime'] / 1000 - time.time()
    #Get ticker to check specific pairs
    ticker('BTCUSDT')
    ticker('ETHUSDT')
    ticker('ETHBTC')
    ticker('BNBBTC')
    ticker('AIONBTC')
    print('-------------------------------------------------------------')
    for x in range(60):  #check each second for break
        time.sleep(1)