I would like to get the orders as displayed in below forms, but the historical data within a time range, like from 2024-01-01
to 2024-04-01
. (Below figure is quoted from a similar question, but I am asking for a different answer)
Right now I could get the orderbook data from latest time stamp by following code:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "../lib/json.hpp"
#include <curl/curl.h>
vector<vector<string>> Binance::fetch_orderbook() {
string response = http_get(api_url + "api/v3/depth?symbol=BTCUSDT&limit=500");
json data = json::parse(response);
return data
}
However, this returns the latest order (with a specific "lastUpdateId"
) like below:
Price: 62351.89000000, Size: 0.20000000, Side: sell
Price: 62351.23000000, Size: 0.10530000, Side: sell
Price: 62351.22000000, Size: 0.02000000, Side: sell
Price: 62350.73000000, Size: 0.10530000, Side: sell
Price: 62350.53000000, Size: 11.25971000, Side: sell
Price: 62350.52000000, Size: 0.10205000, Side: buy
Price: 62350.41000000, Size: 0.00009000, Side: buy
Price: 62350.00000000, Size: 0.07210000, Side: buy
Price: 62349.60000000, Size: 0.00009000, Side: buy
Price: 62348.79000000, Size: 0.00009000, Side: buy
But I want a time series spanning from 2024-01-01
to 2024-04-01
which is more of like:
time. buy price. size. side
1499865549590 6xxxx.xxx. 0.000xx buy
1499865553000 6yyyy.yyy. 0.000yy buy
...
How can I do it by using C++ (or python, prefer C++ because now I am running the whole project on C++, but would also appreciate python solution so that I could translate it into C++ language by myself)? Thanks!