简体   繁体   中英

How can I get specific time periods ohlcv in CCXT bitget?

Even if I type "since" keyword in ccxt bitget, always get only the latest information. The same code worked on ftx, what's the problem?

bitget = ccxt.bitget({'apiKey' : self.KEY,
                    'secret' : self.SECRET_KEY,
                    'enableRateLimit' : True,
                    'options' : {'defaultType':'swap'}
                    })
yyyymmdd = '20220301'
since = int(datetime(int(yyyymmdd[:4]),int(yyyymmdd[4:6]),int(yyyymmdd[6:])).timestamp()*1000)

ohlcv = bitget.fetch_ohlcv('BTC/USDT', '1m', since, limit = 1000)

ohlcv = pd.DataFrame(ohlcv)
ohlcv.columns = ['time','open','high','low','close','volume']
ohlcv['time'] = ohlcv['time'].apply(lambda x : datetime.fromtimestamp(x/1000).strftime('%Y%m%d %H:%M'))    
    time    open    high    low close   volume

0   20220322 14:36  42957.24    42959.97    42927.88    42927.88    1.8439
1   20220322 14:37  42927.88    42957.04    42927.88    42951.36    1.2933  
2   20220322 14:38  42951.36    42951.36    42928.46    42932.59    0.6664
3   20220322 14:39  42932.59    42938.0 42916.22    42916.22    2.0336
4   20220322 14:40  42916.22    42916.22    42891.29    42897.49    2.0132
5   20220322 14:41  42897.49    42900.14    42880.96    42884.51    1.6279
6   20220322 14:42  42884.51    42893.26    42870.46    42870.46    2.3478
.
.
.

How can I get specific time period information ?

maybe since=since

also millisecond unix

since = int(datetime.datetime.strptime("2021-05-18 11:20:00+00:00", "%Y-%m-%d %H:%M:%S%z").timestamp() * 1000)

EDIT: looks like your unix was right my bad

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM