kind of historical candle binance for couple and time
When downloading the historical data of Candelabri for several pairs of cryptocurrencies at different times of Binance Fi, data ordering data is necessary to facilitate the analysis of trends and reasons. In this article, we’ll show you how to order your data based on a pair and time.
assumptions
- Make sure you have a basic understanding of JSON and API interactions.
- You have access to Binance EPI and you know the use to download the data of the historic candle.
Step 1: Determine data structure
Before starting the system, make sure that the data structure is set correctly. Assuming you are working with such an object:
`Javascript
Const data = [
{
TIMESTAMP: ‘2022-01-01T00: 00: 00’,
Pair: “BTC/USDT”,
Open: 1000,
High: 1500,
Bass: 800,
Closed: 1200,
Volume: 100000
},
{
TIMestamp: ‘2022-01-02T00: 00: 00’,
Pair: “ETH/BTC”,
Open: 500,
High: 700,
Bass: 400,
Closed: 550,
Volume: 80000
}
“
`
Step 2: Order a couple and time
You can order your data using the following syntax:
`Javascript
Data.sort ((a, b) => {
If (a.pair === ‘BTC/USDT’ && b.pair! == ‘BTC/USDT’) Return -1;
If (b.pair === ‘BTC/USDT’ &&. Pairs! == ‘BTC/USDT’) Return 1;
Const Timeframea = Moment (A.MIstamp);
Const Timeframeb = Moment (B.Mivestamp);
IF (Timeframea
Otherwise, if (Timeframea> Timeframeb) Return 1;
Return 0;
});
`
This will order the data according to the pair and then in time. If the couple has changed, they move to the front of its corresponding time period.
Step 3: Filter Results
After the system, you may want to filter the results so that they contain only the most relevant data. For example::
`Javascript
Data = data.filter ((item) => Item.pair! == ‘BTC/USDT’);
`
This will remove any element with couples that do not match the required pair.
Step 4: View results
Finally, you can see the organized and filtered data to better understand the trends and models in the cryptographic markets.
Here is an example of how to display the organized data using console.log ()::
Javascript
Data.Foreach ((Item) => {
Console.log (`$ {item.pair}: $ {moment (item.timestamp). Format (‘RRRR-MM-DD HH: mm: SS’)
);
});
`
Example of using a case
Suppose we have a large set of data with multiple pairs and times and we want to analyze the performance of each pair at different times. According to these steps, you can easily order a couple and time data and then filter the results so that they contain only the most relevant information.
`Javascript
Const data = [
{
TIMESTAMP: ‘2022-01-01T00: 00: 00’,
Pair: “BTC/USDT”,
Open: 1000,
High: 1500,
Bass: 800,
Closed: 1200,
Volume: 100000
},
{
TIMestamp: ‘2022-01-02T00: 00: 00’,
Pair: “ETH/BTC”,
Open: 500,
High: 700,
Bass: 400,
Closed: 550,
Volume: 80000
},
{
TIMESTAMP: ‘2022-01-03T00: 00: 00’,
Pair: “BTC/USDT”,
Open: 1200,
High: 1800,
Bass: 1000,
Closed: 1300,
Volume: 150000
}
];
Data.sort ((a, b) => {
If (a.pair === ‘BTC/USDT’ && b.pair! == ‘BTC/USDT’) Return -1;
If (b.pair === ‘BTC/USDT’ &&. Pairs! == ‘BTC/USDT’) Return 1;
Const Timeframea = Moment (A.MIstamp);
Const Timeframeb = Moment (B.Mivestamp);
IF (Timeframea
Otherwise, if (Timeframea> Timeframeb) Return 1;
Return 0;
});
Data.Foreach ((Item) => {
Console.log (`$ {item.pair}: $ {moment (item.timestamp). Format (‘RRRR-MM-DD HH: mm: SS’)
);
});
`
This gives you data for couples and then shows the performance of each pair several times and several times.
Leave a Reply