Пример #1
0
 public Strategy(Exchange exchange, Symbol symbol, TradeBin tradeBin)
 {
     Exchange       = exchange;
     Symbol         = symbol;
     TradeBin       = tradeBin;
     Timeout        = Const.DIRECTIONAL_STRATEGY_TIMEOUT;
     LeveragePosted = false;
 }
Пример #2
0
 public override string GetTradeBin(TradeBin tradeBin, string symbol)
 {
     return(GetTradeBin(new Dictionary <string, object>
     {
         ["symbol"] = symbol,
         ["interval"] = tradeBin.ToShortLabel(),
     }));
 }
Пример #3
0
 public override string GetTradeBin(TradeBin tradeBin, string symbol, DateTime start)
 {
     return(GetTradeBin(new Dictionary <string, object>
     {
         ["symbol"] = symbol,
         ["interval"] = tradeBin.ToShortLabel(),
         ["startTime"] = Utils.SinceEpochMs(start)
     }));
 }
Пример #4
0
        private string GetTradeBinsAfterLatest(TradeBin tradeBin, string symbol)
        {
            var table  = $"{Name}_{tradeBin.ToLabel()}";
            var query  = $"select top 1 [timestamp] from [{table}] where [symbol] = '{symbol}' order by [timestamp] desc";
            var result = Database.Select(query).Rows;
            var start  = (DateTime)result[0]["timestamp"] + Const.TIME_UNIT;

            return(Rest.GetTradeBin(tradeBin, symbol, start));
        }
Пример #5
0
 public override string GetTradeBin(TradeBin tradeBin, string symbol)
 {
     return(GetTradeBin(new Dictionary <string, object>
     {
         ["binSize"] = tradeBin.ToLabel().Split('n')[1],
         ["partial"] = false,
         ["symbol"] = symbol,
         ["count"] = 500
     }));
 }
Пример #6
0
 public override string GetTradeBin(TradeBin tradeBin, string symbol, DateTime start)
 {
     return(GetTradeBin(new Dictionary <string, object>
     {
         ["binSize"] = tradeBin.ToLabel().Split('n')[1],
         ["partial"] = false,
         ["symbol"] = symbol,
         ["count"] = 500,
         ["startTime"] = start.ToString(Const.DATETIME_FORMAT)
     }));
 }
Пример #7
0
 public ChannelStrategy(Exchange exchange, Symbol symbol = Symbol.XBTUSD, TradeBin tradeBin = TradeBin.FiveMinute) : base(exchange, symbol, tradeBin)
 {
     //
     Measurer = new PriceChangeMeasurer {
         Prices = Prices
     };
     Exchange.Prices[Symbol][TradeBin].Updated += (s, e) => Measurer.Measure();
     //
     Band = new MovingDeviation(Const.BB_PERIOD, Prices);
     Exchange.Prices[Symbol][TradeBin].Updated += (s, e) => Band.Update();
     //
     Timeout = Const.CHANNEL_STRATEGY_TIMEOUT;
 }
Пример #8
0
        public DirectionalStrategy(Exchange exchange, Symbol symbol = Symbol.XBTUSD, TradeBin tradeBin = TradeBin.FiveMinute, int fastEmaLength = Const.DIRECTIONAL_FAST_EMA_LENGTH, int slowEmaLength = Const.DIRECTIONAL_SLOW_EMA_LENGTH, int stochLength = Const.DIRECTIONAL_STOCH_LENGTH) : base(exchange, symbol, tradeBin)
        {
            //
            var prices = Exchange.Prices[Symbol][TradeBin];

            Macd            = new MovingMacd(fastEmaLength, slowEmaLength, prices[Price.Close]);
            prices.Updated += (s, e) => Macd.Update();
            //
            var volatilities = Exchange.IndexPrices[Index.BVOL24H];

            Stoch = new MovingStochastic(stochLength, volatilities[Price.Close]);
            volatilities.Updated += (s, e) => Stoch.Update();
            //
            Measurer = new IndexStochasticMeasurer
            {
                Stoch         = Stoch,
                StochTreshold = StochTreshold
            };
            volatilities.Updated += (s, e) => Measurer.Measure();
            //
            Timeout = Const.DIRECTIONAL_STRATEGY_TIMEOUT;
        }
Пример #9
0
 public TradeBinEventArgs(TradeBin tradeBin, bool emptyPartial)
 {
     TradeBin     = tradeBin;
     EmptyPartial = emptyPartial;
 }
Пример #10
0
 public virtual string GetTradeBin(TradeBin tradeBin, Symbol symbol)
 {
     return(GetTradeBin(tradeBin, symbol.ToString()));
 }
Пример #11
0
 public abstract string GetTradeBin(TradeBin tradeBin, string symbol);
Пример #12
0
 public override string GetTradeBin(TradeBin tradeBin, string symbol, int start, int count = 500)
 {
     throw new NotImplementedException();
 }
Пример #13
0
 public virtual string GetTradeBin(TradeBin tradeBin, Index index, int start, int count = 500)
 {
     return(GetTradeBin(tradeBin, index.ToString(), start, count));
 }
Пример #14
0
 public virtual string GetTradeBin(TradeBin tradeBin, Index index, DateTime start, DateTime end)
 {
     return(GetTradeBin(tradeBin, index.ToString(), start, end));
 }
Пример #15
0
 public virtual string GetTradeBin(TradeBin tradeBin, Index index)
 {
     return(GetTradeBin(tradeBin, index.ToString()));
 }
Пример #16
0
 public virtual string GetTradeBin(TradeBin tradeBin, Symbol symbol, DateTime start, DateTime end)
 {
     return(GetTradeBin(tradeBin, symbol.ToString(), start, end));
 }
Пример #17
0
 public virtual string GetTradeBin(TradeBin tradeBin, Symbol symbol, int start, int count = 500)
 {
     return(GetTradeBin(tradeBin, symbol.ToString(), start, count));
 }
Пример #18
0
 public abstract string GetTradeBin(TradeBin tradeBin, string symbol, int start, int count = 500);
Пример #19
0
 public abstract string GetTradeBin(TradeBin tradeBin, string symbol, DateTime start, DateTime end);