CloseOrderBase.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. using GalaSoft.MvvmLight;
  2. using GalaSoft.MvvmLight.Command;
  3. using GalaSoft.MvvmLight.Ioc;
  4. using Muchinfo.MTPClient.Data;
  5. using Muchinfo.MTPClient.Data.Enums;
  6. using Muchinfo.MTPClient.Data.Helper;
  7. using Muchinfo.MTPClient.Data.Model;
  8. using Muchinfo.MTPClient.Data.Model.Account;
  9. using Muchinfo.MTPClient.Infrastructure.Utilities;
  10. using Muchinfo.MTPClient.IService;
  11. using Muchinfo.MTPClient.Resources;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.IO;
  15. using System.Linq;
  16. //----------------------------------------------------------------
  17. //Module Name: $safeprojectname$
  18. //Purpose:
  19. //CopyRight: Muchinfo
  20. //History:
  21. //----------------------------------------------------------------
  22. //DateTime 2016/1/16 16:30:29
  23. //Author
  24. //Description Create
  25. //----------------------------------------------------------------
  26. using System.Windows;
  27. using System.Windows.Media.Imaging;
  28. namespace Muchinfo.MTPClient.Trade.ViewModels
  29. {
  30. public class CloseOrderBase : ViewModelBase
  31. {
  32. #region Fields
  33. private ExpirationType _currentExpirationType;
  34. private bool _isBidDirection;
  35. private QuoteGoods _currentGoods; ////当前商品
  36. private OrderType _currentOrderType;
  37. private decimal _executePrice;
  38. protected IGoodsService _goodsService;
  39. protected IOrderService _orderService;
  40. protected List<HoldingSummary> _holdingSummaries;
  41. private Visibility _limitOrderGridVisibility;
  42. private Visibility _marketOrderGridVisibility;
  43. protected HoldingSummary _holdingSummary; //持仓汇总记录。
  44. private decimal _pips = 5;
  45. //修改止盈/止损
  46. private bool canProfitCharChange = false;
  47. private bool canLossCharChange = false;
  48. private decimal _minPips = 0m;
  49. private decimal _maxPips = 100m;
  50. private decimal _incrementPips = 10m;
  51. private decimal _marketPrice;
  52. private Direction _openDirection;
  53. private bool _isAllowPips = true;//是否允许点差
  54. private bool _isAllowEnsturt; //是否允许限价平仓
  55. #endregion Fields
  56. /// <summary>
  57. /// 当前商品
  58. /// </summary>
  59. public QuoteGoods CurrentGoods
  60. {
  61. get
  62. {
  63. return _currentGoods;
  64. }
  65. set { _currentGoods = value; }
  66. }
  67. /// <summary>
  68. /// 最大手数
  69. /// </summary>
  70. private decimal _maxLot;
  71. /// <summary>
  72. /// Sets and gets the MaxLot property.
  73. /// Changes to that property's value raise the PropertyChanged event.
  74. /// </summary>
  75. public decimal MaxLot
  76. {
  77. get
  78. {
  79. return _maxLot;
  80. }
  81. set
  82. {
  83. Set(() => MaxLot, ref _maxLot, value);
  84. }
  85. }
  86. private bool _isDirectionEnable;
  87. /// <summary>
  88. /// 是否选择方向
  89. /// </summary>
  90. public bool IsDirectionEnable
  91. {
  92. get
  93. {
  94. return _isDirectionEnable;
  95. }
  96. set
  97. {
  98. Set(() => IsDirectionEnable, ref _isDirectionEnable, value);
  99. }
  100. }
  101. private decimal _lot;
  102. /// <summary>
  103. /// Sets and gets the Lot property.
  104. /// Changes to that property's value raise the PropertyChanged event.
  105. /// </summary>
  106. public decimal Lot
  107. {
  108. get
  109. {
  110. return _lot;
  111. }
  112. set
  113. {
  114. Set(() => Lot, ref _lot, value);
  115. }
  116. }
  117. public CloseOrderBase(HoldingOrder holdOrder, QuoteGoods selectQuoteGoods, OrderType orderType = OrderType.MarketCloseOrder)
  118. {
  119. if (holdOrder != null)
  120. {
  121. HoldOrder = holdOrder;
  122. OpenDirection = HoldOrder.Direction;
  123. ExecutePrice = HoldOrder.ClosePrice;
  124. IsBidDirection = holdOrder.Direction == Direction.Ask;
  125. IsAskDirection = !IsBidDirection;
  126. MaxLot = holdOrder.Lot;
  127. }
  128. IsDirectionEnable = false;
  129. CurrentGoods = selectQuoteGoods;
  130. CurrentOrderType = orderType;
  131. }
  132. /// <summary>
  133. /// 汇总平仓
  134. /// </summary>
  135. /// <param name="holdingSummary"></param>
  136. /// <param name="orderType"></param>
  137. public CloseOrderBase(HoldingSummary holdingSummary, QuoteGoods selectQuoteGoods)
  138. {
  139. if (holdingSummary != null)
  140. {
  141. _holdingSummary = holdingSummary;
  142. MaxLot = holdingSummary.Lot;
  143. OpenDirection = holdingSummary.Direction;
  144. IsBidDirection = holdingSummary.Direction == Direction.Ask;
  145. IsAskDirection = !IsBidDirection;
  146. }
  147. CurrentGoods = selectQuoteGoods;
  148. IsDirectionEnable = false;
  149. }
  150. /// <summary>
  151. /// 汇总平仓
  152. /// </summary>
  153. /// <param name="selectQuoteGoods"></param>
  154. public CloseOrderBase(QuoteGoods selectQuoteGoods)
  155. {
  156. _goodsService = SimpleIoc.Default.GetInstance<IGoodsService>();
  157. _orderService = SimpleIoc.Default.GetInstance<IOrderService>();
  158. CurrentGoods = selectQuoteGoods;
  159. }
  160. private HoldingOrder _holdOrder;
  161. /// <summary>
  162. /// 所平建仓单
  163. /// </summary>
  164. public HoldingOrder HoldOrder
  165. {
  166. get
  167. {
  168. return _holdOrder;
  169. }
  170. set
  171. {
  172. Set(() => HoldOrder, ref _holdOrder, value);
  173. //RaisePropertyChanged(() => OpeneOrderDetail);
  174. if (_holdOrder != null)
  175. {
  176. MaxLot = _holdOrder.Lot - _holdOrder.FrozenQty; //可平仓数量=总数-冻结数量
  177. Lot = MaxLot;
  178. }
  179. }
  180. }
  181. #region Properties
  182. #region 验证字符串
  183. /// <summary>
  184. /// 验证是否选择商品
  185. /// </summary>
  186. public string GoodsVailedString
  187. {
  188. get
  189. {
  190. return this.CurrentGoods != null ? string.Empty : Muchinfo_Resource.GoodsSelect_Vailed;
  191. }
  192. }
  193. private bool _isOrderTypeEnable;
  194. /// <summary>
  195. /// 是否可以选择平仓类型
  196. /// </summary>
  197. public bool IsOrderTypeEnable
  198. {
  199. get
  200. {
  201. return _isOrderTypeEnable;
  202. }
  203. set
  204. {
  205. Set(() => IsOrderTypeEnable, ref _isOrderTypeEnable, value);
  206. }
  207. }
  208. #endregion
  209. #region Public Properties
  210. /// <summary>
  211. /// 判断价格方向
  212. /// </summary>
  213. public string EntructPriceChar
  214. {
  215. get
  216. {
  217. switch (OpenDirection)
  218. {
  219. case Direction.Ask:
  220. {
  221. return "≤";
  222. }
  223. case Direction.Bid:
  224. {
  225. return "≥";
  226. }
  227. default:
  228. {
  229. return string.Empty;
  230. }
  231. }
  232. }
  233. }
  234. private bool _isExpiration = true;
  235. /// <summary>
  236. /// 修改止盈止损时,是否可选
  237. /// </summary>
  238. public bool IsExpiration
  239. {
  240. get
  241. {
  242. return _isExpiration;
  243. }
  244. set
  245. {
  246. Set(() => IsExpiration, ref _isExpiration, value);
  247. }
  248. }
  249. /// <summary>
  250. /// 委托价格范围
  251. /// </summary>
  252. private decimal _entructPriceRange;
  253. /// <summary>
  254. /// 委托价格范围
  255. /// </summary>
  256. public decimal EntructPriceRange
  257. {
  258. get
  259. {
  260. return _entructPriceRange;
  261. }
  262. set
  263. {
  264. _entructPriceRange = value;
  265. RaisePropertyChanged(() => EntructPriceRangeDisplay);
  266. }
  267. }
  268. /// <summary>
  269. /// 委托价范围 格式化
  270. /// </summary>
  271. public string EntructPriceRangeDisplay
  272. {
  273. get { return EntructPriceRange.ToString(PriceFormat); }
  274. }
  275. private bool _isLotEnable = true;
  276. /// <summary>
  277. /// 是否可设置数量
  278. /// </summary>
  279. public bool IsLotEnable
  280. {
  281. get { return _isLotEnable; }
  282. set { Set(() => IsLotEnable, ref _isLotEnable, value); }
  283. }
  284. /// <summary>
  285. /// 价格格式化
  286. /// </summary>
  287. public string PriceFormat
  288. {
  289. get
  290. {
  291. if (this.CurrentGoods != null)
  292. {
  293. return CurrentGoods.FormatPrice;
  294. }
  295. else
  296. {
  297. return "F0";
  298. }
  299. }
  300. }
  301. private double _windowHeight = 460;
  302. /// <summary>
  303. /// 窗口高度
  304. /// </summary>
  305. public double WindowHeight
  306. {
  307. get { return _windowHeight; }
  308. set { Set(() => WindowHeight, ref _windowHeight, value); }
  309. }
  310. private string _busyTips;
  311. /// <summary>
  312. /// 服务忙提示
  313. /// </summary>
  314. public string BusyTips
  315. {
  316. get
  317. {
  318. return _busyTips;
  319. }
  320. set
  321. {
  322. Set(() => BusyTips, ref _busyTips, value);
  323. }
  324. }
  325. public string TradeCode
  326. {
  327. get
  328. {
  329. if (UserManager.CurrentTradeAccount == null)
  330. {
  331. return string.Empty;
  332. }
  333. return UserManager.CurrentTradeAccount.TradeCode;
  334. }
  335. }
  336. /// <summary>
  337. /// 表单买卖方向
  338. /// </summary>
  339. public bool IsBidDirection
  340. {
  341. get
  342. {
  343. return _isBidDirection;
  344. }
  345. set
  346. {
  347. Set(() => IsBidDirection, ref _isBidDirection, value);
  348. if (value && IsDirectionEnable)
  349. {
  350. //设置方向的持仓汇总
  351. var holdingSummary =
  352. this._holdingSummaries.FirstOrDefault((item) => item.Direction == Direction.Ask);
  353. SetHoldingSummay(holdingSummary);
  354. }
  355. }
  356. }
  357. private bool _isAskDirection;
  358. public bool IsAskDirection
  359. {
  360. get
  361. {
  362. return _isAskDirection;
  363. }
  364. set
  365. {
  366. Set(() => IsAskDirection, ref _isAskDirection, value);
  367. if (value && IsDirectionEnable)
  368. {
  369. //设置买方向的持仓汇总
  370. var holdingSummary =
  371. this._holdingSummaries.FirstOrDefault((item) => item.Direction == Direction.Bid);
  372. SetHoldingSummay(holdingSummary);
  373. }
  374. }
  375. }
  376. /// <summary>
  377. /// 取消命令
  378. /// </summary>
  379. public RelayCommand<Window> CancelCommand
  380. {
  381. get
  382. {
  383. return new RelayCommand<Window>((view) =>
  384. {
  385. //todo:取消平仓
  386. view.DialogResult = true; //
  387. });
  388. }
  389. }
  390. /// <summary>
  391. /// Sets and gets the CurrentExpirationType property.
  392. /// Changes to that property's value raise the PropertyChanged event.
  393. /// </summary>
  394. public ExpirationType CurrentExpirationType
  395. {
  396. get
  397. {
  398. return _currentExpirationType;
  399. }
  400. set
  401. {
  402. Set(() => CurrentExpirationType, ref _currentExpirationType, value);
  403. }
  404. }
  405. private decimal _openLot;
  406. /// <summary>
  407. /// 反手建仓数量
  408. /// </summary>
  409. public decimal OpenLot
  410. {
  411. get { return _openLot; }
  412. set { Set(() => OpenLot, ref _openLot, value); }
  413. }
  414. /// <summary>
  415. /// 商品图片资源
  416. /// </summary>
  417. public BitmapImage ImageSource
  418. {
  419. get
  420. {
  421. if (File.Exists(UserManager.SysConfigFolderPath + "\\GoodsImages\\" + _currentGoods.GoodsCode + "." + ApplicationParameter.ImageExtension))
  422. {
  423. return new BitmapImage(new Uri(UserManager.SysConfigFolderPath + "\\GoodsImages\\" + _currentGoods.GoodsCode + "." + ApplicationParameter.ImageExtension));
  424. }
  425. else
  426. {
  427. return null;
  428. }
  429. }
  430. }
  431. /// <summary>
  432. /// 图片可见性
  433. /// </summary>
  434. public Visibility ImageVisibility
  435. {
  436. get
  437. {
  438. if (File.Exists(UserManager.SysConfigFolderPath + "\\GoodsImages\\" + _currentGoods.GoodsCode + "." + ApplicationParameter.ImageExtension))
  439. {
  440. return Visibility.Visible;
  441. }
  442. else
  443. {
  444. return Visibility.Collapsed;
  445. }
  446. }
  447. }
  448. /// <summary>
  449. /// Sets and gets the CurrentOrderType property.
  450. /// Changes to that property's value raise the PropertyChanged event.
  451. /// </summary>
  452. public OrderType CurrentOrderType
  453. {
  454. get
  455. {
  456. return _currentOrderType;
  457. }
  458. set
  459. {
  460. Set(() => CurrentOrderType, ref _currentOrderType, value);
  461. if (value == OrderType.MarketCloseOrder || value == OrderType.BidMarketClose)
  462. {
  463. MarketOrderGridVisibility = Visibility.Visible;
  464. LimitOrderGridVisibility = Visibility.Collapsed;
  465. }
  466. else if (value == OrderType.LimitCloseOrder || value == OrderType.BidLimitClose)
  467. {
  468. MarketOrderGridVisibility = Visibility.Collapsed;
  469. LimitOrderGridVisibility = Visibility.Visible;
  470. }
  471. }
  472. }
  473. /// <summary>
  474. /// 获取报价
  475. /// </summary>
  476. public string QuotePriceDisplay
  477. {
  478. get
  479. {
  480. return QuotePrice.ToString(PriceFormat);
  481. }
  482. }
  483. private decimal _quotePrice; //当前行情价
  484. /// <summary>
  485. /// 当前行情价
  486. /// </summary>
  487. public decimal QuotePrice
  488. {
  489. get
  490. {
  491. return _quotePrice;
  492. }
  493. set
  494. {
  495. Set(() => QuotePrice, ref _quotePrice, value);
  496. RaisePropertyChanged(() => QuotePriceDisplay);
  497. }
  498. }
  499. /// <summary>
  500. /// 显示商品行情小数位
  501. /// </summary>
  502. public int Figures
  503. {
  504. get
  505. {
  506. if (this.CurrentGoods != null && this.CurrentGoods.GoodsParameters != null && CurrentGoods.GoodsParameters.HqExchFigures < 20 && CurrentGoods.GoodsParameters.HqExchFigures > -20)
  507. {
  508. return this.CurrentGoods.GoodsParameters.HqExchFigures;
  509. }
  510. return 0;
  511. }
  512. }
  513. /// <summary>
  514. /// 执行价格
  515. /// </summary>
  516. public decimal ExecutePrice
  517. {
  518. get
  519. {
  520. return _executePrice;
  521. }
  522. set
  523. {
  524. Set(() => ExecutePrice, ref _executePrice, value);
  525. // RaisePropertyChanged(() => PriceVailedString);
  526. }
  527. }
  528. /// <summary>
  529. /// Cleanups this instance.
  530. /// </summary>
  531. public override void Cleanup()
  532. {
  533. ////取消注册消息
  534. base.Cleanup();
  535. ApplicationParameter.QuotationMessenger.Unregister(this);
  536. }
  537. /// <summary>
  538. /// 获取和设置the expiration types
  539. /// </summary>
  540. public Dictionary<ExpirationType, string> ExpirationTypes
  541. {
  542. get
  543. {
  544. var types = new Dictionary<ExpirationType, string>();
  545. ExpirationType expirationType;
  546. try
  547. {
  548. string[] expirationData = ApplicationParameter.ExpirationType.Split(',');
  549. for (int i = 0; i < expirationData.Length; i++)
  550. {
  551. expirationType = (ExpirationType)System.Enum.Parse(typeof(ExpirationType), expirationData[i], true);
  552. types.Add(expirationType, expirationType.Discription());
  553. }
  554. }
  555. catch (Exception e)
  556. {
  557. // LogHelper.WriteInfo(e.Message);
  558. }
  559. //types.Add(ExpirationType.Today, ExpirationType.Today.Discription());
  560. //types.Add(ExpirationType.SomeTime, "指定时间有效");
  561. //types.Add(ExpirationType.Weekday, ExpirationType.Weekday.Discription());
  562. return types;
  563. }
  564. }
  565. /// <summary>
  566. /// Sets and gets the LimitOrderVisibility property.
  567. /// Changes to that property's value raise the PropertyChanged event.
  568. /// </summary>
  569. public Visibility LimitOrderGridVisibility
  570. {
  571. get
  572. {
  573. return _limitOrderGridVisibility;
  574. }
  575. set
  576. {
  577. Set(() => LimitOrderGridVisibility, ref _limitOrderGridVisibility, value);
  578. }
  579. }
  580. private bool _isBidMarket;
  581. /// <summary>
  582. /// 是否是竞价商品
  583. /// </summary>
  584. public bool IsBidMarket
  585. {
  586. get { return _isBidMarket; }
  587. set { Set(() => IsBidMarket, ref _isBidMarket, value); }
  588. }
  589. /// <summary>
  590. /// Sets and gets the MarketOrderVisibility property.
  591. /// Changes to that property's value raise the PropertyChanged event.
  592. /// </summary>
  593. public Visibility MarketOrderGridVisibility
  594. {
  595. get
  596. {
  597. return _marketOrderGridVisibility;
  598. }
  599. set
  600. {
  601. Set(() => MarketOrderGridVisibility, ref _marketOrderGridVisibility, value);
  602. }
  603. }
  604. /// <summary>
  605. /// 获取和设置the order types
  606. /// </summary>
  607. public virtual Dictionary<OrderType, string> OrderTypes
  608. {
  609. get
  610. {
  611. var types = new Dictionary<OrderType, string>
  612. {
  613. {OrderType.MarketCloseOrder, OrderType.MarketCloseOrder.Discription()},
  614. {OrderType.LimitCloseOrder, Muchinfo_Resource.OrderType_Enum_LimitClose}
  615. };
  616. return types;
  617. }
  618. }
  619. /// <summary>
  620. /// Sets and gets the Pips property.
  621. /// Changes to that property's value raise the PropertyChanged event.
  622. /// </summary>
  623. public decimal Pips
  624. {
  625. get
  626. {
  627. return _pips;
  628. }
  629. set
  630. {
  631. Set(() => Pips, ref _pips, value);
  632. }
  633. }
  634. /// <summary>
  635. /// 最小点差值
  636. /// </summary>
  637. public decimal MinPips
  638. {
  639. get { return _minPips; }
  640. set { Set(() => MinPips, ref _minPips, value); }
  641. }
  642. /// <summary>
  643. /// 最大点差值
  644. /// </summary>
  645. public decimal MaxPips
  646. {
  647. get { return _maxPips; }
  648. set { Set(() => MaxPips, ref _maxPips, value); }
  649. }
  650. /// <summary>
  651. /// 点差递增值
  652. /// </summary>
  653. public decimal IncrementPips
  654. {
  655. get { return _incrementPips; }
  656. set { Set(() => IncrementPips, ref _incrementPips, value); }
  657. }
  658. /// <summary>
  659. /// 格式化字符串
  660. /// </summary>
  661. public string DisplayFormat
  662. {
  663. get
  664. {
  665. if (this.CurrentGoods == null)
  666. {
  667. return "F0";
  668. }
  669. else
  670. {
  671. return CurrentGoods.FormatPrice;
  672. }
  673. }
  674. }
  675. /// <summary>
  676. /// 是否允许点差
  677. /// </summary>
  678. public bool IsAllowPips
  679. {
  680. get
  681. {
  682. return _isAllowPips;
  683. }
  684. set
  685. {
  686. Set(() => IsAllowPips, ref _isAllowPips, value);
  687. }
  688. }
  689. /// <summary>
  690. /// 关闭清除订阅消息
  691. /// </summary>
  692. public RelayCommand ClosedCommand
  693. {
  694. get
  695. {
  696. return new RelayCommand(() =>
  697. {
  698. this.Cleanup();
  699. });
  700. }
  701. }
  702. private bool _isAllowOpen;
  703. /// <summary>
  704. /// 是否允许反手建仓
  705. /// </summary>
  706. public bool IsAllowOpen
  707. {
  708. get { return _isAllowOpen; }
  709. set { Set(() => IsAllowOpen, ref _isAllowOpen, value); }
  710. }
  711. /// <summary>
  712. /// 暂时使用点差列表
  713. /// </summary>
  714. public List<decimal> PipsInts
  715. {
  716. //todo:点差计算方式从服务器取
  717. get
  718. {
  719. var intList = new List<decimal>();
  720. for (int i = 0; i < 11; i++)
  721. {
  722. intList.Add(i * 10);
  723. }
  724. return intList;
  725. }
  726. }
  727. /// <summary>
  728. /// 持仓单据方向
  729. /// </summary>
  730. public Direction OpenDirection
  731. {
  732. get
  733. {
  734. return _openDirection;
  735. }
  736. set
  737. {
  738. Set(() => OpenDirection, ref _openDirection, value);
  739. }
  740. }
  741. /// <summary>
  742. /// 设置汇总平仓参数设置
  743. /// </summary>
  744. protected void SetHoldingSummay(HoldingSummary holding)
  745. {
  746. if (holding != null)
  747. {
  748. _holdingSummary = holding;
  749. MaxLot = holding.Lot;
  750. }
  751. }
  752. #endregion Public Properties
  753. #endregion Properties
  754. #region 虚函数定义 OTC与竞价不同的市场使用重写不同的
  755. /// <summary>
  756. /// 验证信息
  757. /// </summary>
  758. /// <returns></returns>
  759. public virtual bool Validated()
  760. {
  761. return true;
  762. }
  763. /// <summary>
  764. /// 创建下单委托对象
  765. /// </summary>
  766. /// <returns>下单委托对象</returns>
  767. public virtual NewEntrustOrder BuildEntrustOrder()
  768. {
  769. var entrustOrder = new NewEntrustOrder()
  770. {
  771. AccountId = UserManager.CurrentTradeAccount.AccountId,
  772. GoodsCode = this.CurrentGoods.GoodsCode,
  773. GoodId = (uint)this.CurrentGoods.GoodsParameters.GoodsId,
  774. MemberId = (uint)UserManager.CurrentTradeAccount.MemberAreaId,
  775. MarketId = (uint)this.CurrentGoods.GoodsParameters.MarketId,
  776. AccountType = UserManager.CurrentTradeAccount.AccountType,
  777. BuyOrSell = OpenDirection == Direction.Ask ? Direction.Bid : Direction.Ask,
  778. EntrustQuantity = Lot,
  779. EntrurstTime = ApplicationParameter.ServerTimeNow,
  780. OpenType = OpenClose.Close,
  781. };
  782. if (this.HoldOrder != null)
  783. {
  784. entrustOrder.RelationTicket = HoldOrder.OrderID;
  785. entrustOrder.SpecialAccount = HoldOrder.SettlementMember;
  786. }
  787. entrustOrder.OrderMode = OrderMode.InValid;
  788. // entrustOrder.TradeCloseMode = TradeCloseMode.IsVailed;
  789. entrustOrder.ValidType = CurrentExpirationType;
  790. return entrustOrder;
  791. }
  792. /// <summary>
  793. /// 提交表单
  794. /// </summary>
  795. /// <param name="successAction">成功回调</param>
  796. /// <param name="errorAction">错误返回</param>
  797. public virtual void PostOrder(Action<OrderDetail> successAction, Action<ErrorEntity> errorAction)
  798. {
  799. }
  800. #endregion
  801. }
  802. }