Esempio n. 1
0
def test_get_lookup():
    expected = {
        "securities": {
            "security": {
                "symbol": "GOOGL",
                "exchange": "Q",
                "type": "stock",
                "description": "Alphabet Inc",
            }
        }
    }

    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_lookup("googl")
    assert result == expected
Esempio n. 2
0
def test_get_history():
    expected = {
        "history": {
            "day": {
                "date": "2019-05-06",
                "open": 1166.26,
                "high": 1190.85,
                "low": 1166.26,
                "close": 1189.39,
                "volume": 1563943,
            }
        }
    }
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_history(
        symbol="goog", interval="daily", start="2019-05-04", end="2019-05-06"
    )
    assert result == expected
Esempio n. 3
0
def test_get_search():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_search(q="alphabet")
    assert result["securities"] != None
    assert len(result["securities"]["security"]) > 0
Esempio n. 4
0
def test_get_calendar():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_calendar()
    assert result["calendar"] != None
Esempio n. 5
0
def test_get_clock():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_clock()
    assert result["clock"] != None
Esempio n. 6
0
def test_get_etb():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_etb()
    assert result["securities"] != None
    assert len(result["securities"]["security"]) > 0
Esempio n. 7
0
def test_get_timesales():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_timesales(symbol="AAPL", interval="15min")
    assert result["series"] != None
Esempio n. 8
0
def test_get_lookup_options_symbols():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_lookup_options_symbols(underlying="SPY")
    assert result["symbols"] != None
    assert len(result["symbols"][0]["options"]) > 0
Esempio n. 9
0
def test_get_options_expirations():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_options_expirations(symbol="VXX")
    assert result["expirations"] != None
Esempio n. 10
0
def test_get_options_strikes():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_options_strikes(symbol="VXX", expiration=str(FRIDAY))
    assert result["strikes"] != None
Esempio n. 11
0
def test_get_options_chains():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_options_chains(symbol="VXX", expiration=str(FRIDAY), greeks="true")
    assert result["options"] != None
Esempio n. 12
0
def test_get_quotes():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_quotes(symbols="AAPL")
    assert result["quotes"] != None
Esempio n. 13
0
def test_fake_access_token():
    t = Tradier(access_token="Not a real access token")
    with pytest.raises(AssertionError):
        t.get_lookup("goog")
Esempio n. 14
0
import sys

from PyQt5.QtCore import QObject
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQml import QQmlApplicationEngine

from tradier import Tradier

app = QApplication(sys.argv)
engine = QQmlApplicationEngine()
ctx = engine.rootContext()
ctx.setContextProperty('main', engine)
engine.load('ui\main.qml')
win = engine.rootObjects()[0]
win.show()

t_handle = Tradier()

def set_recent_value():
	symbol = symbol_field.property('text')
	recent_value = t_handle.get_moving_average(symbol, 60)
	recent_value_field.setProperty('text', '60-day moving average: {}'.format(recent_value))


lookup_button = win.findChild(QObject, "lookupButton")
symbol_field = win.findChild(QObject, "symbolField")
recent_value_field = win.findChild(QObject, "recentValue")
lookup_button.clicked.connect(set_recent_value)

sys.exit(app.exec_())