def __init__(self, client, instrument):
     self._client = client
     self._instrument = instrument
     self._data = collections.deque(maxlen = self._DATA_LEN)
     self._held_trade = None
     cur_data = client.get_historical_prices(self._instrument,
                                             datetime.datetime.now() - datetime.timedelta(minutes=self._DATA_LEN + 1),
                                             datetime.datetime.now())
     self._data.extend([c.close for c in cur_data[::-1]])
     short_mavg = talib.SMA(np.array(self._data), timeperiod = 5)
     long_mavg = talib.SMA(np.array(self._data), timeperiod = 25)
     short_mavg[np.isnan(short_mavg)] = short_mavg[np.isfinite(short_mavg)][0]
     long_mavg[np.isnan(long_mavg)] = long_mavg[np.isfinite(long_mavg)][0]
     rc.add_data("close", self._data)
     rc.add_data("short_mavg", short_mavg)
     rc.add_data("long_mavg", long_mavg)
     rc.init()
Ejemplo n.º 2
0
"""
An example plotting time series currency.
"""
import sys
import time
import forexconnect
import lib.login_manager as lm
import lib.realtime_chart as rc

if len(sys.argv) < 2:
    print "Usage: python tick_animation.py instrument(etc. 'EUR/USD')"
    sys.exit()

instrument = sys.argv[1]
username, password, connection = lm.get_login_params()
try:
    client = forexconnect.ForexConnectClient(username,
                                             password,
                                             connection)
except:
    lm.clear_cache()
    sys.exit()
rc.add_data(instrument, [client.get_ask(instrument)] * 100)
rc.init("Real time chart")
while True:
    rc.update_data({instrument: client.get_ask(instrument)})
    time.sleep(1)
Ejemplo n.º 3
0
"""
An example plotting time series currency.
"""
import sys
import time
import forexconnect
import lib.login_manager as lm
import lib.realtime_chart as rc

if len(sys.argv) < 2:
    print("Usage: python tick_animation.py instrument(etc. 'EUR/USD')")
    sys.exit()

instrument = sys.argv[1]
username, password, connection = lm.get_login_params()
try:
    client = forexconnect.ForexConnectClient(username, password, connection)
except:
    lm.clear_cache()
    sys.exit()
rc.add_data(instrument, [client.get_ask(instrument)] * 100)
rc.init("Real time chart")
while True:
    rc.update_data({instrument: client.get_ask(instrument)})
    time.sleep(1)