public BuyV2WsMessage( long balanceId, ActivePair pair, OptionType optionType, OrderDirection direction, DateTimeOffset expiration, int price) { Message = new RequestBody <BuyV2RequestModel> { RequestBodyType = RequestMessageBodyType.OpenBinaryOptions, Body = new BuyV2RequestModel { UserBalanceId = balanceId, ActivePair = pair, OptionType = optionType, Direction = direction, Expiration = expiration, Price = price, // default preset Value = 0, ProfitPercent = 0, RefundValue = 0 } }; }
/// <summary> /// Place the binary position /// </summary> /// <param name="pair">The active pair to place position</param> /// <param name="size">The lot size</param> /// <param name="direction">The position direction</param> /// <param name="expiration">The expira</param> /// <returns></returns> public Task <BinaryOptionsResult> BuyAsync( string requestId, ActivePair pair, decimal size, OrderDirection direction, DateTimeOffset expiration) { //reduce second to 00s if (expiration.Second % 60 != 0) { expiration = expiration.AddSeconds(60 - expiration.Second); } // incasse of non-binary options var optionType = OptionType.Turbo; if (expiration.Subtract(ServerTime).Minutes > 5) { optionType = OptionType.Binary; } return(SendMessageAsync( requestId, new BuyV2WsMessage( Profile.BalanceId, pair, optionType, direction, expiration, size), BinaryOptionPlacedResultObservable)); }
public Task <BuyResult> BuyAsync( ActivePair pair, int size, OrderDirection direction, DateTime expiration = default(DateTime)) { var tcs = new TaskCompletionSource <BuyResult>(); try { var obs = BuyResultObservable .OnErrorResumeNext(BuyResultObservable) .Where(x => x != null) .Subscribe(x => { tcs.TrySetResult(x); }, ex => { tcs.TrySetException(ex); }); tcs.Task.ContinueWith(t => { if (t.Result != null) { obs.Dispose(); } }); SendMessageAsync(new BuyV2WsRequestMessage(pair, size, direction, expiration, TimeSync.ToLocalTime())).ConfigureAwait(false); } catch (Exception ex) { tcs.TrySetException(ex); } return(tcs.Task); }
public Instrument GetByActivityType(ActivePair pair) { var result = this .SelectMany(x => x.Value) .FirstOrDefault(x => x.Name == Enum.GetName(typeof(ActivePair), pair)); return(result); }
public Task <IObservable <CurrentCandle> > SubscribeRealtimeQuoteAsync(ActivePair pair, TimeFrame tf) { WsClient?.SubscribeQuoteAsync(pair, tf).ConfigureAwait(false); var stream = WsClient? .RealTimeCandleInfoObservable .Where(x => x.ActivePair == pair && x.TimeFrame == tf); return(Task.FromResult(stream)); }
public BuyV2WsMessage(ActivePair pair, int price, OrderDirection direction, DateTimeOffset expiration, DateTimeOffset now) { Message = new BuyV2RequestModel() { ActivePair = pair, Price = price, Direction = direction, Expiration = expiration.ToUniversalTime(), Time = now.ToUniversalTime() }; }
public BuyV2WsMessage(ActivePair pair, int price, OrderDirection direction, DateTime expiration, DateTime now) { Message = new BuyV2RequestModel() { ActivePair = pair, Price = price, Direction = direction, Expiration = expiration, Time = now }; }
public BuyModel( ActivePair pair, int size, OrderDirection direction, DateTimeOffset expiration) { Pair = pair; Size = size; Direction = direction; Expiration = expiration; }
public DigitalOptionsIdentifier( ActivePair pair, OrderDirection direction, DigitalExpiryDuration duration, DateTimeOffset now) { Pair = pair; Direction = direction; Duration = duration; Expiration = DateTimeUtilities.GetExpirationTime(now.UtcDateTime, duration); }
public Task <BuyResult> BuyAsync( ActivePair pair, int size, OrderDirection direction, DateTimeOffset expiration) { var tcs = new TaskCompletionSource <BuyResult>(); try { var obs = BuyResultObservable .Where(x => x != null) .Subscribe(x => tcs.TrySetResult(x)); tcs.Task.ContinueWith(t => { if (t.Result != null) { obs.Dispose(); } }); //reduce second to 00s if (expiration.Second % 60 != 0) { expiration = expiration.AddSeconds(60 - expiration.Second); } // incasse of non-binary options var optionType = OptionType.Turbo; if (expiration.Subtract(ServerTime).Minutes >= 5) { optionType = OptionType.Binary; } SendMessageAsync( new BuyV2WsMessage( Profile.BalanceId, pair, optionType, direction, expiration, size)) .ConfigureAwait(false); } catch (Exception ex) { tcs.TrySetException(ex); } return(tcs.Task); }
public Task <BinaryOptionsResult> BuyBinaryAsync( ActivePair pair, int size, OrderDirection direction, DateTimeOffset expiration) { return(BuyBinaryAsync(new BuyModel( pair, size, direction, expiration))); }
public GetCandleItemRequestMessage(ActivePair pair, TimeFrame tf, int count, DateTimeOffset to) { base.Message = new GetCandlesRequestModel() { RequestBody = new GetCandlesRequestModel.GetCandlesRequestBody() { ActivePair = pair, TimeFrame = tf, Count = count, To = to.ToUniversalTime() // servertime should set here } }; }
public void TestCreate_InstrumentId( ActivePair active, OrderDirection direction, DigitalOptionsExpiryDuration duration, string expected) { var specificDate = DateTimeOffset.Parse("2018-11-10 12:50:50Z"); var result = new DigitalOptionsIdentifier(active, direction, duration, specificDate); result.ToString() .Should().Be(expected); }
public GetAlertsRequestMessage( ActivePair activeId, string type) { Message = new RequestBody <GetAlertsRequestMessageModel> { RequestBodyType = RequestMessageBodyType.GetAlerts, Body = new GetAlertsRequestMessageModel { AssetId = activeId, Type = type } }; }
public SubscribeMessageRequest(ActivePair pair, TimeFrame tf) { base.Message = new SubscribeRequestBody() { Parameters = new SubscribeRequestParameter() { Filter = new SubscribeRequestParameter.RequestFilter() { ActivePair = pair, TimeFrame = tf } } }; }
public SubscribeTradersMoodChangedRequest(InstrumentType instrumentType, ActivePair activePair) { base.Message = new { name = "traders-mood-changed", @params = new { routingFilters = new { instrument = InstrumentTypeUtilities.GetInstrumentTypeFullName(instrumentType), asset_id = (int)activePair } } }; }
public FinancialInformationRequestMessage( ActivePair pair) { Message = new RequestBody <FinancialInformationModel> { RequestBodyType = RequestMessageBodyType.GetFinancialInformation, Body = new FinancialInformationModel { Query = "query GetAssetProfileInfo($activeId:ActiveID!, $locale: LocaleName){\n active(id: $activeId) {\n id\n name(source: TradeRoom, locale: $locale)\n ticker\n media {\n siteBackground\n }\n charts {\n dtd {\n change\n }\n m1 {\n change\n }\n y1 {\n change\n }\n ytd {\n change\n }\n }\n index_fininfo: fininfo {\n ... on Index {\n description(locale: $locale)\n }\n }\n fininfo {\n ... on Pair {\n type\n description(locale: $locale)\n currency {\n name(locale: $locale)\n }\n base {\n name(locale: $locale)\n ... on Stock {\n company {\n country {\n nameShort\n }\n gics {\n sector\n industry\n }\n site\n domain\n }\n keyStat {\n marketCap\n peRatioHigh\n }\n }\n ... on CryptoCurrency {\n site\n domain\n coinsInCirculation\n maxCoinsQuantity\n volume24h\n marketCap\n }\n }\n }\n }\n }\n }", OperationName = "GetAssetProfileInfo", Variables = new FinancialInformationVariables { ActiveId = pair }, } }; }
public SubscribeLiveDealRequest(string requestId, string message, ActivePair pair, DigitalOptionsExpiryType duration) { base.Message = new { name = message, @params = new { routingFilters = new { instrument_active_id = (int)pair, expiration_type = duration.ToString() } } }; }
public async Task <BinaryOptionsResult> BuyAsync( ActivePair pair, int size, OrderDirection direction, DateTimeOffset expiration) { if (pair == pair) //TODO: Verificar se é digital ou nn { return(await _trader.BuyBinaryAsync( pair, size, direction, expiration)); } return(null); }
public GetExposureRequestMessage(InstrumentType instrumentType, ActivePair activeId, CurrencyCode currency, DateTimeOffset time) { if (time.Second % 60 != 0) { time = time.AddSeconds(60 - time.Second); } Message = new RequestBody <GetExposureModel> { RequestBodyType = RequestMessageBodyType.GetActiveExposure, Body = new GetExposureModel { InstrumentType = instrumentType, ActiveId = (int)activeId, Time = time, Currency = currency, } }; }
public CreateAlertRequestMessage( ActivePair activeId, InstrumentType instrumentType, string type, double value, int activations) { Message = new RequestBody <CreateAlertRequestMessageModel> { RequestBodyType = RequestMessageBodyType.CreateAlert, Body = new CreateAlertRequestMessageModel { AssetId = activeId, IntrumentTypeId = instrumentType, Type = type, Value = value, Activations = activations } }; }
public Task <CandleCollections> GetCandlesAsync(ActivePair pair, TimeFrame tf, int count, DateTimeOffset to) { var tcs = new TaskCompletionSource <CandleCollections>(); try { var sub = CandelsCollectionsObservable.Subscribe(x => { tcs.TrySetResult(x); }); tcs.Task.ContinueWith(t => { sub.Dispose(); return(t.Result); }); SendMessageAsync(new GetCandleItemRequestMessage(pair, tf, count, to)).ConfigureAwait(false); } catch (Exception ex) { tcs.TrySetException(ex); } return(tcs.Task); }
/// <summary> /// Subscribe to the realtime quotes, after called this method /// The <see cref="ActivePair"/> with specific <see cref="TimeFrame"/> will received every single tick /// </summary> /// <param name="pair">The Active pair to subscribe</param> /// <param name="timeFrame">The Time frame to subscribe</param> /// <returns></returns> public Task SubscribeQuoteAsync(ActivePair pair, TimeFrame timeFrame) { return(SendMessageAsync(new SubscribeMessageRequest(pair, timeFrame), "s_")); }
/// <summary> /// UnSubscribe to Traders mood changed /// </summary> /// <param name="string">Request Id</param> /// <param name="type">The Instrument type.</param> /// <param name="pair">The Active pair</param> public void UnSubscribeTradersMoodChanged(string requestId, InstrumentType type, ActivePair pair) { SendMessageAsync(requestId, new UnsubscribeTradersMoodChanged(type, pair), "s_").ConfigureAwait(false); }
public Task <BinaryOptionsResult> BuyAsync(ActivePair pair, int size, OrderDirection direction, DateTimeOffset expiration) { return(WsClient?.BuyAsync(pair, size, direction, expiration)); }
/// <inheritdoc/> public Task <DigitalOptionsPlacedResult> PlaceDigitalOptions(ActivePair pair, OrderDirection direction, DigitalExpiryDuration duration, int amount) => WsClient?.PlaceDigitalOptions(pair, direction, duration, amount);
public Task <CandleCollections> GetCandlesAsync(ActivePair pair, TimeFrame timeFrame, int count, DateTimeOffset to) { return(WsClient?.GetCandlesAsync(pair, timeFrame, count, to)); }
/// <summary> /// UnSubscribe to the realtime quotes, after called this method /// The <see cref="ActivePair"/> with specific <see cref="TimeFrame"/> will not received anymore /// </summary> /// <param name="pair">The Active pair to unsubscribe</param> /// <param name="timeFrame">The Time frame to unsubscribe</param> /// <returns></returns> public Task UnsubscribeCandlesAsync(ActivePair pair, TimeFrame timeFrame) { return(SendMessageAsync(new UnSubscribeMessageRequest(pair, timeFrame))); }
/// <summary> /// Place the DigitalOptions order /// </summary> /// <param name="requestId">Request identifier<example>5f2c370145a047c7b87f2680556b3b93</example></param> /// <param name="pair">The Active pair, make sure your place with correct active.</param> /// <param name="direction">The position direction.</param> /// <param name="duration">The duration period in (1Min, 5Min, 15Min) from now</param> /// <param name="amount">The Amount of position</param> /// <returns></returns> public Task <DigitalOptionsPlacedResult> PlaceDigitalOptions(string requestId, ActivePair pair, OrderDirection direction, DigitalOptionsExpiryDuration duration, double amount) { return(SendMessageAsync(requestId, new PlaceDigitalOptionsMessageRequest(new DigitalOptionsIdentifier( pair, direction, duration, ServerTime), (int)Profile.BalanceId, amount), PlaceDigitalOptionResultObservable)); }
/// <inheritdoc/> public Task UnSubscribeRealtimeData(ActivePair pair, TimeFrame tf) => WsClient?.UnsubscribeCandlesAsync(pair, tf);