Beispiel #1
0
 def test_get_new_orders(self, input_data, expected):
     trader = Trader(None, None, None)
     self._mox.StubOutWithMock(trader, '_get_type_and_amount_and_price_for_new_order')
     for amount in input_data:
         trader._get_type_and_amount_and_price_for_new_order(amount).AndReturn(('order_type', amount, 'price'))
     self._mox.ReplayAll()
     result = list(trader._get_new_orders(Observable.from_iterable(input_data), 2).to_blocking())
     self.assertEqual(result[-1] if result else None, expected)
     self._mox.VerifyAll()
Beispiel #2
0
 def test_get_new_price(self, order_type, compare_function):
     options = TradingOptions(CurrencyPair(CURRENCY_BTC, CURRENCY_USD), 1, 1, None, None, None)
     trader = Trader(options, None, None)
     price = trader._get_new_price(order_type, 100)
     self.assertTrue(compare_function(price, 100))
Beispiel #3
0
 def test_get_balance(self, input_data, expected):
     trader = Trader(None, None, None)
     result = list(trader._get_balance(Observable.from_iterable(input_data), 'currency').to_blocking())
     self.assertEqual(result[-1] if result else None, expected)
Beispiel #4
0
 def test_get_completed_orders_singly(self, input_data, expected):
     trader = Trader(None, None, None)
     result = list(trader._get_completed_orders_singly(Observable.from_iterable(input_data), 'pair').to_blocking())
     self.assertEqual(result[-1] if result else None, expected)
Beispiel #5
0
from rx.subjects import Subject

from btce import config
from btce.common import get_logger
from btce.exchange import ExchangeConnector
from btce.trader import Trader


logger = get_logger(__name__)


if __name__ == '__main__':
    event_stream = Subject()
    command_stream = Subject()
    connector = ExchangeConnector(event_stream, command_stream)
    connector.init()
    traders = []
    for options in config.TRADING:
        trader = Trader(options, event_stream, command_stream)
        trader.init()
        traders.append(trader)
    try:
        connector.run()
    except:
        for trader in traders:
            trader.deinit()
        connector.deinit()