示例#1
0
        public Mantle.Fix44.OrderCancelReplaceRequest OrderCancelReplaceRequest(
            NewOrderRequest request, string orderID, decimal quantity, decimal price, OnReplaceReject onReject)
        {
            var res = new Mantle.Fix44.OrderCancelReplaceRequest()
            {
                StandardHeader = StandardHeader()
            };

            res.ClOrdID.Value     = _clOrdIDGenerator.GenerateID();
            res.OrigClOrdID.Value = res.ClOrdID.Value;
            res.OrderID.Value     = orderID;
            res.Account.Value     = _cfg.Account;
            if (_cfg.PartyID != null)
            {
                var party = new Mantle.Fix44.Party();
                party.PartyID.Value       = _cfg.PartyID;
                party.PartyIDSource.Value = _cfg.PartyIDSource;
                party.PartyRole.Value     = _cfg.PartyRole;
                res.PartyGroup.Add(party);
            }
            res.Instrument.Symbol.Value = request.Symbol;
            res.Price.Value             = price;
            res.OrderQty.Value          = quantity;
            if (_cfg.TradingSessionID != null)
            {
                res.TradingSessionIDGroup.Add(new Mantle.Fix44.TradingSessionID {
                    Value = _cfg.TradingSessionID
                });
            }
            res.OrdType.Value      = request.OrderType == OrderType.Market ? '1' : '2';
            res.Side.Value         = request.Side == Side.Buy ? '1' : '2';
            res.TransactTime.Value = res.StandardHeader.SendingTime.Value;
            if (onReject == OnReplaceReject.Cancel)
            {
                res.CancelOrigOnReject.Value = true;
            }
            return(res);
        }
示例#2
0
 public Mantle.Fix44.OrderCancelReplaceRequest OrderCancelReplaceRequest(
     NewOrderRequest request, string orderID, decimal quantity, decimal price, OnReplaceReject onReject)
 {
     var res = new Mantle.Fix44.OrderCancelReplaceRequest() { StandardHeader = StandardHeader() };
     res.ClOrdID.Value = _clOrdIDGenerator.GenerateID();
     res.OrigClOrdID.Value = res.ClOrdID.Value;
     res.OrderID.Value = orderID;
     res.Account.Value = _cfg.Account;
     if (_cfg.PartyID != null)
     {
         var party = new Mantle.Fix44.Party();
         party.PartyID.Value = _cfg.PartyID;
         party.PartyIDSource.Value = _cfg.PartyIDSource;
         party.PartyRole.Value = _cfg.PartyRole;
         res.PartyGroup.Add(party);
     }
     res.Instrument.Symbol.Value = request.Symbol;
     res.Price.Value = price;
     res.OrderQty.Value = quantity;
     if (_cfg.TradingSessionID != null)
         res.TradingSessionIDGroup.Add(new Mantle.Fix44.TradingSessionID { Value = _cfg.TradingSessionID });
     res.OrdType.Value = request.OrderType == OrderType.Market ? '1' : '2';
     res.Side.Value = request.Side == Side.Buy ? '1' : '2';
     res.TransactTime.Value = res.StandardHeader.SendingTime.Value;
     if (onReject == OnReplaceReject.Cancel)
         res.CancelOrigOnReject.Value = true;
     return res;
 }
示例#3
0
        public Mantle.Fix44.NewOrderSingle NewOrderSingle(NewOrderRequest req)
        {
            var res = new Mantle.Fix44.NewOrderSingle()
            {
                StandardHeader = StandardHeader()
            };

            res.ClOrdID.Value = _clOrdIDGenerator.GenerateID();
            res.Account.Value = _cfg.Account;
            if (_cfg.PartyID != null)
            {
                var party = new Mantle.Fix44.Party();
                party.PartyID.Value       = _cfg.PartyID;
                party.PartyIDSource.Value = _cfg.PartyIDSource;
                party.PartyRole.Value     = _cfg.PartyRole;
                res.PartyGroup.Add(party);
            }
            if (_cfg.TradingSessionID != null)
            {
                res.TradingSessionIDGroup.Add(new Mantle.Fix44.TradingSessionID {
                    Value = _cfg.TradingSessionID
                });
            }
            res.Instrument.Symbol.Value = req.Symbol;
            res.Side.Value         = req.Side == Side.Buy ? '1' : '2';
            res.TransactTime.Value = res.StandardHeader.SendingTime.Value;
            res.OrdType.Value      = req.OrderType == OrderType.Market ? '1' : '2';
            if (req.Price.HasValue)
            {
                res.Price.Value = req.Price.Value;
            }
            if (req.TimeToLive.HasValue)
            {
                res.TimeInForce.Value = '6';  // Good Till Date
                res.ExpireTime.Value  = DateTime.UtcNow + req.TimeToLive.Value;
            }
            res.OrderQtyData.OrderQty.Value = req.Quantity;
            if (_cfg.Extensions == Extensions.Huobi)
            {
                res.MinQty.Value = req.Quantity;
                string method = req.Side == Side.Buy ? "buy" : "sell";
                string price  = null;
                if (req.OrderType == OrderType.Market)
                {
                    method += "_market";
                }
                else
                {
                    if (!req.Price.HasValue)
                    {
                        throw new ArgumentException("Limit order is missing Price");
                    }
                    price = ToHuobiString(req.Price.Value);
                }
                res.HuobiSignature = HuobiSignature
                                     (
                    new KeyValuePair <string, string>[]
                {
                    new KeyValuePair <string, string>("method", method),
                    new KeyValuePair <string, string>("amount", ToHuobiString(req.Quantity)),
                    new KeyValuePair <string, string>("coin_type", HuobiCoinType(req.Symbol)),
                    new KeyValuePair <string, string>("price", price),
                }
                                     );
            }
            if (_cfg.Extensions == Extensions.Btcc)
            {
                string price = "";
                if (req.OrderType == OrderType.Limit)
                {
                    if (!req.Price.HasValue)
                    {
                        throw new ArgumentException("Limit order is missing Price");
                    }
                    price = ToBtccString(req.Price.Value);
                }
                string method = req.Side == Side.Buy ? "buy" : "sell";
                // This is undocumented.
                method           += $"Order3&params={price},{ToBtccString(req.Quantity)},{req.Symbol}";
                res.Account.Value = BtccSignature(_cfg.Account, _cfg.SecretKey, method);
            }
            return(res);
        }
示例#4
0
 public Mantle.Fix44.NewOrderSingle NewOrderSingle(NewOrderRequest request)
 {
     var res = new Mantle.Fix44.NewOrderSingle() { StandardHeader = StandardHeader() };
     res.ClOrdID.Value = _clOrdIDGenerator.GenerateID();
     res.Account.Value = _cfg.Account;
     if (_cfg.PartyID != null)
     {
         var party = new Mantle.Fix44.Party();
         party.PartyID.Value = _cfg.PartyID;
         party.PartyIDSource.Value = _cfg.PartyIDSource;
         party.PartyRole.Value = _cfg.PartyRole;
         res.PartyGroup.Add(party);
     }
     if (_cfg.TradingSessionID != null)
         res.TradingSessionIDGroup.Add(new Mantle.Fix44.TradingSessionID { Value = _cfg.TradingSessionID });
     res.Instrument.Symbol.Value = request.Symbol;
     res.Side.Value = request.Side == Side.Buy ? '1' : '2';
     res.TransactTime.Value = res.StandardHeader.SendingTime.Value;
     res.OrdType.Value = request.OrderType == OrderType.Market ? '1' : '2';
     if (request.Price.HasValue)
         res.Price.Value = request.Price.Value;
     if (request.TimeToLive.HasValue)
     {
         res.TimeInForce.Value = '6';  // Good Till Date
         res.ExpireTime.Value = DateTime.UtcNow + request.TimeToLive.Value;
     }
     res.OrderQtyData.OrderQty.Value = request.Quantity;
     if (_cfg.Extensions == Extensions.Huobi)
     {
         res.MinQty.Value = request.Quantity;
         string method = request.Side == Side.Buy ? "buy" : "sell";
         string price = null;
         if (request.OrderType == OrderType.Market)
         {
             method += "_market";
         }
         else
         {
             if (!request.Price.HasValue) throw new ArgumentException("Limit order is missing Price");
             price = ToHuobiString(request.Price.Value);
         }
         res.HuobiSignature = HuobiSignature
         (
             new KeyValuePair<string, string>[]
             {
                 new KeyValuePair<string, string>("method", method),
                 new KeyValuePair<string, string>("amount", ToHuobiString(request.Quantity)),
                 new KeyValuePair<string, string>("coin_type", HuobiCoinType(request.Symbol)),
                 new KeyValuePair<string, string>("price", price),
             }
         );
     }
     return res;
 }