Beispiel #1
0
import time
import datetime
import pandas as pd

#เวอร์ชั่น CSV

while True:
    #try:
    timeBegin = time.time()
    print(datetime.datetime.now().strftime('%H:%M'))
    df1 = pd.read_csv('Data.csv', error_bad_lines=False)
    df = df1.set_index('indexAround')

    Around = df.loc['Around']['Balance']  # ตัวนับ

    df = callFuntionFutures.updatee(df, Around)
    df = df.loc[:,
                ~df.columns.str.contains('^Unnamed')]  # ลบคอลัม์ที่ไม่ต้องการ

    pd.set_option('display.width', 1000)
    print(df.loc[Around].to_frame().T)
    df = df.reset_index()
    df.to_csv("Data.csv", index=False)

    timeEnd = time.time()
    timeElapsed = timeEnd - timeBegin
    time.sleep(60 - timeElapsed)  # ถ่วงเวลา 1 นาที

#except Exception as e:
#       callFuntion.LineNotify('','',e,'error') # ถ้า error ไลน์ไป แจ้งคนเขียน
#       break
Beispiel #2
0
if presskey == '1':
    #เช็คค่าตัวแปรต่างๆก่อนรันบอทจริง
    callFuntionFutures.Setup_beforeTrade()

if presskey == '2':

    # Update while Loop
    timeBegin = 0
    checkError = 0
    sleeptime = 30  # ถ่วงเวลา 30-60  วินาที
    while True:
        try:
            timeBegin = time.time()

            callFuntionFutures.updatee()

            timeEnd = time.time()
            timeElapsed = timeEnd - timeBegin
            #print('เวลา' + str(datetime.datetime.now().strftime('%H:%M')) + ' กระบวนการ 1 รอบใช้เวลา: ' + str(int(timeElapsed)) + ' วินาที')
            print('time ' + str(datetime.datetime.now().strftime('%H:%M')) +
                  ' processing time per round : ' + str(int(timeElapsed)) +
                  ' Secound')  # กระบวนการ 1 รอบใช้เวลา
            # จบกระบวนการทั้งหมดใน callFuntionFutures ใช้ 37-51 วิ แล้วเอา 60 - 37 = 23วิ ที่เหลือในการถ่วงเวลา
            # ทำให้ หน่วงเวลา 30 วิไม่ได้ เพราะ 1รอบใช้เวลา 37วิ และ กระบวนการห้ามนานเกิน 60วิ
            time.sleep(sleeptime - timeElapsed)  # ถ่วงเวลา 30-60  วินาที

            if sleeptime == 300:
                sleeptime = 30

        # """ เครดิตพี่นัท LazyTrader """
Beispiel #3
0
]
creds = ServiceAccountCredentials.from_json_keyfile_name("API.json", scope)
gc = gspread.authorize(creds)

Product = 'XRP-PERP'
#Update while Loop
while True:
    #try:
    timeBegin = time.time()
    print(datetime.datetime.now().strftime('%H:%M'))
    ws = gc.open("Data").worksheet('PERP')  # เปิดหน้าชีท
    df = get_as_dataframe(ws).set_index(
        'Product'
    )  # เรียกข้อมูลใน google sheet และตั้งให้ คอลัม indexAround เป็น index ไว้ให้ pandas เรียกใช้

    df = callFuntionFutures.updatee(df)
    df = df.loc[:,
                ~df.columns.str.contains('^Unnamed')]  # ลบคอลัม์ที่ไม่ต้องการ

    pd.set_option('display.width', 1000)
    print(df.loc[Product].to_frame().T)
    set_with_dataframe(gc.open("Data").worksheet('PERP'),
                       df.reset_index())  # บันทึกลง ชีทหน้า

    timeEnd = time.time()
    timeElapsed = timeEnd - timeBegin
    time.sleep(60 - timeElapsed)  # ถ่วงเวลา 1 นาที

#except Exception as e:
#       callFuntion.LineNotify('','',e,'error') # ถ้า error ไลน์ไป แจ้งคนเขียน
#       break