Пример #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
Пример #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
Пример #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
Пример #4
0
def test_get_calendar():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_calendar()
    assert result["calendar"] != None
Пример #5
0
def test_get_clock():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_clock()
    assert result["clock"] != None
Пример #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
Пример #7
0
def test_get_timesales():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_timesales(symbol="AAPL", interval="15min")
    assert result["series"] != None
Пример #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
Пример #9
0
def test_get_options_expirations():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_options_expirations(symbol="VXX")
    assert result["expirations"] != None
Пример #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
Пример #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
Пример #12
0
def test_get_quotes():
    t = Tradier(access_token=ACCESS_TOKEN)
    result = t.get_quotes(symbols="AAPL")
    assert result["quotes"] != None
Пример #13
0
def test_fake_access_token():
    t = Tradier(access_token="Not a real access token")
    with pytest.raises(AssertionError):
        t.get_lookup("goog")
Пример #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_())