Thursday, July 22, 2021

Alpaca streaming

https://forum.alpaca.markets/t/data-streaming-api-issues-with-c-sdk-v-3-8-0-beta2/2270



 _dataStreamingClient = Alpaca.Markets.Environments.Paper.GetAlpacaDataStreamingClient(securityKey);

		//_dataStreamingClient = Alpaca.Markets.Environments.Live.GetAlpacaDataStreamingClient(oAuthKey);

        Console.WriteLine($"Hooking to OnError event ...");
        _dataStreamingClient.OnError += (Exception ex) =>
        {
            Console.WriteLine($"OnError event => Exception: {ex}");
        };

        Console.WriteLine($"Hooking to Connected event ...");
        _dataStreamingClient.Connected += (AuthStatus authStatus) =>
        {
            Console.WriteLine($"Connected event => AuthStatus: {authStatus}");
        };

        Console.WriteLine($"Hooking to SocketClosed event ...");
        _dataStreamingClient.SocketClosed += () =>
        {
            Console.WriteLine("SocketClosed event => Socket closed.");
        };

        Console.WriteLine($"Hooking to SocketOpened event ...");
        _dataStreamingClient.SocketOpened += () =>
        {
            Console.WriteLine("SocketOpened event => Socket opened.");
        };

        await _dataStreamingClient.ConnectAndAuthenticateAsync();

        if (!string.IsNullOrWhiteSpace(symbol))
        {
            var tradeSubscription = _dataStreamingClient.GetTradeSubscription(symbol);

            Console.WriteLine($"Hooking to trade subscription for symbol {symbol} event ...");
            tradeSubscription.Received += (IStreamTrade trade) =>
            {
                Console.WriteLine($"Trade Streaming: {trade.Symbol}, Exchange: {trade.Exchange}, Price: {trade.Price}, Size: {trade.Size}, TimeUtc: {trade.TimeUtc}, TradeId: {trade.TradeId}, Current Time: {DateTime.UtcNow}");
            };

            Console.WriteLine($"Subscribing to trade for symbol {symbol} ...");
            _dataStreamingClient.Subscribe(tradeSubscription);

            //Quote
            var quoteSubscription = _dataStreamingClient.GetQuoteSubscription(symbol);

            Console.WriteLine($"Hooking to quote subscription for symbol {symbol} event ...");
            quoteSubscription.Received += (IStreamQuote quote) =>
            {
                Console.WriteLine($"Quote Streaming: {quote.Symbol}, Exchange: {quote.AskExchange}, AskPrice: {quote.AskPrice}, AskSize: {quote.AskSize}, BidExchange: {quote.BidExchange}, BidPrice: {quote.BidPrice}, BidSize: {quote.BidSize}, TimeUtc: {quote.TimeUtc}, Current Time: {DateTime.UtcNow}");
            };

            Console.WriteLine($"Subscribing to quotes for symbol {symbol} ...");
            _dataStreamingClient.Subscribe(quoteSubscription);

            //Minute aggregated data for symbol
            var minAggrSubscription = _dataStreamingClient.GetMinuteAggSubscription(symbol);

            Console.WriteLine($"Hooking to minute aggregated data subscription for symbol {symbol} event ...");
            minAggrSubscription.Received += (IStreamAgg agg) =>
            {
                Console.WriteLine($"Minute Aggregation Streaming: {agg.Symbol}, Open: {agg.Open}, High: {agg.High}, Low: {agg.Low}, Close: {agg.Close}, Average: {agg.Average}, StartTimeUtc: {agg.StartTimeUtc}, EndTimeUtc: {agg.EndTimeUtc}, Volume: {agg.Volume}, Current Time: {DateTime.UtcNow}");
            };

            Console.WriteLine($"Subscribing to minute aggregated data for symbol {symbol} ...");
            _dataStreamingClient.Subscribe(minAggrSubscription);
        }

        int waitTime = 60000;
        Console.WriteLine($"Keeping the data streaming alive for {((float)waitTime) / 60000} minutes ...");
        await Task.Delay(waitTime);
        Console.WriteLine($"Exiting data streaming after {((float)waitTime) / 60000} minutes ...");
  • created

Thursday, June 17, 2021

fastest transfer money without Zelle using paypal

Set up two Paypal accounts

a@x.com and b@y.com

link a@x.com to one bank that has fund

link b@y.com to bank receiving fund

Send money from a@x.com (send ex.$1000) to b@y.com, then it will immediate receive, then withdraw money from b@y.com will end in bank account the next day. Fastest transfer money when no Zelle available

Note: if you send $5000 it will be put on hold for 5 days. I tried 1000, and send immediately

Friday, January 15, 2021

UVXY is an interesting ETF to work with the market up or down

 UVXY, you can buy when stock market is hot(it goes lower), and sell it when market sell off(goes higher), this happened today. Somehow I targeted right, I set at $11.21, and high was $11.27, too many brokerage accounts, Fidelity set at $11.21, Merrill does not allow to trade UVXY, Webull still have 29 shares not sold on time (sold 300).




     TD thinkorswim


Schwab