Friday, January 8, 2021

trade idea alert config for 3 green bars

 After 3 green bars, if you have 4th, then green bar usually last till 6 or 7 or even 9, then it will drop 3 bars, then either continue up or down, when down 3 bars, it is time to buy, and sell in 3 bars, you you have two waves up then it usually up or consolidate...

basically in afternoon, usually 2 waves up, then down, but in the morning when market open, it can have 5 waves up then down.





Wednesday, October 21, 2020

Tuesday, October 20, 2020

unix timestamp to C#

 public static DateTime UnixTimeStampToDateTime( double unixTimeStamp )

{
    // Unix timestamp is seconds past epoch
    System.DateTime dtDateTime = new DateTime(1970,1,1,0,0,0,0,System.DateTimeKind.Utc);
    dtDateTime = dtDateTime.AddSeconds( unixTimeStamp ).ToLocalTime();
    return dtDateTime;
}

Monday, October 19, 2020

Delete project from visual studio online

 https://docs.microsoft.com/en-us/azure/devops/organizations/projects/delete-project?view=azure-devops&tabs=browser

jason to C# class


 https://stackoverflow.com/questions/2246694/how-to-convert-json-object-to-custom-c-sharp-object

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Newtonsoft.Json;

using Newtonsoft.Json.Linq;


namespace JasonTest

{

    class Program

    {

        static void Main(string[] args)

        {

            String dataIn = "{\"ev\":\"A\",\"sym\":\"AAPL\",\"v\":1267,\"av\":53480851,\"op\":119.96,\"vw\":118.8477,\"o\":118.8536,\"c\":118.84,\"h\":118.855,\"l\":118.84,\"a\":119.2689,\"z\":70,\"n\":1,\"s\":1603125023000,\"e\":1603125024000}";

            //var inCovJ = JsonConvert.DeserializeObject(dataIn);

            StockIn inCovJ = JsonConvert.DeserializeObject<StockIn>(dataIn);

            

            Console.WriteLine(inCovJ);

            Console.WriteLine();

        }

    }

}



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace JasonTest

{

    public class StockIn

    {

        public string ev { get; set; }

        public string sym { get; set; }

        public int v { get; set; }

        public int av { get; set; }

        public double op { get; set; }

        public double vw { get; set; }

        public double o { get; set; }

        public double c { get; set; }

        public double h { get; set; }

        public double l { get; set; }

        public double a { get; set; }

        public int z { get; set; }

        public long s { get; set; }

        public long e { get; set; }

    }

}


Thursday, September 24, 2020

Clickup app invite people

 on bottom left corner, click your Avtar, they you see invite, ...you can select invite by email and assign them member or admin

Friday, September 18, 2020

mplfinance and Alpaca charting working copy

#D:\test\p4\t4.py

import websocket

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

from pyxtension.Json import Json

import numpy as np  

from datetime import datetime

import mplfinance as mpf

from matplotlib import style



def on_message(ws, message):

    #message = message.replace('[','').replace(']','')

    x = message.replace('[','').replace(']','')

    if x.find("sym") > 0:

        x = x.replace('[','').replace(']','')

        print (x)

        y = Json(x)

        #print(y.sym)

        open  = y.o

        print("open: ", open)

        close = y.c

        high = y.h

        low = y.l

        vw = y.vw

        volume = y.v

        timestamp = str(y.s)

        timestamp = timestamp[0:10]

        timestampEnd = str(y.e)

        timestampEnd = timestampEnd[0:10]

        dateBeg =  datetime.fromtimestamp(int(timestamp))

        dateEnd =  datetime.fromtimestamp(int(timestampEnd))

        global dfObj

        dfObj = dfObj.append({'Open':open, 'High':high, 'Low':low, 'Close':close, 'Volume':volume,'VW':vw,'DateBeg': dateBeg, 'Date': dateEnd }, ignore_index=True)

           

        print("close:",dfObj.Close)

        trows = len(dfObj.index)

        noRows = 9

        print("cnt:", trows)

        if trows > noRows:

            print (dfObj)

            dfObj = dfObj.set_index(pd.DatetimeIndex(dfObj['Date']))

            ax1.clear()

            ax2.clear()

            mpf.plot(dfObj,type='candle', ax=ax1,volume=ax2, block=False, mav=(9,21,50,200))

            plt.pause(3)

            print("passed fig ****************ROW > NO *******************************")

        elif trows == noRows:

            dfObj = dfObj.set_index(pd.DatetimeIndex(dfObj['Date']))

            print(dfObj)

            mpf.plot(dfObj,type='candle', ax=ax1,volume=ax2, block=False, mav=(9,21,50,200))

            plt.pause(3)

            print("passed fig ************** ROW = NO *********************************")


def on_error(ws, error):

    print(error)


def on_close(ws):

    print("### closed ###")

    #f.close


def on_open(ws):

    ws.send('{"action":"auth","params":"XXXX"}')

    ws.send('{"action":"subscribe","params":"A.AAPL"}')

    


#f = open("demofile.txt", "a")


#Set up plot

#fig = mpf.figure(figsize=(10,9))

fig = mpf.figure()

ax1 = fig.add_subplot(2,1,1,style='yahoo')

ax1 = fig.add_subplot(2,1,1)

ax2 = fig.add_subplot(3,1,3)


#ax1 = fig.add_subplot(1, 1, 1)

#fig, ax = plt.subplots()

#lines, = ax.plot([],[], 'o')

#Autoscale on unknown axis and known lims on the other

ax1.set_autoscaley_on(True)

#ax.set_xlim(self.min_x, self.max_x)

##Other stuff

ax1.grid()

#lt.tight_layout()

dfObj = pd.DataFrame(columns=['Open', 'High', 'Low','Close', 'Volume', 'VW', 'DateBeg', 'Date'])

#print("Empty Dataframe ", dfObj, sep='\n')

dfObj = dfObj.set_index(pd.DatetimeIndex(dfObj['Date']))


if __name__ == "__main__":

    # websocket.enableTrace(True)

    

    ws = websocket.WebSocketApp("wss://socket.polygon.io/stocks",

                              on_message = on_message,

                              on_error = on_error,

                              on_close = on_close)

    ws.on_open = on_open


    ws.run_forever()