binance-public-data | Details on how to get Binance public data | Cryptocurrency library
kandi X-RAY | binance-public-data Summary
kandi X-RAY | binance-public-data Summary
To help users download our public data easily, we've put all Kline, Trade, and AggTrade data for all pairs, month by month, online.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Download monthly index klines
- Download a file from a base location
- Returns the destination directory
- Convert string to date object
- Make a POST request
- Create a signature for a given request
- Create an argument parser
- Download monthly trades
- Send a GET request
- Get all symbols
- Download daily aggregation
- Download daily trades
- Download daily klines
- Download monthly aggregations
- Download monthly klines
- Download daily mark prices
- Download daily index klines
- Download monthly mark priceKlines
- Download monthly index price klines
- Download daily index prices
- Return start and end dates
binance-public-data Key Features
binance-public-data Examples and Code Snippets
Community Discussions
Trending Discussions on binance-public-data
QUESTION
how can i transform tick data to OHLCV(Open , High , Low , Close , Volume):
Current Sample (ticks format)
...ANSWER
Answered 2021-Nov-25 at 08:52You can associate each row in your dataset to 1 minute windows using window
. After, the rows are partitioned using their window and window analytical functions can be applied on them. Finally select the first row from each window.
A
groupBy
would not work asfirst
andlast
are non-deterministic when order is not provided, leading to wrong values foropen
andclose
columns.
I have also included logic to translate
epoch
todatetime
without needing to useUDF
.
Working ExampleI am preserving the timestamp column and using it order within window to have the high precision for finding
open
andclose
columns; as the deriveddatetime
column does not includemicroseconds
and the dataset has multiple entries within the same second.
QUESTION
use walkdir::WalkDir;
use std::ffi::OsStr;
use rusqlite::{params, Connection, Result};
use std::error::Error;
use std::io;
use std::process;
use std::path::Path;
use serde::{Serialize, Deserialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Trade {
id: usize,
price: f64,
quantity: f64,
quoted_quantity: f64,
time: i64,
is_buyer_maker: bool,
is_best_match: bool,
}
fn process_csv(file: &Path, db: &Connection) -> Result<(), Box> {
let mut rdr = csv::Reader::from_path(file)?;
for result in rdr.records() {
match result.deserialize::() {
Ok(s) => {
db.execute("INSERT INTO trades (id, price, quantity, quoted_quantity, time, is_buyer_maker, is_best_match) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
params![s.id, s.price, s.quantity, s.quoted_quantity, s.time, s.is_buyer_maker, s.is_best_match])?;
},
Err(e) => println!("Failed to deserialize: {}", e),
}
}
}
fn main () -> Result<(), Box> {
let conn = Connection::open("bot.db")?;
conn.execute(
"CREATE TABLE trades (
id INTEGER PRIMARY KEY,
price REAL NOT NULL,
quanity REAL NOT NULL,
quoted_quatity REAL NOT NULL,
time INTEGER NOT NULL,
is_buyer_maker INTEGER NOT NULL,
is_best_match INTEGER NOT NULL,
)",
[],
)?;
for entry in WalkDir::new("E:/binance-public-data/python/data/spot/monthly/trades/").into_iter().filter_map(|e| e.ok()) {
println!("Processing: {}", entry.path().display());
if let Err(e) = process_csv(entry.path(), &conn) {
println!("Processing failed: {}", e);
}
}
Ok(())
}
...ANSWER
Answered 2021-Sep-07 at 16:58Your first error is because you're calling csv
's .deserialize()
on the wrong variable, it should be called on the reader. Change:
QUESTION
I have a program that currently unzips files in a specific folder. However, I have many files in t that need to be sorted through. In my trades folder there are many coins and each coin has many files. I can get the files in each coin but cannot go through the folders initially for each coin. I need to be able to go through all those files without manually changing the directory to each coin. This is how the files are set up
...ANSWER
Answered 2021-Sep-05 at 22:22os.listdir
gives you the file name in the directory. You would have to rebuild its path from your current directory before accessing the file. os.path.abspath(item)
created an absolute path from your current working directory, not the directory holding your zip file.
You can use glob
instead. It will filter out non-zip file extensions and will keep the relative path to the found file so you don't have to fiddle with the path. The pathlib
module makes path handling a bit easier than glob.glob
and os.path
, so I'll use it here.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install binance-public-data
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page