Comments (5)
@tekr good point! If you provide a very elegant way to do that, I will accept your pull request. but I think you can handle it without any changes. When I designed the structure I expected handling this case by registration the components with the following way. This example uses UnityContainer but you can implement absolutely the same behaviour using any other DI framework.
// authorization1 - this instance contains apikey1 and secret1
Container.RegisterInstance<IBitmexAuthorization>("AuthorizationAccount1", authorization1);
Container.RegisterType<IBitmexApiProxy, BitmexApiProxy>($"BitmexApiProxyAccount1",
new InjectionConstructor(new ResolvedParameter<IBitmexAuthorization>($"AuthorizationAccount1")));
Container.RegisterType<IBitmexApiService, BitmexApiService>($"BitmexApiServiceAccount1",
new InjectionConstructor(new ResolvedParameter<IBitmexApiProxy>($"BitmexApiProxyAccount1")));
// authorization2 - uses another credencials
Container.RegisterInstance<IBitmexAuthorization>("AuthorizationAccount2", authorization2);
Container.RegisterType<IBitmexApiProxy, BitmexApiProxy>($"BitmexApiProxyAccount2",
new InjectionConstructor(new ResolvedParameter<IBitmexAuthorization>($"AuthorizationAccount2")));
Container.RegisterType<IBitmexApiService, BitmexApiService>($"BitmexApiServiceAccount2",
new InjectionConstructor(new ResolvedParameter<IBitmexApiProxy>($"BitmexApiProxyAccount2")));
let me know if it covers you case
from bitmex.net.
@semashkinvg The current implementation requires each account to have its own TCP connection. I.e. 10 accounts = 10 TCP connections. However it's fairly straightforward to support multiple accounts on one connection given that account details are specified on every REST request. There are at least a couple of ways to do it:
-
Make the IBitmexAuthorization parameter optional in the BitmexApiService constructor, and add an optional parameter for it to IBitmexApiService.Execute(). It can then be specified in the constructor (as before) for single-account usage, or alternatively in the Execute() calls for multi-account usage.
-
Add [I]BitmexMultiAccountApiService, similar to the existing [I]BitmexApiService except that IBitmexAuthorization is moved from the constructor to the Execute() method.
The first approach has the advantage of less code/duplication, but would need to rely on run-time checks to ensure an IBitmexAuthorization has been specified in either the constructor or Execute() call.
The second approach allows compile-time checking, but at the cost of some code duplication.
Do you have a preference? I'm happy to go with either approach.
from bitmex.net.
NB. Commits 51f0996 and 7c99c8f referenced above are implementations of options 1 and 2 respectively. Let me know if you're happy with one of them and I'll raise a PR.
from bitmex.net.
@tekr wow thanks, I will have a look tonight
from bitmex.net.
So.. not keen on adopting either approach?
In my current production setup I'm using 7c99c8f (i.e. a build with [I]BitmexMultiAccountApiService added). Happy to keep maintaining that fork if need be as it's not much extra code. I just figured some others may find it useful.
from bitmex.net.
Related Issues (20)
- Implement and Test WebSocket.Order HOT 2
- REST connection is opened & closed on every request HOT 3
- Randomly closes down without any exception HOT 2
- TradeSocketSubscription - Bug HOT 1
- Error creating order HOT 2
- Serialization Bug for Booleans HOT 3
- Implement and Tests WebSocket.Chat
- Implement and Tests WebSocket.announcement HOT 1
- Implement and Tests WebSocket.funding
- Implement and Tests WebSocket.Wallet
- Implement and Tests WebSocket.margin HOT 4
- BitmexApiException "Signature not valid". Mono HOT 7
- Can i trade with symbols: XBTZ18 or XBTН19 HOT 5
- Propogate 503, 429 Error responses HOT 9
- Custom coding
- Orderbook notifications are sent in different threads HOT 1
- Asks should be Bids in MainWindowViewModel subscribing to OrderBook10 HOT 1
- TradeSubscription events unordered
- WebSocket object not receiving welcome message HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitmex.net.