Exemplo n.º 1
0
        public TradingItem(TradingStrategy tsItem, string itemCode, string itemName, long buyingPrice, int buyingQnt, bool completeBuying = false, bool sold = false, string buyOrderType = "", string sellOrderType = "")
        {
            this.ts               = tsItem;
            this.itemCode         = itemCode;
            this.itemName         = itemName;
            this.buyingPrice      = buyingPrice;
            this.buyingQnt        = buyingQnt;
            this.outStandingQnt   = buyingQnt;
            this.isCompleteBuying = false;
            this.conditionUid     = ts.buyCondition.Uid;
            this.isBuyCancel      = false;
            this.isCompleteSold   = false;

            this.buyOrderNum  = string.Empty;
            this.sellOrderNum = string.Empty;

            this.buyOrderType = buyOrderType;
            //this.sellOrderType = sellOrderType;
            this.usingDivideSellLoss         = ts.useDivideSellLoss;
            this.usingDivideSellProfit       = ts.useDivideSellProfit;
            this.usingDivideSellLossLoop     = ts.useDivideSellLossLoop;
            this.usingDivideSellProfitLoop   = ts.useDivideSellProfitLoop;
            this.usingStopLossAfterBuyMore   = ts.usingStopLossAfterBuyMore;
            this.usingTakeProfitAfterBuyMore = ts.usingTakeProfitAfterBuyMore;
            this.divideSellCount             = ts.divideSellCount;
            this.divideSellCountProfit       = ts.divideSellCountProfit;
            this.Uid = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
            curState = TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_BEFORE_ORDER;
        }
Exemplo n.º 2
0
 public OnReceiveStrateyStateResultArgs(string itemcode, int buyQnt, int buyPrice, TRADING_ITEM_STATE state)
 {
     this.ItemCode = itemcode;
     this.Price    = buyPrice;
     this.Qnt      = buyQnt;
     this.State    = state;
 }
Exemplo n.º 3
0
 public void StrategyBuyOrderUpdate(string itemCode, int price, int qnt, TRADING_ITEM_STATE state)
 {
     if (OnReceiveBuyOrder != null)
     {
         OnReceiveBuyOrder.Invoke(this, new OnReceiveStrateyStateResultArgs(itemCode, qnt, price, state));
     }
 }
Exemplo n.º 4
0
 public void SetCompleteBuying(bool buying)
 {
     this.isCompleteBuying = buying;
     if (buying)
     {
         curState = TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_COMPLETE;
     }
 }
Exemplo n.º 5
0
 public void SetCompleteSold(bool sold)
 {
     this.isCompleteSold = sold;
     if (sold)
     {
         curState = TRADING_ITEM_STATE.AUTO_TRADING_STATE_SELL_COMPLETE;
     }
 }
Exemplo n.º 6
0
        public TradingItemForSave(BalanceSellStrategy item)
        {
            itemCode = item.itemCode;

            buyingPrice = item.buyingPrice;
            curQnt      = (int)item.curQnt;
            buyingQnt   = (int)item.curQnt;
            sellQnt     = (int)item.sellQnt;

            curState = TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_COMPLETE;
        }
Exemplo n.º 7
0
        public static string StateToString(TRADING_ITEM_STATE state)
        {
            switch (state)
            {
            case TRADING_ITEM_STATE.NONE:
                return(ConstName.AUTO_TRADING_STATE_NONE);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_SELL_NOT_COMPLETE_OUTCOUNT:
                return(ConstName.AUTO_TRADING_STATE_SELL_NOT_COMPLETE_OUTCOUNT);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_SELL_NOT_COMPLETE:
                return(ConstName.AUTO_TRADING_STATE_SELL_NOT_COMPLETE);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_SELL_COMPLETE:
                return(ConstName.AUTO_TRADING_STATE_SELL_COMPLETE);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_SELL_CANCEL_NOT_COMPLETE:
                return(ConstName.AUTO_TRADING_STATE_SELL_CANCEL_NOT_COMPLETE);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_SELL_BEFORE_ORDER:
                return(ConstName.AUTO_TRADING_STATE_SELL_BEFORE_ORDER);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_SEARCH_AND_CATCH:
                return(ConstName.AUTO_TRADING_STATE_SEARCH_AND_CATCH);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_NOT_COMPLETE_OUTCOUNT:
                return(ConstName.AUTO_TRADING_STATE_BUY_NOT_COMPLETE_OUTCOUNT);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_NOT_COMPLETE:
                return(ConstName.AUTO_TRADING_STATE_BUY_NOT_COMPLETE);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_COMPLETE:
                return(ConstName.AUTO_TRADING_STATE_BUY_COMPLETE);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_CANCEL_NOT_COMPLETE:
                return(ConstName.AUTO_TRADING_STATE_BUY_CANCEL_NOT_COMPLETE);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_CANCEL_COMPLETE:
                return(ConstName.AUTO_TRADING_STATE_BUY_CANCEL_COMPLETE);

            case TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_BEFORE_ORDER:
                return(ConstName.AUTO_TRADING_STATE_BUY_BEFORE_ORDER);

            default:
                return("ERROR");
            }
        }
Exemplo n.º 8
0
 public void SetBuyState()
 {
     curState = TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_BEFORE_ORDER;
 }
Exemplo n.º 9
0
 public void SetBuyCancelComplete()
 {
     curState = TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_CANCEL_COMPLETE;
 }
Exemplo n.º 10
0
 public void SetBuyCancelOrder()
 {
     curState         = TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_CANCEL_NOT_COMPLETE;
     this.isBuyCancel = true;
 }
Exemplo n.º 11
0
 public void SetSellCancelOrderComplete()
 {
     curState = TRADING_ITEM_STATE.AUTO_TRADING_STATE_BUY_COMPLETE; //매도 취소 성공 -> 매수 완료 상태
 }
Exemplo n.º 12
0
 public void SetSellCancelOrder()
 {
     curState = TRADING_ITEM_STATE.AUTO_TRADING_STATE_SELL_CANCEL_NOT_COMPLETE;
 }
Exemplo n.º 13
0
 public void SetSold(bool isProfitSell = true)
 {
     this.isProfitSell = isProfitSell;
     curState          = TRADING_ITEM_STATE.AUTO_TRADING_STATE_SELL_BEFORE_ORDER;
 }
Exemplo n.º 14
0
 public void SetState(TRADING_ITEM_STATE _state)
 {
     curState = _state;
 }