public FillsClient(CBAuthenticationContainer authenticationContainer, MyOrderBook orderBook) : base(authenticationContainer) { myActiveOrderBook = orderBook; FillWatchList = orderBook.MyChaseOrderList; IsBusy_TrackIngOrder = false; BusyCheckingOrder = false; //startTracker(); }
public ContextValues(ref MyOrderBook orderBook, ref TickerClient inputTicker) { MyOrderBook = orderBook; CurrentTicker = inputTicker; UserStartedTrading = false; TradeActionList = new List <string>(); //ForceSold = false; BuySellAmount = 0.01m;//default //CurrentLargeSmaTimeInterval = 3; //default //CurrentLargeSmaSlices = 60; //default CurrentAction = "NOT_SET"; //CurrentSmallSmaTimeInterval = 3; //default //CurrentSmallSmaSlices = 55; //default PriceBuffer = 0.05m; //default CurrentRealtimePrice = 0; CurrentBufferedPrice = 0; //CurrentLargeSmaPrice = 0; BuyOrderFilled = false; SellOrderFilled = false; WaitingSellFill = false; WaitingBuyFill = false; WaitingBuyOrSell = false; WaitTimeAfterBigSmaCrossInMin = 5; //buy sell every time interval MaxBuy = 5; MaxSell = 5; StartAutoTrading = false; //AutoTradingStoppedEvent?.Invoke(this, EventArgs.Empty); LastLargeSmaCrossTime = DateTime.UtcNow.ToLocalTime(); //LastSmallSmaCrossTime = DateTime.UtcNow.ToLocalTime(); }
private void InitManager(string ProductName, IntervalValues intervalValues) { //try to get ticker first //Logger.WriteLog("Init Manager Thread ID: " + Thread.CurrentThread.ManagedThreadId.ToString()); try { Logger.WriteLog("Initializing ticker"); ProductTickerClient = new TickerClient(ProductName); } catch (Exception ex) { Logger.WriteLog("Manager cant initialize ticker"); return; } ProductTickerClient.PriceUpdated += ProductTickerClient_UpdateHandler; AvoidExchangeFees = true; ProductTickerClient.TickerConnectedEvent += TickerConnectedHandler; ProductTickerClient.TickerDisconnectedEvent += TickerDisconnectedHandler; MyAuth = new CBAuthenticationContainer(MyKey, MyPassphrase, MySecret); MyProductOrderBook = new MyOrderBook(MyAuth, ProductName, ref ProductTickerClient); MyProductOrderBook.OrderUpdateEvent += FillUpdateEventHandler; CurContextValues = new ContextValues(ref MyProductOrderBook, ref ProductTickerClient); CurContextValues.ProductName = ProductName; CurContextValues.Auth = MyAuth; CurContextValues.AutoTradingStartEvent += autoTradeStartEventHandler; CurContextValues.AutoTradingStopEvent += autoTradeStopEventHandler; ////update ui with initial prices ProductTickerClient_UpdateHandler(this, new TickerMessage(ProductTickerClient.CurrentPrice)); CurrentDisplaySmaTimeInterval = intervalValues.LargeIntervalInMin; CurrentDisplaySmaSlices = intervalValues.LargeSmaSlices; //default large sma slice value //SmaSmall = new MovingAverage(ref ProductTickerClient, ProductName, CurContextValues.CurrentSmallSmaTimeInterval, CurContextValues.CurrentSmallSmaSlices); //SmaSmall.MovingAverageUpdated += SmaSmallChangedEventHandler; Logger.WriteLog(string.Format("{0} manager started", ProductName)); //currentTradeStrategy = new TradeStrategyA(ref CurContextValues); //currentTradeStrategy = new TradeStrategyB(ref CurContextValues); //currentTradeStrategy = new TradeStrategyC(ref CurContextValues); //currentTradeStrategy = new TradeStrategyB(ref CurContextValues); //currentTradeStrategy = new TradeStrategyD(ref CurContextValues); if (intervalValues == null) { intervalValues = new IntervalValues(30, 15, 5);//IntervalValues(5, 3, 1); } //currentTradeStrategy = new TradeStrategyE(ref CurContextValues, intervalValues); CreateUpdateStrategyInstance(intervalValues, true).Wait(); currentTradeStrategy.CurrentActionChangedEvent += CUrrentActionChangeEventHandler; //save the interval values for later use //CurContextValues.CurrentIntervalValues = intervalValues; SetCurrentIntervalValues(intervalValues); DisplaySma = new MovingAverage(ref ProductTickerClient, ProductName, CurrentDisplaySmaTimeInterval, CurrentDisplaySmaSlices); DisplaySma.MovingAverageUpdatedEvent += DisplaySmaChangedEventHandler; UpdateDisplaySmaParameters(CurrentDisplaySmaTimeInterval, CurrentDisplaySmaSlices); UpdateBuySellAmount(0.01m); //default //UpdateBuySellBuffer(0.03m); //default try { UpdateFunds(); } catch (Exception) { Logger.WriteLog("Error getting available funds details, please check your gdax credentials"); } AppSettings.MajorSettingsChangEvent += MajorSettingsChangedEventHandler; //writeCurrentStrategySmaValues(); //ShowGraph(gra); }