on bottom left corner, click your Avtar, they you see invite, ...you can select invite by email and assign them member or admin
Thursday, September 24, 2020
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()
Wednesday, September 16, 2020
“inconsistent use of tabs and spaces in indentation”
https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation
It is possible to solve this problem using notepad++ by replacing Tabs with 4 Spaces:
- Choose Search -> Find... or press Ctrl + F
- Select the Replace tab
- In the box named Search Mode choose Extended(\n, \r, \t, \0, \x...)
- In the field Find what : write \t
- In the field Replace with : press Space 4 times. Be sure that there is nothing else in this field.
- Click on the button Replace All
Alpaca data stream
# Be sure to pip install websocket-client
Tuesday, September 15, 2020
python requirements.txt
https://stackoverflow.com/questions/31684375/automatically-create-requirements-txt
Python Websocket Alpaca (code works if you put in the key)
# Be sure to pip install websocket-client
# Details: https://pypi.org/project/websocket-client/
import websocket
import json
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def on_message(ws, message):
with open('data.txt', 'a') as outfile:
json.dump(message, outfile)
print(message)
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")
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()
Monday, September 14, 2020
Python PIP not installed on VS code
This occurs when broken pip. The broken pip caused by the failed upgrade can be fixed by running: "easy_install pip"
https://github.com/DamnWidget/anaconda/issues/762
