The abstraction layer of exchanges.
nouzan / exc Goto Github PK
View Code? Open in Web Editor NEWAn abstraction layer for exchanges
License: MIT License
An abstraction layer for exchanges
License: MIT License
Binance has added support for signing with RSA keys for private APIs. We are planning to add support to it to provide more security.
impl<C, Req> Exchange<C, Req>
where
Exc<C, Req>: ExcService<QueryLastCandles>,
{
pub async fn get_price(&mut self, period: Period, num: usize) -> anyhow::Result<Vec<Decimal>> {
let range = ..;
let req = QueryLastCandles::new(&self.inst, period, range, num);
let sub = (&mut self.public_exc).oneshot(req).await?;
let data = sub.filter_map(|x| async { x.ok().map(|x|x.close) }).collect().await;
Ok(data)
}
}
Sometimes it takes a long time(2m 11s), but in most cases it only takes a short time(0.7s).
Do you know what causes it to take a long time?
can you give me a demo for binance trading example can Take Profit Stop Loss? thanks in advance.
I want to wrap the interface, like this:
impl<C, Req> Exchange<C, Req>
where
Exc<C, Req>: FetchCandlesService,
{
}
but, OKX not implement FetchCandlesService
.
OKX had implement QueryLastCandles
, but I can't find FetchLastCandlesService
in main branches.
hi, i am testing the trade on okx, and i run cargo run --bin okx-ws-trading from examples.
the error is Error: api error: code=50014 msg=Parameter ccy can not be empty.
can you guide me where can i set the paramaeter for order? thank you so much.
In addition to the general method, can you refer to the project Position to implement a comm utils lib for cex extends api request .
With it , we can use uniform parameters,such as uri and payload to implement method quickly.For example, sometime we need to transfer funds between sub-accounts.
Although I may be a little ambiguous, this is a good idea. It can help users quickly connect to non-core interfaces
examples/examples
├── binance_candle.rs
├── binance_rate_limit.rs
├── box_exc_service.rs
These three files have the same error:
error[E0599]: no method named into_fetch_candles_forward
found for struct Exc
in the current scope
--> examples/examples/binance_rate_limit.rs:11:10
|
8 | let mut binance = Binance::usd_margin_futures()
| ______________-
9 | | .connect_exc()
10 | | .into_rate_limited(70, Duration::from_secs(60))
11 | | .into_fetch_candles_forward(1500);
| | -^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in Exc<RateLimit<IntoService<Binance, Request>>, Request>
| ||
|
--> examples/examples/box_exc_service.rs:42:46
|
42 | candle: Box::new(binance.clone().into_fetch_candles_forward(1000)),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in Exc<Binance, Request>
Preamble, I think this project does a really good job of abstracting the exchange interface, and I've been doing some promotion these days
However, from my previous long-term experience, the current demo way may not be enough.Sometimes it is necessary to implement a simple strategy based on a single transaction.
For example, many times the use of multiple exchanges and multiple accounts is very common. I need to dynamically add, enable, or disable accounts through ws, rpc, http, or even just listening for configuration file changes.
I have been using java to implement trading systems and am now switching to rust,Below are some of my current plans.
Hope to progress with you,HiHi.
The program is blocked on tickers.next().await
in https://github.com/Nouzan/exc/blob/main/examples/examples/binance_ticker.rs
Maybe it's a good idea choice hashbrown::HashMap instead of std::collections::HashMap。
By providing the reconnect
request, the higher level system can reset the whole connection actively in the buggy cases that have not yet been considered by exc
.
hi,Nouzan , are we spport Private channel websocket subscribe right now?
Problem
It would be great if we can do this:
struct Exchange {
ticker: Box<dyn SubscribeTickersService>,
}
But for now, it requires the user to specify the associated type Future
, which is difficult.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.