예제 #1
0
        public MainController(BitmexRealtimeDataService bitmexRealtimeDataService, HitBtcRealtimeDataService hitBtcRealtimeDataService, IMainView mainView, TradeBitMex2[] tradeBitMex)
        {
            _tradeBitMex = tradeBitMex;
            _bitmexRealtimeDataService = bitmexRealtimeDataService;
            _hitBtcRealtimeDataService = hitBtcRealtimeDataService;
            _mainView = mainView;

            _bitmexRealtimeDataService.Initialize();             // BitMex start subscription and websocket events listening
            _hitBtcRealtimeDataService.Initialize();


            // Model events subscription

            _bitmexRealtimeDataService.TradeDataReceived += (sender, args) => _mainView.Invoke((Action)(() => _mainView.AddTrade(args.Data)));
            _bitmexRealtimeDataService.BalanceReceived   += (sender, args) => _mainView.Invoke((Action)(() => _mainView.Balance = args.Data));
            _bitmexRealtimeDataService.OrderBookReceived += (sender, args) => _mainView.Invoke((Action)(() => _mainView.OrderBookDataSet = args.Data));

            foreach (var t in _tradeBitMex)
            {
                t.OrdersChanged += (sender, args) => {
                    _mainView.Invoke((Action)(() => {
                        _mainView.Orders = t.Orders.ToList().AsReadOnly();
                    }));
                };
            }
        }
예제 #2
0
        public TradeBitMex2(BitmexRealtimeDataService bitmexRealtimeDataService, HitBtcRealtimeDataService hitBtcRealtimeDataService, BitmexDataService bitmexDataService, double limitPriceShift)
        {
            _limitPriceShift = limitPriceShift;

            _bitmexRealtimeDataService = bitmexRealtimeDataService;
            _bitmexDataService         = bitmexDataService;

            _hitBtcRealtimeDataService = hitBtcRealtimeDataService;
            // We don't use HitBtcDataService because at HitBtc orders are sent via websocket

            _bitmexDataService.WebSocket.Message += orderBookRecevied;
            // We dont use any events because we use only market orders placement at HitBtc

            order = new Dictionary <string, Order>();
        }
예제 #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            _dataBase = new DataBase();

            _bitmexDataService         = new BitmexDataService(TradinServer.Real, _dataBase);                    // Real or demo server
            _bitmexRealtimeDataService = new BitmexRealtimeDataService(_bitmexDataService, "ETHUSD");            // + Trading symbol ETHUSD / XBTUSD

            _hitBtcDataService         = new HitBtcDataService(TradinServer.Real);                               // DB instance is not passed as the parameter. The only DB is used in BitmexDataService
            _hitBtcRealtimeDataService = new HitBtcRealtimeDataService(_hitBtcDataService, _dataBase, "ETHUSD"); // We send database class instance in order to update DB records when hedge market orders are filled in such events are triggered in HitBtc websocket event listener


            // Hit btc connection shall be performed like that:
            //_hitbtcDataService = new HitbtcDataService(TradinServer.Demo, _dataBase);
            //_hitbtcRealtimeDataService = new HitbtcRealtimeDataService(_hitbtcDataService, "ETHUSD");

            // // Create the reading class + set up order book limit orders shift
            // XBTUSD: 0, 0.5. 1 ..
            // ETHUSD: 0.05, 0,1, 0,15
            _tradeBitMex2 = new TradeBitMex2(_bitmexRealtimeDataService, _hitBtcRealtimeDataService, _bitmexDataService, 0.05);             // ETHUSD 0.05 Dom price offset. 0 - at the best bid/ask
            //_tradeBitMex3 = new TradeBitMex2(_bitmexRealtimeDataService, _hitBtcRealtimeDataService, _bitmexDataService, 0.1); // Works good

            _mainController = new MainController(_bitmexRealtimeDataService, _hitBtcRealtimeDataService, _mainForm = new Form1(_dataBase), new[] { _tradeBitMex2 });

            // DELETE! WS messages listening must realized through a method in NEW Base class. In this class all events will be located
            // Then WS events will invoke public methods of Trade.cs class
            // BitmexRealtimeDataServices and HITBTC exchange class will inherite these methods from newly created BASE class with events in it.
            // Events located in BitmexRealtimeDataServices line 117

            //_trade = new TradeBitMex(_bitmexDataService, _bitmexDataService.Api);
            //_trade.placeLimitOrder();



            Application.Run(_mainForm);
        }