Coder Social home page Coder Social logo

Futures API support? about binance-rs-async HOT 5 CLOSED

igosuki avatar igosuki commented on July 23, 2024
Futures API support?

from binance-rs-async.

Comments (5)

Igosuki avatar Igosuki commented on July 23, 2024 1

Sure, I'm not currently using futures but it shouldn't be hard to add.

from binance-rs-async.

Igosuki avatar Igosuki commented on July 23, 2024 1

Here : #4
You can use it but I haven't tested every endpoint for now.

from binance-rs-async.

Igosuki avatar Igosuki commented on July 23, 2024 1

Didn't see that everything started requiring tokio, I updated the examples accordingly.
The examples are passing so I see no reason to not merge into master. Let me know if you need anymore patches.

from binance-rs-async.

0ihsan avatar 0ihsan commented on July 23, 2024

Thank you. But, I am getting runtime panic for this code

use binance::api::*;
use binance::futures::general::*;
use futures::executor::block_on;

async fn get_all_symbols() {

    let general: FuturesGeneral = Binance::new(None, None);

    match general.exchange_info().await {
        Ok(answer) => println!("Exchange information: {:?}", answer),
        Err(e) => println!("Error: {:?}", e),
    }

}

fn main() {

    block_on(get_all_symbols());

}
thread 'main' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x
runtime', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.7.0/src/runtime/blocking/pool.rs:84:33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

from binance-rs-async.

0ihsan avatar 0ihsan commented on July 23, 2024

I solved that by adding tokio = { version = "1", features = ["full"] } to dependencies and making these changes

use binance::api::*;
use binance::futures::general::*;
use futures::executor::block_on;
+use tokio;

async fn get_all_symbols() {

    let general: FuturesGeneral = Binance::new(None, None);

    match general.exchange_info().await {
        Ok(answer) => println!("Exchange information: {:?}", answer),
        Err(e) => println!("Error: {:?}", e),
    }

}

+#[tokio::main]
+async fn async_main() {
+
+    block_on(get_all_symbols());
+
+}

fn main() {

-    block_on(get_all_symbols());
+    async_main();

}

from binance-rs-async.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.