Git Product home page Git Product logo

barter-rs / barter-data-rs Goto Github PK

View Code? Open in Web Editor NEW
100.0 100.0 64.0 859 KB

NOTE: Barter-Data migrated to Barter monorepo: https://www.github.com/barter-rs/barter-rs

Home Page: https://github.com/orgs/barter-rs/repositories

License: MIT License

Rust 100.00%
algo-trading algorithmic-trading algotrading backtesting backtesting-engine backtesting-frameworks backtesting-trading-strategies crypto-bot event-driven hft high-frequency-trading market-making quant quantitative-finance rust trading-bot trading-platform trading-simulator trading-strategies trading-systems

barter-data-rs's Introduction

Barter Ecosystem

Barter is an open-source ecosystem of Rust libraries for building live-trading and back-testing systems. It is made up of several easy-to-use, extensible crates:

  • Barter: Framework for building event-driven live-trading and back-testing systems. Algorithmic trade with the peace of mind that comes from knowing your strategies have been back-tested with a near-identical trading engine.
  • Barter-Data: High-performance WebSocket integration library for streaming public market data from leading cryptocurrency exchanges - batteries included.
  • Barter-Execution: Feature rich simulated exchange to assist with back-testing and dry-trading. Also provides a normalised trading interface capable of executing across different financial venues.
  • Barter-Integration: Low-level frameworks for flexible REST/WebSocket integrations.
  • Barter-Macro: Barter ecosystem macros.

See: Barter, Barter-Data, Barter-Integration, Barter-Execution & Barter-Macro for more comprehensive documentation.

Crates.io MIT licensed Build Status Discord chat

Getting Help

Firstly, see if the answer to your question can be found in the API Documentation. If the answer is not there, I'd be happy to help via Chat and try answer your question via Discord.

Contributing

Thanks in advance for helping to develop the Barter ecosystem! Please do get hesitate to get touch via the Discord Chat to discuss development, new features, and the future roadmap.

Licence

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in one of the Barter workspace crates by you, shall be licensed as MIT, without any additional terms or conditions.

Disclaimer

This software is for educational purposes only. Do not risk money which you are afraid to lose. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.

barter-data-rs's People

Contributors

crauzer avatar djamrog94 avatar g-tejas avatar jlodenius avatar jnatherley avatar just-a-stream avatar liamwh avatar minicheddar avatar pandadefi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

barter-data-rs's Issues

Build error

I'm trying to build the example https://github.com/barter-rs/barter-rs#example and I'm getting a build error:

   Compiling barter-data v0.5.7
error[E0599]: no variant named `Serde` found for enum `SocketError`
  --> /Users/dave/.cargo/registry/src/github.com-1ecc6299db9ec823/barter-data-0.5.7/src/exchange/kraken/model.rs:65:43
   |
65 |             .map_err(|error| SocketError::Serde {
   |                                           ^^^^^ variant not found in `SocketError`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `barter-data` due to previous error
warning: build failed, waiting for other jobs to finish...```

Exchange_time and received_time are the same

Hi! I am running this example:
https://github.com/barter-rs/barter-data-rs/blob/develop/examples/public_trades_streams.rs

Unfortunately I have rather doubtful results

MarketEvent<OrderBookL1>: MarketEvent { exchange_time: 2023-02-06T17:52:17.056798Z, received_time: 2023-02-06T17:52:17.056798Z, exchange: binance_futures_usd, instrument: Instrument { base: btc, quote: usdt, kind: FuturePerpetual }, kind: OrderBookL1 { last_update_time: 2023-02-06T17:52:17.056798Z, best_bid: Level { price: 23041.9, amount: 0.205 }, best_ask: Level { price: 23042.0, amount: 17.663 } } }

Exchange and receive time are the same, I doubt that it is due to hyper fast benefits of this lib, any suggestions? Is this a bug?

Metatrader Exchange API

It'd be neat to be able to use Metatrader, because they are broker independant. They already have a ton of implementations for other exchanges, which would make this very useful.

Backtrader already implemented this here by using the MQL5-JSON-API.

Confusing variable name and inappropriate value in subscription::OrderBook::mid_price

Hi, dear maintainers. Thanks for the great project! I think I have found some problem in the implementation of mid_price and volume_weighed_mid_price, but I am new to rust, please correct me if I am wrong.

  pub fn mid_price(&self) -> f64 {
        match (self.bids.levels.first(), self.asks.levels.first()) {
            (Some(best_bid), Some(best_ask)) => mid_price(best_bid.price, best_ask.price),
            (Some(best_bid), None) => best_bid.price,
            (None, Some(best_bid)) => best_bid.price,
            (None, None) => 0.0,
        }

Firstly, IIUC, the third arm in the match block, (None, Some(best_bid)), is intended to match the case where only best ask is available and no bids. The matched value should be named best_ask instead of best_bid. The whole arm should be (None, Some(best_ask)) => best_ask.price,

Secondly, for the (None, None) case. It may not be a good idea to use 0.0 as a default value. price = 0.0 has its meaning in trading: the instrument is for free. In practical use cases, the mid price of order book is typically used to indicate the "fair price" for the associated instrument. There are no quoting does not necessarily mean the instrument has zero price. Moreover, it is dangerous to set an instrument's price as 0.0, especially when some selling signal is generated based on this price, which results in extremely low price as the order price, and may lead to trading loss.

From my experience, I would rather use nan as mid price in the empty order book case. But I don't know whether rust supports nan. Another option is to use None, but that requires changing the return type to Option<f64>

local `exchange_time` is used for orderbook subscription

hi, thanks for the crate!

it seems like the exchange_time field of MarketEvent is not set to the exchange given timestamp when using Binance L2 orderbook subscriptions.

Self(vec![Ok(MarketEvent {
exchange_time: book.last_update_time,
received_time: Utc::now(),

book.last_update_time is set here to Utc::now()

match updater.update(book, update) {
Ok(Some(book)) => {
MarketIter::<OrderBook>::from((Exchange::ID, instrument.clone(), book)).0
}

I'm interested in the exchange given timestamp to check latency between my service and the exchange feed

`u64` or `DateTime<Utc>` for the data type of timestamps

Would it be better to use u64 datatype for timestamps because of better performance when serde deserializes it?

Candle uses DateTime<Utc> for start_time and end_time for now.

/// Normalised Barter OHLCV [`Candle`] model.
#[derive(Copy, Clone, PartialEq, PartialOrd, Debug, Deserialize, Serialize)]
pub struct Candle {
pub start_time: DateTime<Utc>,
pub end_time: DateTime<Utc>,
pub open: f64,
pub high: f64,
pub low: f64,
pub close: f64,
pub volume: f64,
pub trade_count: u64,
}

Can China Futures CTP interface be supported

Similar implementations include vnpy, which supports many exchanges, as well as China's futures market and stock market. Unfortunately, the efficiency of the Python based framework is not very satisfactory.
I have been looking for a Rust based framework. I was lucky to find Barter, but only support crypto exchanges.

Development Documentation:CTP Client Development Guide.pdf
CTP_Client_Development_Guide.pdf

c++ code & dll is:v6.6.8_traderapi.zip
(I found the trust encapsulation of the ctp interface, but I don't know how to combine it with barter:https://github.com/WiSaGaN/ctp-rs)

test account is :https://www.simnow.com.cn/ (MarketPrice not need account)

Implementing new exchanges as independent crates

Under the current structure, implementing a new exchange requires merging new codes into the codebase, such as creating a new crate in the exchange, adding a new variant to the ExchangeId enum.

But there are cases where users may want to implement some exotic exchanges that are not interested to other users. I hope we can have a better way to factor out exchange specific codes, so users can implement whatever exotic exchanges as they like, without affecting the whole project.

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.