public MyOrderBook(CBAuthenticationContainer authContainer, string product, ref TickerClient inputTickerClient) : base(authContainer) { isUpdatingOrderList = false; isBusyCancelAndReorder = false; BusyWithWithCancelReorder = false; OrderRetriedCount = 0; OrderStartingPrice = 0; AvoidExFees = true; //avoid fees by default ProductName = product; _auth = authContainer; orderList = new OrderList(_auth); MyChaseOrderList = new List <MyOrder>(); lastTickTIme = DateTime.UtcNow; PriceTicker = inputTickerClient; //new TickerClient(product); //no need to create two different ticker, use one global ticker PriceTicker.PriceUpdated += PriceUpdateEventHandler; PriceTicker.TickerConnectedEvent += TickerConnectedEventHandler; PriceTicker.TickerDisconnectedEvent += TickerDisconnectedEventHandler; fillsClient = new FillsClient(_auth, this); fillsClient.FillUpdated += OrderFilledEventHandler; }
public FillsClient(CBAuthenticationContainer authenticationContainer, MyOrderBook orderBook) : base(authenticationContainer) { myActiveOrderBook = orderBook; FillWatchList = orderBook.MyChaseOrderList; IsBusy_TrackIngOrder = false; BusyCheckingOrder = false; //startTracker(); }
public RealtimePriceClient(string ProductString, CBAuthenticationContainer auth = null) : this(ProductString : ProductString, auth : auth, realtimeOrderBookSubscription : new RealtimeOrderBookSubscription(new string[] { ProductString }, auth, GDAX_Channel.matches)) { robsCreatedLocally = true; // subscribe if robsCreatedLocally this.RealtimeOrderBookSubscription.SubscribeAsync( // don't await bc it won't complete until subscription ends reConnectOnDisconnect: true); }
public RealtimePriceClient(string ProductString, RealtimeOrderBookSubscription realtimeOrderBookSubscription, CBAuthenticationContainer auth = null) { this.ProductString = ProductString; this.RealtimeOrderBookSubscription = realtimeOrderBookSubscription; this.RealtimeOrderBookSubscription.RealtimeMatch += OnMatch; // should already be subscribed since robs is passed in }
private CBAuthenticationContainer GetAuthenticationContainer() { var authenticationContainer = new CBAuthenticationContainer( "", // API Key "", // Passphrase "" // Secret ); return(authenticationContainer); }
public RealtimeOrderBookClient(CBAuthenticationContainer auth) : base(auth) { _sells = new List <BidAskOrder>(); _buys = new List <BidAskOrder>(); Sells = new List <BidAskOrder>(); Buys = new List <BidAskOrder>(); ResetStateWithFullOrderBook(); }
private CBAuthenticationContainer GetAuthenticationContainer() { var passphrase = Configuration.Ask(Configuration.Passphrase, "What is the passphrase?"); var apikey = Configuration.Ask(Configuration.Apikey, "What is the API key?"); var secret = Configuration.Ask(Configuration.Secret, "What is the secret?"); var authenticationContainer = new CBAuthenticationContainer(apiKey: apikey, passphrase: passphrase, secret: secret); return(authenticationContainer); }
public Funds(CBAuthenticationContainer auth, string productName) : base(auth) { if (productName.Contains("-")) { ProductName = productName.Split('-').First(); } else { ProductName = productName; } }
public RealtimeOrderBookSubscription(string[] Products, CBAuthenticationContainer auth = null, GDAX_Channel gdax_Channel = GDAX_Channel.full) : base(auth) { // + eventually can take an array of productStrings and subscribe simultaneously this.Products = Products; if (Products == null || Products.Length == 0) { throw new ArgumentNullException("Products"); } this.gdax_Channel = gdax_Channel; ConnectionOpened += (product, channel) => subscribedProducts.Add(product, channel); ConnectionClosed += (product, channel) => subscribedProducts.Remove(product); }
public RealtimeOrderBookClient(string ProductString, CBAuthenticationContainer auth = null) { this.ProductString = ProductString; this.productOrderBookClient = new ProductOrderBookClient(auth); Sells = new ObservableSortedDictionary <decimal, ObservableLinkedList <BidAskOrder> >(new DescendingComparer <decimal>()); Buys = new ObservableSortedDictionary <decimal, ObservableLinkedList <BidAskOrder> >(new DescendingComparer <decimal>()); this.RealtimeOrderBookSubscription = new RealtimeOrderBookSubscription(ProductString, auth); this.RealtimeOrderBookSubscription.RealtimeOpen += OnOpen; this.RealtimeOrderBookSubscription.RealtimeDone += OnDone; this.RealtimeOrderBookSubscription.RealtimeMatch += OnMatch; this.RealtimeOrderBookSubscription.RealtimeChange += OnChange; //await ResetStateWithFullOrderBook(); }
public RealtimeOrderBookClient(string ProductString, RealtimeOrderBookSubscription realtimeOrderBookSubscription, CBAuthenticationContainer auth = null) { this.ProductString = ProductString; this.productOrderBookClient = new ProductOrderBookClient(auth); Sells = new ConcurrentObservableSortedDictionary <decimal, ObservableLinkedList <BidAskOrder> >(isMultithreaded: true, comparer: new DescendingComparer <decimal>()); Buys = new ConcurrentObservableSortedDictionary <decimal, ObservableLinkedList <BidAskOrder> >(isMultithreaded: true, comparer: new DescendingComparer <decimal>()); this.RealtimeOrderBookSubscription = realtimeOrderBookSubscription; this.RealtimeOrderBookSubscription.RealtimeOpen += OnOpen; this.RealtimeOrderBookSubscription.RealtimeDone += OnDone; this.RealtimeOrderBookSubscription.RealtimeMatch += OnMatch; this.RealtimeOrderBookSubscription.RealtimeChange += OnChange; // not really used for anything except for their sequence number this.RealtimeOrderBookSubscription.RealtimeReceived += OnReceived; this.RealtimeOrderBookSubscription.RealtimeLastMatch += OnLastMatch; this.RealtimeOrderBookSubscription.Heartbeat += OnHeartbeat; this.RealtimeOrderBookSubscription.ConnectionClosed += OnConnectionClosed; }
static void Main(string[] args) { /* * * passphrase: * kb4ou7pbmkk * * key: * c8420d4178367af6929335a08da8ca90 * * secret: * zUF25y0GTGgpdR1LI2J4Pu6rjwQ/4RgqJVK03mR+T38ik+JyDwl1T3hI2p4GiED6Lm4KOUAgHnxl3+53ihRC4Q== */ var myPassphrase = ""; var myKey = ""; var mySecret = ""; CBAuthenticationContainer myAuth = new CBAuthenticationContainer(myKey, myPassphrase, mySecret); RealtimeOrderBookClient rtClient = new RealtimeOrderBookClient(myAuth); rtClient.Updated += RtClient_Updated; //var book = rtClient.GetProductOrderBook("BTC-USD"); //var res = rtClient.Buys; //Task.WaitAny(); //System.Threading.Thread.Sleep(5000); while (true) { System.Threading.Thread.Sleep(60000); Console.WriteLine("Thread Sleeping..."); } }
public PersonalOrdersClient(CBAuthenticationContainer authenticationContainer) : base(authenticationContainer) { }
public FillsClient(CBAuthenticationContainer authenticationContainer) : base(authenticationContainer) { }
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); }
public OrderList(CBAuthenticationContainer authContainer) : base(authContainer) { }
//public string customOrderId { get; set; } // client_oid //public string size { get; set; } //public string price { get; set; } //public string side { get; set; } //public string productName { get; set; } //public string orderType { get; set; } //public string selfTradeFlag { get; set; } public OrderPlacer(CBAuthenticationContainer authContainer) : base(authContainer) { }
public ProductOrderBookClient(CBAuthenticationContainer authenticationContainer) : base(authenticationContainer) { }
public RealtimeOrderBookSubscription(string ProductString, CBAuthenticationContainer auth = null) : base(auth) { // + eventually can take an array of productStrings and subscribe simultaneously this.ProductString = ProductString; }
public AccountClient(CBAuthenticationContainer authContainer) : base(authContainer) { }
public RealtimeOrderBookClient(string ProductString, CBAuthenticationContainer auth = null) : this(ProductString : ProductString, auth : auth, realtimeOrderBookSubscription : new RealtimeOrderBookSubscription(new string[] { ProductString }, auth)) { robsCreatedLocally = true; }