private void OXchange() { if (Xchange != null) { Xchange.Invoke(this, new EventArgs()); } }
public SocketMsgPack(Guid id, Xchange xchange, object data, long timestamp) { Id = id; Exchange = xchange; Data = data; Timestamp = timestamp; }
public SetLeverage(Guid id, Xchange exchange, Guid accountID, string symbol, decimal leverage) { Id = id == default ? Guid.NewGuid() : id; Exchange = exchange; AccountId = accountID; Symbol = symbol; Leverage = leverage; }
public CancelOrder(Guid id, Xchange exchange, Guid accountId, string orderId, string symbol) { Id = id == default ? Guid.NewGuid() : id; Exchange = exchange; AccountId = accountId; OrderId = orderId; Symbol = symbol; }
public ApiKeySet(Guid id, Xchange exchange, string apiKey, string secret, Env env = Env.Test) { Id = id.ToString() == string.Empty ? Guid.NewGuid() : id; Exchange = exchange; ApiKey = apiKey; ApiSecret = secret; Env = env; }
/// <summary> /// Updates Instrument CacheInstances /// </summary> /// <param name="exchange"></param> /// <param name="symbol"></param> /// <param name="instrumentDto"></param> /// <returns></returns> public long Update(Guid id, Xchange exchange, string symbol, long timeStamp, Instrument instrumentDto) { var keyString = $"{exchange}{symbol}{id}"; var cacheObject = _instrumentStore.GetInstrument(keyString, id, exchange, symbol); cacheObject.Update(timeStamp, instrumentDto); Set(keyString, cacheObject); return(cacheObject.Timestamp); }
public SocketUpdatePack(Guid id, Xchange xchange, object insert, object update, object delete, long timestamp) { Id = id; Exchange = xchange; Insert = insert; Update = update; Delete = delete; Timestamp = timestamp; }
public OrderPutRequestDto(Guid accountId, Xchange exchange, string symbol, string orderId, decimal?qty, decimal?price) { AccountId = accountId; Exchange = exchange; Symbol = symbol; OrderId = orderId; Qty = qty; Price = price; }
public UpdateOrder(Guid id, Xchange exchange, Guid accountId, string orderID, string symbol, decimal?price, decimal?amount) { Id = id == default ? Guid.NewGuid() : id; Exchange = exchange; AccountId = accountId; OrderId = orderID; Symbol = symbol; Price = price; Amount = amount; }
public OrderPostRequestDto(Guid accountId, Xchange exchange, string symbol, decimal?qty, decimal?price, OrderSide?side, OrderType ordType, TimeInForce tif, IEnumerable <ExecInst> execs) { AccountId = accountId; Exchange = exchange; Symbol = symbol; Quantity = qty; Price = price; Side = side; OrdType = ordType; TimeInForce = tif; Execs = execs; }
public CreateOrder(Guid id, Xchange exchange, Guid accountId, string symbol, decimal?price, decimal?amount, OrderType?type, TimeInForce?tif, OrderSide?side = null) { Id = id == default ? Guid.NewGuid() : id; Exchange = exchange; AccountId = accountId; Symbol = symbol; Price = price; Amount = amount; OrderType = type; TimeInForce = tif; Side = side; }
public long Get(Xchange exchange) { switch (exchange) { case Xchange.ByBit: return(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()); case Xchange.BitMex: return((long)(DateTime.UtcNow - EpochTime).TotalSeconds + LifetimeSeconds); default: return(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + LifetimeSeconds); } }
public async Task <InstrumentDto[]> GetInstrumentAsync(Xchange exchange, string symbol = default) // wont be passed atm { var requestDictionary = _descriptorService.GetPublicEndPointUrl(exchange, XchangeHttpOperation.GetInstrument); // var res = await _restRequestService.SendGetAsync(requestDictionary).ConfigureAwait(false); var result = TypeSerializer.DeserializeFromString <InstrumentDto[]>(res.Result); result.Each(f => { f.Exchange = exchange; f.Timestamp = res.Timestamp; }); return(result); }
public async Task <PositionDto> GetPositionAsync(Guid accountId, Xchange exchange, string symbol, CancellationToken token = default) { var requestObject = _descriptorService.RequestDictionary(exchange, XchangeHttpOperation.GetPosition, new ObjectDictionary() { { IXchangeDescriptorService.SymbolString, symbol } }); var response = await _restRequestService.SendRequestObjectAsync(accountId, requestObject, token).ConfigureAwait(false); var result = TypeSerializer.DeserializeFromString <PositionDto>(response.Result); result.AccountId = accountId; result.Exchange = exchange; result.Timestamp = result.Timestamp; return(result); }
public async Task <LeverageDto[]> GetLeverageAsync(Guid accountId, Xchange exchange, CancellationToken token = default) { var requestObject = _descriptorService.RequestDictionary(exchange, XchangeHttpOperation.GetLeverage); var response = await _restRequestService.SendRequestObjectAsync(accountId, requestObject, token).ConfigureAwait(false); var result = TypeSerializer.DeserializeFromString <LeverageDto[]>(response.Result); result.Each(p => { p.AccountId = accountId; p.Exchange = exchange; p.Timestamp = response.Timestamp; }); return(result); }
public async Task UpdateAsync(Guid id, Xchange exchange, string symbol, long timeStamp, OrderBook[] inserts, OrderBook[] updates, OrderBook[] deletes) { var keyString = CreateKeyString(id, exchange, symbol); var cacheObject = Update(keyString: keyString, id: id, exchange: exchange, symbol: symbol, timeStamp: timeStamp, inserts: inserts, updates: updates, deletes: deletes); await SetAsync(keyString, cacheObject); return; }
public async Task <LeverageDto> PostLeverageAsync(Guid accountId, Xchange exchange, string symbol, decimal leverage, CancellationToken token = default) { var route = _descriptorService.RequestDictionary(exchange, XchangeHttpOperation.PostLeverage, new ObjectDictionary() { { IXchangeDescriptorService.LeverageString, (int)leverage }, { IXchangeDescriptorService.SymbolString, symbol } }); var response = await _restRequestService.SendRequestObjectAsync(accountId, route, token).ConfigureAwait(false); var result = TypeSerializer.DeserializeFromString <LeverageDto>(response.Result); result.AccountId = accountId; result.Exchange = exchange; result.Timestamp = result.Timestamp; return(result); }
public async Task <MarginDto[]> GetMarginAsync(Guid accountId, Xchange exchange, string currency, CancellationToken token = default) { var route = _descriptorService.RequestDictionary(exchange, XchangeHttpOperation.GetMargin, new ObjectDictionary() { { _currencyString, currency } }); var response = await _restRequestService.SendRequestObjectAsync(accountId, route, token).ConfigureAwait(false); var result = TypeSerializer.DeserializeFromString <MarginDto[]>(response.Result); result.Each(p => { p.AccountId = accountId; p.Exchange = exchange; p.Timestamp = response.Timestamp; }); return(result); }
public async Task <OrderDto[]> DeleteAllOrdersAsync(Xchange exchange, Guid accountId, string symbol, CancellationToken token = default) { var route = _descriptorService.RequestDictionary(exchange, XchangeHttpOperation.PostCancelAllOrder, new ObjectDictionary() { { IXchangeDescriptorService.SymbolString, symbol } }); var res = await _restRequestService.SendRequestObjectAsync(accountId, route, token).ConfigureAwait(false); var result = TypeSerializer.DeserializeFromString <OrderDto[]>(res.Result); result.Each(p => { p.AccountId = accountId; p.Exchange = exchange; p.Timestamp = res.Timestamp; }); return(result); }
public XchangeRequestObject(XchangeDescriptor descriptor, EndPoint endPoint, ObjectDictionary paramDictionary = default) { Exchange = (Xchange)descriptor.Id; Url = endPoint.Url; Method = endPoint.Method; ApiKeyString = descriptor.ApiKeyString; TimeStampString = descriptor.TimeStampString; SignString = descriptor.SignString; RequestParameter = new SortedDictionary <string, object>(); if (paramDictionary == default) { return; } foreach (var p in paramDictionary) { Add(endPoint.Parameter[p.Key], paramDictionary[p.Key]);//p.Key is DomainName } }
public async Task <OrderDto> DeleteOrderAsync(Xchange exchange, Guid accountId, string symbol, string orderId, CancellationToken token = default) { var route = _descriptorService.RequestDictionary(exchange: exchange, routeKey: XchangeHttpOperation.PostCancelOrder, paramObjDict: new ObjectDictionary() { { IXchangeDescriptorService.OrderIdString, orderId }, { IXchangeDescriptorService.SymbolString, symbol } }); var res = await _restRequestService.SendRequestObjectAsync(accountId, route, token).ConfigureAwait(false); var result = TypeSerializer.DeserializeFromString <OrderDto>(res.Result); result.AccountId = accountId; result.Exchange = exchange; result.Timestamp = result.Timestamp; return(result); }
public Dictionary <long, OrderBook> Get(Guid id, Xchange exchange, string symbol) => _orderBookStore.GetOrderBook(key: CreateKeyString(id, exchange, symbol), id: id, exchange: exchange, symbol: symbol)?.OrderBook;
public async Task <Instrument> GetInstrumentAsync(Guid id, Xchange exchange, string symbol) => (await GetAsync($"{id}{exchange}{symbol}")).Instrument;
/// <summary> /// Updates Instrument CacheInstances /// </summary> /// <param name="exchange"></param> /// <param name="symbol"></param> /// <param name="orderBookDto"></param> /// <returns></returns> private OrderBookCacheObject Update(string keyString, Guid id, Xchange exchange, string symbol, long timeStamp, OrderBook[] inserts, OrderBook[] updates, OrderBook[] deletes) => _orderBookStore.GetOrderBook(key: keyString, id, exchange, symbol) .Update(timeStamp: timeStamp, insert: inserts, update: updates, delete: deletes);
public InstrumentCacheObject GetInstrument(string key, Guid id, Xchange exchange, string symbol) => _instrumentCacheObjects.GetValueOrDefault(key, new InstrumentCacheObject(id, exchange, symbol));
private OrderBookCacheObject Insert(string keyString, Guid id, Xchange exchange, string symbol, long timeStamp, OrderBook[] insert) => _orderBookStore.GetOrderBook(key: keyString, id, exchange, symbol) .Insert(timeStamp, insert);
public OrderBookCacheObject(Guid id, Xchange exchange, string symbol) { Id = id; Exchange = exchange; Symbol = symbol; }
public void Insert(Guid id, Xchange exchange, string symbol, long timeStamp, OrderBook[] snapShot) => Insert(CreateKeyString(id, exchange, symbol), id, exchange, symbol, timeStamp, snapShot);
public async Task <Dictionary <long, OrderBook> > GetAsync(Guid id, Xchange exchange, string symbol) => (await GetAsync(CreateKeyString(id, exchange, symbol)))?.OrderBook;
public void Update(Guid id, Xchange exchange, string symbol, long timeStamp, OrderBook[] insert, OrderBook[] update, OrderBook[] delete) => Update(CreateKeyString(id, exchange, symbol), id, exchange, symbol, timeStamp, insert, update, delete);