Esempio n. 1
0
        public WsIQClientRx()
        {
            // TODO INJECT
            _ws            = new WebSocketWrapper();
            _epoch         = new Epoch();
            _randomNumbers = new RandomNumbers();

            MessagesFeed = Observable
                           .FromEventPattern <OnMessageEventHandler, WsRecievemessageEventArgs>(
                h => _ws.OnMessage += h,
                h => _ws.OnMessage -= h)
                           //.ObserveOn(NewThreadScheduler.Default)
                           .Map((e) =>
            {
                var serializedMessage = e.EventArgs.Message;
                var iQmessage         = JsonConvert.DeserializeObject <IQOptionMessage>(serializedMessage);
                return(iQmessage);
            });

            _onConnection = Observable
                            .FromEventPattern <OnConnectedEventHandler, EventArgs>(
                h => _ws.OnConnected += h,
                h => _ws.OnConnected -= h)
                            .Map(e => e.EventArgs)
                            .Replay();

            _onConnectionConnection = _onConnection.Connect();

            //TODO DO THIS IN THE IQCLient
            _ssidDualChannel = new SsidPublisherChannel(this);

            _heartBeatDualChannel = new HeartBeatDualChannel(this);

            _wsMessagesSubscription = _heartBeatDualChannel.ChannelFeed
                                      .Map(heartbeat => _heartBeatDualChannel.SendMessage(new HeartBeatOutputMessage(_epoch.EpochMilliSeconds, heartbeat.HeartbeatTime)))
                                      .Subscribe();

            _candleGeneratedDualChannel = new CandleGeneratedDualChannel(this);

            _serverTimeSync = new TimeSyncListenerChannel(this);

            _profileChannel = new ProfileListenerChannel(this);

            _listInfoDataChannelListener = new ListInfoDataListenerChannel(this);

            _buyV2ChannelPublisher = new BuyV2Channel(this, _epoch);
        }
Esempio n. 2
0
 public DateTime AtUtcDateTime(IEpoch epoch)
 {
     return(epoch.FromUnixTimeToDateTime(this.AtTimeStamp));
 }
Esempio n. 3
0
 public BuyV2Channel(IWsIQClient wsIqClient, IEpoch epoch)
 {
     _wsIqClient = wsIqClient;
     _epoch      = epoch;
     _publisher  = new IqOptionGenericChannelPublisher <dynamic>(wsIqClient, ChannelName);
 }
Esempio n. 4
0
        private static void Dump(IEpoch epoch, LogicalNetworEntity best)
        {
            Console.WriteLine("{0} - Best error: {1}, NA.Gates: {2}, Nodes: {3}, Conns: {4}, DNA: {5}",
                epoch.CurrentIteration,
                best.Errors,
                best.NumberOfNotAllowedGates,
                best.Network.NumberOfNodes,
                best.Network.NumberOfConnections,
                best.Plan.Length);

            var gateEntries = best.Network.Entries.Where(e => e.NodeEntry.Node is LogicGate);
            foreach (var gateEntry in gateEntries)
            {
                Console.Write(new LogicGateType(((LogicGate)gateEntry.NodeEntry.Node).Operation, gateEntry.UpperConnectionEntries.Count));
                Console.Write(" ");
            }
            Console.WriteLine();
        }