コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: aliyome/BitFlyerDotNet
 public void Initialize()
 {
     _account = new BfTradingAccount();
     _account.Login(_key, _secret);
     _market = _account.GetMarket(ProductCode);
     //_market.GetOrderBookSource();
     //_market.ChildOrderChanged += OnChildOrderChanged;
     //_market.ChildOrderTransactionStateChanged += OnChildOrderTransactionChanged;
     _factory = new BfxOrderFactory(_market);
 }
コード例 #2
0
        // Pass key and secret from arguments.
        static void Main(string[] args)
        {
            // Set API ket and secret
            _account = new BfTradingAccount();
            if (args.Length == 2)
            {
                _account.Login(args[0], args[1]);
            }
            else
            {
                Console.Write("API Key   :"); var key    = Console.ReadLine();
                Console.Write("API Secret:"); var secret = Console.ReadLine();
                if (!string.IsNullOrEmpty(key))
                {
                    _account.Login(key, secret);
                }
                else
                {
                    _account.Initialize();
                }
            }

            // Register event handlers
            _market = _account.GetMarket(ProductCode);
            _market.ChildOrderTransactionStateChanged += OnChildOrderTransactionStateChanged;
            _market.ChildOrderChanged += OnChildOrderChanged;
            _market.ParentOrderTransactionStateChanged += OnParentOrderTransactionStateChanged;
            _market.ParentOrderChanged += OnParentOrderChanged;
            _market.TickerChanged      += OnTickerChanged;
            _market.PositionChanged    += OnPositionChanged;

            _orderFactory = new BfxOrderFactory(_market);

            while (true)
            {
                Console.WriteLine("======== Main menu");
                Console.WriteLine("1) Open market sample");
                Console.WriteLine("C) Child order samples");
                Console.WriteLine("P) Parent order samples");
                Console.WriteLine("");
                Console.WriteLine("Q) Quit sample");

                switch (GetCh())
                {
                case '1':
                    OpenMarket();
                    break;

                case 'C':
                    ChildOrderMain();
                    break;

                case 'P':
                    ParentOrderMain();
                    break;

                case 'Q':
                    _disposables.Dispose();
                    return;
                }
            }
        }