Giter Site home page Giter Site logo

Comments (2)

wisespace-io avatar wisespace-io commented on August 25, 2024

@JoshuaBatty it is NOT implemented. The request is different, so you will need:

  1. Update websockets.rs and add a new subscribe method:
    pub fn subscribe_raw_books<S>(&mut self, symbol: S, et: EventType)
        where S: Into<String> 
    {
        let msg = json!(
            {
                "event": "subscribe", 
                "channel": "book", 
                "pair": self.format_symbol(symbol.into(), et),
                "prec": "R0"
            });

        if let Err(error_msg) = self.sender.send(&msg.to_string()) {
            self.error_hander(error_msg);
        }
    }

Note: The algorithm for raw books is based on "R0", so I guess we can hardcode it.

  1. Add a new struct to book.rs as it streams order_id, price and amount
    // Trading: if AMOUNT > 0 then bid else ask; Funding: if AMOUNT < 0 then bid else ask;
    #[derive(Serialize, Deserialize, Debug)]
    pub struct RawBook {
        pub order_id: i64,
        pub price: f64,
        pub amount: f64,
    }
  1. Update events.rs and add 2 new entries to the Enum DataEvent
    RawBookEvent (i32, RawBook),
    RawBookUpdateEvent (i32, Vec<RawBook>),
  1. In order to test, update on_data_event in public_channels.rs to handle the Event and UpdateEvent added above ...
        } else if let DataEvent::RawBookEvent(channel, raw_book) = event {
            println!("Rawbook Event ({}) - {:?}", channel, raw_book);
        }  ....

Please submit a Pull Request if it works, together with any other changes, so we can add it to the library.

from bitfinex-rs.

JoshuaBatty avatar JoshuaBatty commented on August 25, 2024

@wisespace-io thanks a bunch this works great. Had to change the order of the json message to subscribe but after that everything works perfectly. I've opened a pull request so feel free to merge when you're ready.

from bitfinex-rs.

Related Issues (4)

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.