GithubHelp home page GithubHelp logo

garethdmm / gryphon Goto Github PK

View Code? Open in Web Editor NEW
1.0K 1.0K 151.0 1.77 MB

Powerful, proven, and extensible framework for building trading strategies at any frequency, with a focus on crypto currencies. Battle-tested with billions traded.

Home Page: http://www.gryphonframework.org

License: Other

Python 86.11% Mako 0.07% CSS 0.08% JavaScript 9.92% HTML 3.61% Shell 0.21%

gryphon's People

Contributors

asmodehn avatar bmoscon avatar garethdmm avatar itali43 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gryphon's Issues

ImportError: cannot import name ESDIRK

Hello,
I have installed gryphon and running gryphon-runtests says that all test successfully passed. I can run import gryphon but if I want to import ESDIRK I get the following error

>>> from gryphon import ESDIRK
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name ESDIRK

Bitstamp : subaccount API invalid signature

(gryphon2)alexv@pop-os:/opt/Projects/gryphon-strategies$ gryphon-exec script reset_balance --exchange_name bitstamp_btc_eur
{u'status': u'error', u'reason': u'Invalid signature', u'code': u'API0005'}
Traceback (most recent call last):
  File "/home/alexv/.virtualenvs/gryphon2/bin/gryphon-exec", line 11, in <module>
    load_entry_point('gryphon', 'console_scripts', 'gryphon-exec')()
  File "/opt/Projects/gryphon/gryphon/execution/app.py", line 544, in main
    app.run()
  File "/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/cement/core/foundation.py", line 882, in run
    return_val = self.controller._dispatch()
  File "/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/cement/core/controller.py", line 471, in _dispatch
    return func()
  File "/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/cement/core/controller.py", line 477, in _dispatch
    return func()
  File "/opt/Projects/gryphon/gryphon/execution/app.py", line 437, in default
    main_function(script_arguments=script_arguments, execute=execute)
  File "/opt/Projects/gryphon/gryphon/execution/scripts/reset_balance.py", line 159, in main
    fix_balance_issues_for_exchange(exchange_name, execute)
  File "/opt/Projects/gryphon/gryphon/execution/scripts/reset_balance.py", line 137, in fix_balance_issues_for_exchange
    exchange_balance = exchange.get_balance()
  File "exchange_api_wrapper.pyx", line 203, in gryphon.lib.exchange.exchange_api_wrapper.ExchangeAPIWrapper.get_balance (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/lib/exchange/exchange_api_wrapper.c:5374)
  File "/opt/Projects/gryphon/gryphon/lib/exchange/bitstamp_btc_usd.py", line 232, in get_balance_resp
    'Balance missing expected keys',
gryphon.lib.exchange.exceptions.ExchangeAPIErrorException: [BITSTAMP_BTC_EUR] Balance missing expected keys

Anyone else having the same issue ? It used to work for main account... Any hint ?

Running [strat_name].py leads to .config file not being found. Original fix did not resolve this

I believe the fix left this part aside :
https://github.com/garethdmm/gryphon/blob/master/gryphon/execution/lib/config_helper.py#L96
Which means the configuration file should be named with "strat_name.py.conf" currently, and that is probably not intended

How do we want to handle this? If we're not planning more changes in the original strategy parser, we could simply add a few more if statements.

Originally posted by @asmodehn in #30 (comment)

DB Unicode error: SAWarning: Unicode type received non-unicode bind param value 'SIMPLEMARKETMAKING'.

Hello,

Thanks for the app - looks really interesting.

I've just installed it and attempted to run the simple_market_making strategy.

I'm getting this error - full trace below.

SAWarning: Unicode type received non-unicode bind param value 'SIMPLEMARKETMAKING'.

Do I need to setup the MYSQL DB with a specific encoding?

---- Full Trace ----

(venv) zen:gryphon matt$ gryphon-exec strategy simple_market_making --builtin --exchange BITSTAMP_BTC_USD
INFO: Running strategy simple_market_making with configuration={'platform': {'audit': None, 'execute': False, 'config_file': None, 'sentry': None, 'strategy': 'simple_market_making', 'builtin': True, 'emerald': None, 'heartbeat': None}, 'strategy': {'tick_sleep': None, 'exchange': 'BITSTAMP_BTC_USD'}, 'exchanges': {}}
INFO:cement:app:gryphon-fury:Running strategy simple_market_making with configuration={'platform': {'audit': None, 'execute': False, 'config_file': None, 'sentry': None, 'strategy': 'simple_market_making', 'builtin': True, 'emerald': None, 'heartbeat': None}, 'strategy': {'tick_sleep': None, 'exchange': 'BITSTAMP_BTC_USD'}, 'exchanges': {}}
INFO:gryphon.execution.live_runner:live_run(simple_market_making, False)
INFO:gryphon.execution.harness.harness:[HARNESS_SETUP] (25/06/19 13:28:41 UTC) The following exchanges will be tradable: []

SimpleMarketMaking
/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py:273: SAWarning: Unicode type received non-unicode bind param value 'SIMPLEMARKETMAKING'. (this warning may be suppressed after 10 occurrences)
(util.ellipses_string(value),),
INFO:gryphon.execution.harness.harness:[SimpleMarketMaking] (25/06/19 13:28:41 UTC) Open position: BTC 0.00000000
INFO:gryphon.execution.harness.harness:[SimpleMarketMaking] (25/06/19 13:28:41 UTC) Available balances:
INFO:gryphon.execution.harness.harness:[SimpleMarketMaking] (25/06/19 13:28:41 UTC) Open Orders:
ERROR:gryphon.execution.live_runner:[TypeError] string indices must be integers
Traceback (most recent call last):
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/execution/live_runner.py", line 281, in live_run
harness.tick()
File "harness.pyx", line 161, in gryphon.execution.harness.harness.Harness.tick (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3195)
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/lib/util/profile.py", line 59, in inner
t, result = timeit.timeit(run_func, number=1)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/timeit.py", line 237, in timeit
return Timer(stmt, setup, timer).timeit(number)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/timeit.py", line 202, in timeit
timing = self.inner(it, self.timer)
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/lib/util/monkeypatch_timeit.py", line 14, in inner
retval = _func()
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/lib/util/profile.py", line 57, in run_func
return func(*args, **kwargs)
File "harness.pyx", line 169, in gryphon.execution.harness.harness.Harness.tick_algo (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3394)
File "simple_market_making.pyx", line 41, in gryphon.execution.strategies.builtin.simple_market_making.SimpleMarketMaking.tick (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/execution/strategies/builtin/simple_market_making.c:1530)
File "exchange_coordinator.pyx", line 378, in gryphon.execution.harness.exchange_coordinator.ExchangeCoordinator.cancel_all_open_orders (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/execution/harness/exchange_coordinator.c:6923)
File "exchange_api_wrapper.pyx", line 164, in gryphon.lib.exchange.exchange_api_wrapper.ExchangeAPIWrapper.cancel_all_open_orders (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/lib/exchange/exchange_api_wrapper.c:4500)
File "exchange_api_wrapper.pyx", line 138, in gryphon.lib.exchange.exchange_api_wrapper.ExchangeAPIWrapper.get_open_orders (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/lib/exchange/exchange_api_wrapper.c:3902)
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/lib/exchange/bitstamp_btc_usd.py", line 307, in get_open_orders_resp
if raw_order['type'] == '0':
TypeError: string indices must be integers
INFO:gryphon.execution.live_runner:handle_exception succeeded, full speed ahead

SimpleMarketMaking
INFO:gryphon.execution.harness.harness:[SimpleMarketMaking] (25/06/19 13:28:47 UTC) Open position: BTC 0.00000000
INFO:gryphon.execution.harness.harness:[SimpleMarketMaking] (25/06/19 13:28:47 UTC) Available balances:
INFO:gryphon.execution.harness.harness:[SimpleMarketMaking] (25/06/19 13:28:47 UTC) Open Orders:
ERROR:gryphon.execution.live_runner:[TypeError] string indices must be integers
Traceback (most recent call last):
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/execution/live_runner.py", line 281, in live_run
harness.tick()
File "harness.pyx", line 161, in gryphon.execution.harness.harness.Harness.tick (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3195)
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/lib/util/profile.py", line 59, in inner
t, result = timeit.timeit(run_func, number=1)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/timeit.py", line 237, in timeit
return Timer(stmt, setup, timer).timeit(number)
File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/timeit.py", line 202, in timeit
timing = self.inner(it, self.timer)
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/lib/util/monkeypatch_timeit.py", line 14, in inner
retval = _func()
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/lib/util/profile.py", line 57, in run_func
return func(*args, **kwargs)
File "harness.pyx", line 169, in gryphon.execution.harness.harness.Harness.tick_algo (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3394)
File "simple_market_making.pyx", line 41, in gryphon.execution.strategies.builtin.simple_market_making.SimpleMarketMaking.tick (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/execution/strategies/builtin/simple_market_making.c:1530)
File "exchange_coordinator.pyx", line 378, in gryphon.execution.harness.exchange_coordinator.ExchangeCoordinator.cancel_all_open_orders (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/execution/harness/exchange_coordinator.c:6923)
File "exchange_api_wrapper.pyx", line 164, in gryphon.lib.exchange.exchange_api_wrapper.ExchangeAPIWrapper.cancel_all_open_orders (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/lib/exchange/exchange_api_wrapper.c:4500)
File "exchange_api_wrapper.pyx", line 138, in gryphon.lib.exchange.exchange_api_wrapper.ExchangeAPIWrapper.get_open_orders (/Users/matt/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/lib/exchange/exchange_api_wrapper.c:3902)
File "/Users/matt/projects/internetschminternet/gryphon/venv/lib/python2.7/site-packages/gryphon/lib/exchange/bitstamp_btc_usd.py", line 307, in get_open_orders_resp
if raw_order['type'] == '0':
TypeError: string indices must be integers
INFO:gryphon.execution.live_runner:handle_exception succeeded, full speed ahead
^CINFO:gryphon.execution.live_runner:Setting Warm Shutdown Flag

SimpleMarketMaking
INFO:gryphon.execution.live_runner:Initiating Warm Shutdown
INFO:gryphon.execution.live_runner:Warm Shutdown Complete
(venv) zen:gryphon matt$

There is no entry with the name 'BURN' in your exchange account

After Initializing my ledgers (for kraken and bitstamp), running the dashboard, and then visiting the fees and assets pages, I get :

INFO:root:200 GET /fees (127.0.0.1) 13.96ms - FAST
/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py:242: SAWarning: Unicode type received non-unicode bind param value 'DEPOSIT'. (this warning may be suppressed after 10 occurrences)
  (util.ellipses_string(value),))
/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py:242: SAWarning: Unicode type received non-unicode bind param value 'WITHDRAWL'. (this warning may be suppressed after 10 occurrences)
  (util.ellipses_string(value),))
/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py:242: SAWarning: Unicode type received non-unicode bind param value 'BURN'. (this warning may be suppressed after 10 occurrences)
  (util.ellipses_string(value),))
INFO:gryphon.lib.assets:There is no entry with the name 'BURN' in your exchange account table, so we won'tbe able to show non-trading expenses in the dashboard service. You can learn how toset this feature up in the framework documentation.
INFO:root:200 GET /assets (127.0.0.1) 596.35ms - SLOW
  1. There should probably be a link to the correct section in the documentation ? I m guessing it might be the ledger initialization part, but I might be wrong ?

  2. How can I check if it is a problem in code or in DB setup ?

CurrencyMismatch: unsupported operation between money in 'EUR' and 'USD': '<'.

I am running this strategy :

from gryphon.execution.strategies.base import Strategy
from gryphon.lib import arbitrage as arb
from gryphon.lib.exchange.consts import Consts


class MoneyLtIssue(Strategy):

    def __init__(self, db, harness=None, strategy_configuration=None):
        self.done = False
        super(MoneyLtIssue, self).__init__(db, harness, strategy_configuration)

    def tick(self, open_orders):
        crosses = arb.detect_crosses_between_many_orderbooks(
            [self.harness.bitstamp_eth_eur.get_orderbook(),
             self.harness.bitstamp_eth_btc.get_orderbook(),
            self.harness.bitstamp_eth_usd.get_orderbook()], ignore_unprofitable=False
        )

        for cross in crosses:
            print(cross)
            self.done = True

    def is_complete(self):
        return self.done

When multiple crosses are detected (hence why I need to pass 3 orderbooks), this happens :

ERROR:gryphon.execution.live_runner:[CurrencyMismatch] unsupported operation between money in 'EUR' and 'USD': '<'. Use XMoney for automatic currency conversion.
Traceback (most recent call last):
  File "/opt/Projects/gryphon/gryphon/execution/live_runner.py", line 281, in live_run
    harness.tick()
  File "harness.pyx", line 161, in gryphon.execution.harness.harness.Harness.tick (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3195)
  File "/opt/Projects/gryphon/gryphon/lib/util/profile.py", line 59, in inner
    t, result = timeit.timeit(run_func, number=1)
  File "/usr/lib/python2.7/timeit.py", line 237, in timeit
    return Timer(stmt, setup, timer).timeit(number)
  File "/usr/lib/python2.7/timeit.py", line 202, in timeit
    timing = self.inner(it, self.timer)
  File "/opt/Projects/gryphon/gryphon/lib/util/monkeypatch_timeit.py", line 14, in inner
    retval = _func()
  File "/opt/Projects/gryphon/gryphon/lib/util/profile.py", line 57, in run_func
    return func(*args, **kwargs)
  File "harness.pyx", line 169, in gryphon.execution.harness.harness.Harness.tick_algo (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3394)
  File "money_lt_issue.pyx", line 13, in strategies.money_lt_issue.MoneyLtIssue.tick (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/strategies/money_lt_issue.c:1228)
  File "/opt/Projects/gryphon/gryphon/lib/arbitrage.py", line 234, in detect_crosses_between_many_orderbooks
    crosses = sorted(crosses, key=lambda c: c.profit, reverse=True)
  File "/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/money/money.py", line 54, in __lt__
    raise CurrencyMismatch(self.currency, other.currency, '<')
CurrencyMismatch: unsupported operation between money in 'EUR' and 'USD': '<'. Use XMoney for automatic currency conversion.

Builtin strategy configuration autocreate ?

When running a strategy, the first level of parametrization shoud be done via configuration files.
However when a user first install gryphon, most of default values used are "hidden in code", especially invisible for users running 'builtin' strategies.

I am wondering if it wouldn't be better to have builtin strategies creating their configuration file upon first run, so that the user can easily find and modify what he needs, at his level, in the folder where he runs the strategy from....

Thoughts?

Migrate database cannot import name escape_sequence

hi I'm having issues with the command:

./gryphon-exec run-migrations --database trading --execute

Gives error:

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb/converters.py", line 35, in <module> from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL ImportError: cannot import name escape_sequence

gryphon-runtests runs successfully with no errors:

263 tests run in 2.212 seconds (263 tests passed)

Out of date GDS dictionary

When I try to run GDS I get the following error,

12:30:33 PRODUCER.1 | INFO:emerald-havoc-producer:['BITSTAMP_BTC_USD', 'COINBASE_BTC_USD', 'GEMINI_BTC_USD'] 12:30:33 PRODUCER.1 | Traceback (most recent call last): 12:30:33 PRODUCER.1 | File "runt.py", line 80, in <module> 12:30:33 PRODUCER.1 | main() 12:30:33 PRODUCER.1 | File "runt.py", line 68, in main 12:30:33 PRODUCER.1 | TradesPollTask(exchanges=non_orderbook_exchanges).start_task() 12:30:33 PRODUCER.1 | File "/home/matteo/Desktop/gryphon/gryphon/data_service/trades_poll_task.py", line 33, in __init__ 12:30:33 PRODUCER.1 | self.pollers = [exchange_pollers[ex] for ex in exchanges] 12:30:33 PRODUCER.1 | KeyError: 'GEMINI_BTC_USD'

When I checked the code in trades_poll_task.py, it looks like the dictionary contains the key 'GEMINI' but not 'GEMINI_BTC_USD'. I'm not sure if the fix is as simple as updating the key.

Dashboard

I've been able to play around with different strategies, but can't seem to get the dashboard to work.

I get this error.

(venv) zen:dashboards matt$ gryphon-dashboards

INFO:gryphon.dashboards.app:Could not find a gds credential, orderbook and other dashboards won't be operational
WARNING:root:404 GET /__webpack_hmr (::1) 3.00ms - FAST
WARNING:root:404 GET /__webpack_hmr (::1) 1.21ms - FAST
WARNING:root:404 GET /__webpack_hmr (::1) 0.91ms - FAST

As I've downloaded from source, do I need to build the webpack version of the site?

Or any other pointers you can provide?

Thanks guys.

Feature request : Allow & document sqlite database usage

For installation and usage improvement, how about implementing / documenting workflow using sqlite ? It might be good enough for most usage, and would require less setup effort.

For example have the file path in the config, and let gryphon automatically create it. Security will be managed by the user, via file permissions, so no DB knowledge needed.

Sounds nice to me, but what is everyone thinking about it ? Can there be some potential drawbacks ?

CCXT Integration

CCXT is a cryptocurrency trading API with support for more than 130 bitcoin/altcoin exchanges. Using ccxt as the underlying platform for exchange connections would greatly enhance the opportunity for wide scaled arbitrage and trading opportunities.

AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'

I got an error after running this command;
(grybot)$ gryphon-exec run-migrations --database trading --execute
Python2 is correctly installed all other modules.

--||--
(grybot)$ gryphon-exec run-migrations --database trading --execute
INFO:gryphon.execution.controllers.run_migrations:Migrating the trading database
Traceback (most recent call last):
File "/usr/local/bin/gryphon-exec", line 10, in
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/gryphon/execution/app.py", line 544, in main
app.run()
File "/usr/local/lib/python2.7/site-packages/cement/core/foundation.py", line 882, in run
return_val = self.controller._dispatch()
File "/usr/local/lib/python2.7/site-packages/cement/core/controller.py", line 471, in _dispatch
return func()
File "/usr/local/lib/python2.7/site-packages/cement/core/controller.py", line 477, in _dispatch
return func()
File "/usr/local/lib/python2.7/site-packages/gryphon/execution/app.py", line 491, in default
run_migrations.main(target_db, execute)
File "/usr/local/lib/python2.7/site-packages/gryphon/execution/controllers/run_migrations.py", line 63, in main
run_migrations(target_db)
File "/usr/local/lib/python2.7/site-packages/gryphon/execution/controllers/run_migrations.py", line 50, in run_migrations
command.upgrade(alembic_cfg, 'head')
File "/usr/local/lib/python2.7/site-packages/alembic/command.py", line 124, in upgrade
script.run_env()
File "/usr/local/lib/python2.7/site-packages/alembic/script.py", line 193, in run_env
util.load_python_file(self.dir, 'env.py')
File "/usr/local/lib/python2.7/site-packages/alembic/util.py", line 177, in load_python_file
module = load_module(module_id, path)
File "/usr/local/lib/python2.7/site-packages/alembic/compat.py", line 39, in load_module
return imp.load_source(module_id, path, fp)
File "/usr/local/lib/python2.7/site-packages/gryphon/execution/migrations/env.py", line 98, in
run_migrations_online()
File "/usr/local/lib/python2.7/site-packages/gryphon/execution/migrations/env.py", line 76, in run_migrations_online
engine = create_engine(os.environ.get('TRADING_DB_CRED'))
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/init.py", line 443, in create_engine
return strategy.create(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 56, in create
plugins = u._instantiate_plugins(kwargs)
AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'
--||--

Bitfinex

I'm trying to use Bitfinex (BTCUSD) and and striking this issue:

(venv) zen:gryphon matt$ gryphon-exec initialize-ledger BITFINEX_BTC_USD
Could not initialize BITFINEX_BTC_USD, for an unexpected reason.

I can see that this page says BITFINEX is supported => https://gryphon.readthedocs.io/en/latest/exchange_integrations.html#supported-exchange-list

However, this page does not mention BITFINEX in the config examples => https://gryphon.readthedocs.io/en/latest/environment.html#environment-exchanges

I've downloaded the source and I can see gryphon-master/gryphon/lib/exchange/bitfinex_btc_usd.py exists

I've tried different permutations of the below, but suspect I am missing the correct key names.

BITFINEX_BTC_USD_API_KEY_ID=[my key id]
BITFINEX_BTC_USD_API_KEY=[my api key]
BITFINEX_BTC_USD_API_SECRET=[my secret]

I've tried the debugging steps as per the previous ticket, but I don't think it even got that far as it fails the

if configuration: test on line 45 of ..lib/exchange/bitfinex_btc_usd.py

Thanks again for this project, really enjoying playing around with this.

'module' object has no attribute 'Money'

I isolated an issue that I believe would benefit from being investigated & fixed early, to sort out any oddities in gryphon import structure and tests, before adding more changes....

I m on python 2.7.16 with nose 1.3.7.

AttributeError: 'module' object has no attribute 'Money'

I added this code at the beginning of gryphon/lib/money to see what was happening :

from pprint import pprint
pprint("BEFORE:")
pprint(sys.modules.get('money'))


# need absolute_import from above so that this doesn't load our current file
import money as super_money

pprint("AFTER:")
pprint(sys.modules.get('money'))

And I run some models tests in two ways :

(grytest) alexv@pop-os:~/Projects/gryphon_check$ nosetests -s gryphon/tests/logic/models/order_test.py 
'BEFORE:'
None
'AFTER:'
<module 'money' from '/home/alexv/.virtualenvs/grytest/local/lib/python2.7/site-packages/money/__init__.pyc'>
....
----------------------------------------------------------------------
Ran 4 tests in 0.012s

OK

which works fine and

(grytest) alexv@pop-os:~/Projects/gryphon_check$ nosetests -s gryphon/tests/logic/models
'BEFORE:'
None
'BEFORE:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'AFTER:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'BEFORE:'
None
'BEFORE:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'AFTER:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'BEFORE:'
None
'BEFORE:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'AFTER:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'BEFORE:'
None
'BEFORE:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'AFTER:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'BEFORE:'
None
'BEFORE:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
'AFTER:'
<module 'money' from '/opt/Projects/gryphon_check/gryphon/lib/money.pyc'>
EEEEE
======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'Money')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/alexv/.virtualenvs/grytest/local/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/alexv/.virtualenvs/grytest/local/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/alexv/.virtualenvs/grytest/local/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/opt/Projects/gryphon_check/gryphon/tests/logic/models/balance_test.py", line 10, in <module>
    from gryphon.lib.money import Money
  File "/opt/Projects/gryphon_check/gryphon/lib/money.py", line 16, in <module>
    import money as super_money
  File "/opt/Projects/gryphon_check/gryphon/lib/money.py", line 21, in <module>
    class Money(super_money.Money):
AttributeError: 'module' object has no attribute 'Money'

======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'Money')
----------------------------------------------------------------------
[...]

======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'Money')
----------------------------------------------------------------------
[...]

======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'Money')
----------------------------------------------------------------------
[...]

======================================================================
ERROR: Failure: AttributeError ('module' object has no attribute 'Money')
----------------------------------------------------------------------
[...]

----------------------------------------------------------------------
Ran 5 tests in 0.001s

FAILED (errors=5)

Which I interpret roughly as "the nose importer doesn't do absolute imports AND does not clean its imports after each test".

I tried to use the isolate plugin with --with-isolate but that seems to just make things worse...

Can anyone replicate this ? Thoughts ?

Running a strategy from a Jupyter Notebook

I would like to run a strategy from a notebook (to be able to draw diagrams and study a strategy with a more interactive and graphical interface).

How would I go about doing this ? I probably need to run the harness, from python and not from shell so that I can pass the strategy class from the notebook cell, redirect the log output somewhere else... and probably stop at some time in the future(not going for ever)...

Has anyone already done that before ?
Maybe something to add to the docs...

CompileError clang/cython

Hi!

I am trying to run the gryphon dashboards with the Gryphon Data Service (GDS). I have set up redis and RabbitMQ properly, but I keep on running into a CompileError when I call foreman start to start the GDS. Has anyone run into the same problem? Any guidance on how I should proceed? The TRADES and ORDERBOOK parts work fine, as shown in the error message below, but PRODUCER always crashes:

$ foreman start
11:43:09 PRODUCER.1           | started with pid 18413
11:43:09 ORDERBOOK_CONSUMER.1 | started with pid 18414
11:43:09 TRADES_CONSUMER.1    | started with pid 18415
11:43:09 VOLUMES_CONSUMER.1   | started with pid 18416
11:43:10 VOLUMES_CONSUMER.1   | INFO:raven.base.Client:Raven is not configured (logging is disabled). Please see the documentation for more information.
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:raven.base.Client:Raven is not configured (logging is disabled). Please see the documentation for more information.
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Connecting to amqp://guest:guest@localhost:5672
11:43:10 VOLUMES_CONSUMER.1   | INFO:pika.adapters.base_connection:Connecting to ::1:5672
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Connection opened
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Adding connection close callback
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Channel opened
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Adding channel close callback
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Declaring exchange trades_exchange
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Exchange declared
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Declaring queue exchange_volume_durable
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Binding trades_exchange to exchange_volume_durable with *.exchange_volume.tinker
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Queue bound
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Issuing consumer related RPC commands
11:43:10 VOLUMES_CONSUMER.1   | INFO:emerald-havoc-consumer:Adding consumer cancellation callback
11:43:10 TRADES_CONSUMER.1    | INFO:raven.base.Client:Raven is not configured (logging is disabled). Please see the documentation for more information.
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Connecting to amqp://guest:guest@localhost:5672
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:pika.adapters.base_connection:Connecting to ::1:5672
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Connection opened
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Adding connection close callback
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Channel opened
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Adding channel close callback
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Declaring exchange trades_exchange
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Exchange declared
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Declaring queue orderbook_durable
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Binding trades_exchange to orderbook_durable with *.orderbook.tinker
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Queue bound
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Issuing consumer related RPC commands
11:43:10 ORDERBOOK_CONSUMER.1 | INFO:emerald-havoc-consumer:Adding consumer cancellation callback
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Connecting to amqp://guest:guest@localhost:5672
11:43:10 TRADES_CONSUMER.1    | INFO:pika.adapters.base_connection:Connecting to ::1:5672
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Connection opened
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Adding connection close callback
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Channel opened
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Adding channel close callback
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Declaring exchange trades_exchange
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Exchange declared
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Declaring queue trades_durable
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Binding trades_exchange to trades_durable with *.trades.tinker
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Queue bound
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Issuing consumer related RPC commands
11:43:10 TRADES_CONSUMER.1    | INFO:emerald-havoc-consumer:Adding consumer cancellation callback
11:43:10 PRODUCER.1           | /Users/raulgallodagir/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/lib/exchange/base.c:17:2: error: unterminated conditional directive
11:43:10 PRODUCER.1           | #ifndef Py_PYTHON_H
11:43:10 PRODUCER.1           |  ^
11:43:10 PRODUCER.1           | /Users/raulgallodagir/.pyxbld/temp.macosx-10.14-x86_64-2.7/pyrex/gryphon/lib/exchange/base.c:14490:102: error: expected ';' after top level declarator
11:43:10 PRODUCER.1           |   {&__pyx_n_s_price_quote_req, __pyx_k_price_quote_req, sizeof(__pyx_k_price_quote_req), 0, 0, 1, 1}}
11:43:10 PRODUCER.1           |                                                                                                      ^
11:43:10 PRODUCER.1           |                                                                                                      ;
11:43:10 PRODUCER.1           | 2 errors generated.
11:43:10 PRODUCER.1           | Traceback (most recent call last):
11:43:10 PRODUCER.1           |   File "runt.py", line 13, in <module>
11:43:10 PRODUCER.1           |     from gryphon.data_service.auditor_task import AuditorTask
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/gryphon/data_service/auditor_task.py", line 2, in <module>
11:43:10 PRODUCER.1           |     from gryphon.data_service.auditors.bitstamp_orderbook_auditor import BitstampOrderbookAuditor
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/gryphon/data_service/auditors/bitstamp_orderbook_auditor.py", line 3, in <module>
11:43:10 PRODUCER.1           |     from gryphon.data_service.auditors.orderbook_auditor import OrderbookAuditor
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/gryphon/data_service/auditors/orderbook_auditor.py", line 18, in <module>
11:43:10 PRODUCER.1           |     from gryphon.lib.exchange.base import Exchange
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 431, in load_module
11:43:10 PRODUCER.1           |     language_level=self.language_level)
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 209, in load_module
11:43:10 PRODUCER.1           |     inplace=build_inplace, language_level=language_level)
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 186, in build_module
11:43:10 PRODUCER.1           |     reload_support=pyxargs.reload_support)
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/pyximport/pyxbuild.py", line 104, in pyx_to_dll
11:43:10 PRODUCER.1           |     dist.run_commands()
11:43:10 PRODUCER.1           |   File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
11:43:10 PRODUCER.1           |     self.run_command(cmd)
11:43:10 PRODUCER.1           |   File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
11:43:10 PRODUCER.1           |     cmd_obj.run()
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/Cython/Distutils/build_ext.py", line 163, in run
11:43:10 PRODUCER.1           |     _build_ext.build_ext.run(self)
11:43:10 PRODUCER.1           |   File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 340, in run
11:43:10 PRODUCER.1           |     self.build_extensions()
11:43:10 PRODUCER.1           |   File "/usr/local/lib/python2.7/site-packages/Cython/Distutils/build_ext.py", line 171, in build_extensions
11:43:10 PRODUCER.1           |     self.build_extension(ext)
11:43:10 PRODUCER.1           |   File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 499, in build_extension
11:43:10 PRODUCER.1           |     depends=ext.depends)
11:43:10 PRODUCER.1           |   File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 574, in compile
11:43:10 PRODUCER.1           |     self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
11:43:10 PRODUCER.1           |   File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/unixccompiler.py", line 124, in _compile
11:43:10 PRODUCER.1           |     raise CompileError, msg
11:43:10 PRODUCER.1           | ImportError: Building module gryphon.lib.exchange.base failed: ["CompileError: command 'clang' failed with exit status 1\n"]
11:43:11 PRODUCER.1           | exited with code 1
11:43:11 system               | sending SIGTERM to all processes
11:43:11 VOLUMES_CONSUMER.1   | terminated by SIGTERM
11:43:11 TRADES_CONSUMER.1    | terminated by SIGTERM
11:43:11 ORDERBOOK_CONSUMER.1 | terminated by SIGTERM

Thanks in advance for the help ;)

ERROR:gryphon.execution.live_runner:[UnmappedInstanceError] Class '__builtin__.NoneType' is not mapped

Finished the installation, and ran the tests. Everything seems to have been setup correctly.

Using the Built In Simple Market Maker to test out the system. On each "trade" I guess, this error comes up, it keeps running fine, the trades are actually placed via API, but it is kind of annoying to see over and over again, and I just wanted to see if there is a way to fix this?

ERROR:gryphon.execution.live_runner:[UnmappedInstanceError] Class '__builtin__.NoneType' is not mapped
Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python2.7/site-packages/gryphon/execution/live_runner.py", line 281, in live_run
    harness.tick()
  File "harness.pyx", line 157, in gryphon.execution.harness.harness.Harness.tick (/home/ubuntu/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3155)
  File "harness.pyx", line 193, in gryphon.execution.harness.harness.Harness.consolidate_ledgers (/home/ubuntu/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3879)
  File "exchange_coordinator.pyx", line 77, in gryphon.execution.harness.exchange_coordinator.ExchangeCoordinator.consolidate_ledger (/home/ubuntu/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/exchange_coordinator.c:1941)
  File "exchange_coordinator.pyx", line 134, in gryphon.execution.harness.exchange_coordinator.ExchangeCoordinator._run_accounting (/home/ubuntu/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/exchange_coordinator.c:2777)
  File "exchange_coordinator.pyx", line 233, in gryphon.execution.harness.exchange_coordinator.ExchangeCoordinator.update_position (/home/ubuntu/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/exchange_coordinator.c:4405)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py", line 162, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1940, in add
    raise exc.UnmappedInstanceError(instance)
UnmappedInstanceError: Class '__builtin__.NoneType' is not mapped
INFO:gryphon.execution.live_runner:handle_exception succeeded, full speed ahead

Add support for BitMex exchange.

Could someone add support for the BitMex exchange? And if someone had the documentation to add a new exchange direct me to that but still keep the issue open?

Strategy: Auditing cancels orders ?

I recently noticed that auditing a strategy implies cancelling orders... Is that required for some reason ?

A side effect seems to be that these cancelled orders are not passed to the strategy tick() method... which means the strategy has no way to know these orders have been cancelled...

Any hint/idea to improve that ?

Setting up Data Service HOWTO

I have been trying to setup the data service on my machine, but it looks like there are some information missing from the docs.

Questions that comes to mind :

  • how do I setup the GDS database ? There is a setting should put in the configuration file, but no info about that.
  • where do I find foreman ? It doesn't seem to be installed by the requirements... something missing somewhere, or not uptodate ?
  • why do I need to cd gryphon/data_service/ it is a python package, isn't it ? no entry point ?
  • whats emerald ?
  • Should I attempt use runt.py directly or not ?
  • the README is empty...

So I m a bit confused as you can see...

Backtest feature

It would be great to be able to test your strategies with past data on the selected exchanges.

Strategies are `.pyx` only ?

Is that expected ?

Attempting to run a gryphon-exec strategy strategies/mystrat.py gives :

Traceback (most recent call last):
  File "/home/alexv/.virtualenvs/gryphon2/bin/gryphon-exec", line 11, in <module>
    load_entry_point('gryphon', 'console_scripts', 'gryphon-exec')()
  File "/opt/Projects/gryphon/gryphon/execution/app.py", line 544, in main
    app.run()
  File "/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/cement/core/foundation.py", line 882, in run
    return_val = self.controller._dispatch()
  File "/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/cement/core/controller.py", line 477, in _dispatch
    return func()
  File "/opt/Projects/gryphon/gryphon/execution/app.py", line 151, in strategy
    live_run(final_configuration)
  File "/opt/Projects/gryphon/gryphon/execution/live_runner.py", line 234, in live_run
    strategy_class = get_strategy_class(strategy_name, is_builtin_strategy)
  File "/opt/Projects/gryphon/gryphon/execution/live_runner.py", line 168, in get_strategy_class
    return get_strategy_class_from_filepath(strategy_path)
  File "/opt/Projects/gryphon/gryphon/execution/live_runner.py", line 158, in get_strategy_class_from_filepath
    module = importlib.import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named py

It looks like it might be an easy fix...

Consistent default values for exchange fees ?

Having a look at kraken_btc_usd and kraken_btc_eur the fees are configured for different type of users...

Ideally we should have the default values matching the setup of a new user of an exchange.
We can probably not enforce that they always match what the exchange fees actually are, but we probably can :

  • centralize some of the exchange configuration (it's not related with the traded currency pair for example), to avoid inconsistent changes in multiple places.
  • keep reference links around in the source, and rely on a developer modifying the default values when the exchange happens to change its fees policy.
  • #41 so that "advanced" user can easily change their personal fee via configuration, once they have traded enough to have their fees decreased by the exchange.

Initialize-ledger retrieve exchange ledger

Feature request

Initializing a ledger retrieves the current balance from the exchange, and writes it into the ledger DB as an initial "deposit".

I am thinking this might not be optimal, as if someone initializes a ledger multiple times (or in multiple places) for whatever reason, (s)he will loose visibility on past history (that is however kept on the exchange).

To keep consistency, it would be nice to have the possibility to import the complete exchange ledger into our gryphon ledger DB, upon initialization.

I am wondering if this would be a good idea or if there are things I am overlooking...
What does everyone thinks ?

SQL Operational Error on datetime ?

I started trading on kraken recently and I got this (on first order passed I think...) :

ERROR:gryphon.execution.live_runner:[OperationalError] (_mysql_exceptions.OperationalError) (1292, "Incorrect datetime value: '2019-07-04 15:48:46+00:00' for column `gryphon`.`trade`.`time_created` at row 1")
Traceback (most recent call last):
  File "/opt/Projects/gryphon/gryphon/execution/live_runner.py", line 281, in live_run
    harness.tick()
  File "harness.pyx", line 157, in gryphon.execution.harness.harness.Harness.tick (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3155)
  File "harness.pyx", line 193, in gryphon.execution.harness.harness.Harness.consolidate_ledgers (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/harness.c:3879)
  File "exchange_coordinator.pyx", line 77, in gryphon.execution.harness.exchange_coordinator.ExchangeCoordinator.consolidate_ledger (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/exchange_coordinator.c:1941)
  File "exchange_coordinator.pyx", line 133, in gryphon.execution.harness.exchange_coordinator.ExchangeCoordinator._run_accounting (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/exchange_coordinator.c:2754)
  File "exchange_coordinator.pyx", line 361, in gryphon.execution.harness.exchange_coordinator.ExchangeCoordinator._save_order (/home/alexv/.pyxbld/temp.linux-x86_64-2.7/pyrex/gryphon/execution/harness/exchange_coordinator.c:6591)
  File "/opt/Projects/gryphon/gryphon/lib/session.py", line 74, in commit_mysql_session
    raise e
OperationalError: (_mysql_exceptions.OperationalError) (1292, "Incorrect datetime value: '2019-07-04 15:48:46+00:00' for column `gryphon`.`trade`.`time_created` at row 1") [SQL: u'INSERT INTO trade (trade_type, unique_id, exchange_trade_id, time_created, fee, fee_currency, price, price_currency, volume, volume_currency, meta_data, fee_buyback_transaction_id, order_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'] [parameters: ('BID', '--snip--', '--snip--', datetime.datetime(2019, 7, 4, 15, 48, 46, tzinfo=<UTC>), Decimal('0.0843'), 'EUR', Decimal('52.6820'), 'EUR', Decimal('0.0050000000'), 'BTC', '{}', None, 219L)] (Background on this error at: http://sqlalche.me/e/e3q8)
INFO:gryphon.execution.harness.harness:[DynamicMarketMaking] (04/07/19 15:49:01 UTC) Winding Down

Any hint ?

Document sim_exchange

I recently found out about sim_exchange.py
I built something similar in python in my strategy to evaluate performance during a strategy run ( over multiple ticks ) even when not running with --execute, but it looks like sim_exchange could be used for that exact purpose, maybe via a --simulate option ?

I believe sim_exchange.py is not documented yet but should be.

Forex:Could not establish redis exchange rate.

I recently noticed : INFO:gryphon.lib.forex:Could not establish redis exchange rate. in my log.

I previously did setup my OXR account, along with a redis DB, and specified that in my configuration as explained in the documentation, since I mostly use EUR as price currency.

What are my options to investigate / debug more, only on this part, without involving a whole strategy run if possible ?

Thanks a lot !

Sentry alternative ?

I am having issues setting up sentry (python envs, permission, postgres setup, etc.).
While I can eventually solve that, is there another possibility to store all logs, but maybe with a simpler, quicker setup ?
Like everything in a text file or something?
I m looking for a simple solution to start leaving gryphon running for some time without always having to watch the terminal... but I probably don't need the whole sentry heavyweight...
Thanks !

Example Code is not working

Screenshot from 2019-07-01 17-41-38

Actually, I tried it run from the command line too and it is showing the same error. It is not able to call the base file.

tornadotoad

tornadotoad seems to rely on tornado 4.*
with tornado 5 it throws errors about IOLoop (when dashboard errors), so on my venv I rolledback to tornado 4.5.3.

tornadotoad doesnt seem very maintained... the github repo is gone...
What would be the plan going forward for this ?

Looking for feedback: Strategies and Strategy Ledgers are not intuitive to users

Hey folks, I've heard from more than one person that the current behaviour of Strategy ledgers is counter-intuitive to new users. I have some thoughts about how to restructure this but I wanted to get the community opinion.

Here's the issue. The built-in market making strategies have a concept of a 'primary exchange', being the sole exchange which this strategy will place orders on, which is configurable between runs. By default, a strategy only has a single trade history (I call this the 'strategy ledger' in my head, but this might be confusing since we use 'ledger' also for exchanges, and for the total trade history of the firm in general, also looking for feedback about this terminology). This means that if you do a second run of the same strategy with a different primary exchange, it's running on the same strategy ledger and will have the some position, p&l etc. as the previous run.

This is surprising to some users, who think that running e.g. SimpleMarketMaking on two separate exchanges should represent a different trade history and have different metrics.

The reason this happens is because orders are associated with a strategy through their actor field. By default a strategy's actor is just it's name upper-cased. See:

def actor(self):
"""
The strategy's 'actor' is how orders and trades are associated with the
strategy in the database. As a consequence, if two strategies have the same
actor, they have the same trade history and position.
"""
return self.__class__.__name__.upper()
Creating a separate ledger for each different targeted exchange is pretty simple, you'd just override the actor property and make it parameterized with the primary exchange.

This is intended behaviour. At Tinker, we sometimes ran a single strategy in multiple processes at once, with each process targeting a separate exchange. This gives a bunch of benefits through parallelism but helps with fault tolerance. Writing strategies such that they can be parallelized like this is surprisingly easy.

So here's the questions at hand:

  1. Should we change the default strategies so that by default they keep separate ledgers for different target exchanges?
  2. Should we somehow clarify in code the use of actor's to create these two different effects?

If yes to 2), I think a simple way to do this would be to have two strategy subclasses users could use. The first could be the current default, something like

class GlobalLedgerStrategy(Strategy)

and the different-ledger-for-each-exchange strategy could do something like this:

class ExchangeLocalLedgerStrategy(Strategy):
    @property
    def actor(self):
        return '%s_%s' % s(elf.__class__.__name__.upper(), self.primary_exchange_name)

Possibly both of these could inheret from something like PrimaryExchangeStrategy, since they both share the property and code of having a configurable target exchange. I'm open to different naming ideas for all of this too.

Thoughts?

Keeping track of dependencies

Gryphon has a lot of dependencies. We should look around for a service to help us manage them (I m thinking of something like https://pyup.io/ but dont have any strong preference).

The goal is to get an automatic pull request when a new version of dependency is available, so we can quickly decide if we want to upgrade or not (based on our PR build result). This helps to remain in control of our dependencies, stay close to the latest versions with minimum effort, and makes mandatory manual upgrades less painful (as all transitive dependencies usually have been upgraded previously).

Thoughts ?

The homepage readme "gryphon-exe" is a typo?

"Copy this code into a python file named 'arbitrage.py' in the same directory as your .env file, and you can run it in test mode with gryphon-exe strategy arbitrage."

The command "gryphon-exe strategy arbitrage" should be

"gryphon-exec strategy arbitrage"?

Screen Shot 2019-07-10 at 3 02 34 PM

AttributeError: type object 'IOLoop' has no attribute 'initialized'

Whenever i run the dashboard server and navigate to the "Simple Market Making" tab under "Trading" in the dashboard, i get the following error:

  (util.ellipses_string(value),))
ERROR:tornado.application:Uncaught exception GET /strategies/manual (::1)
HTTPServerRequest(protocol='http', host='localhost:8080', method='GET', uri='/strategies/manual', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornado/web.py", line 1590, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornado/web.py", line 3006, in wrapper
    return method(self, *args, **kwargs)
  File "/Users/tdudz/gryphon/gryphon/dashboards/handlers/strategies/strategy.py", line 63, in get
    self.render_template('strategy.html', args=template_args)
  File "/Users/tdudz/gryphon/gryphon/dashboards/handlers/admin_base.py", line 109, in render_template
    return self.render(template, **kwargs)
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornado/web.py", line 766, in render
    html = self.render_string(template_name, **kwargs)
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornado/web.py", line 907, in render_string
    return t.generate(**namespace)
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornado/template.py", line 346, in generate
    return execute()
  File "templates/strategy_html.generated.py", line 107, in _tt_execute
    _tt_tmp = '%s %.2f' % (args['open_pl'].currency, args['open_pl'].amount)  # templates/strategy.html:51 (via templates/base.html:207)
AttributeError: 'NoneType' object has no attribute 'currency'
ERROR:tornado.application:Exception in exception handler
Traceback (most recent call last):
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornado/web.py", line 1597, in _execute
    self._handle_request_exception(e)
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornado/web.py", line 1650, in _handle_request_exception
    self.send_error(500, exc_info=sys.exc_info())
  File "/Users/tdudz/gryphon/gryphon/dashboards/handlers/base.py", line 67, in send_error
    tornado_toad.post_notice(exception, request=request_data)
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornadotoad/api.py", line 28, in post_notice
    self._send(url, body=body, headers={'Content-Type': 'text/xml'})
  File "/Users/tdudz/.local/share/virtualenvs/gryphon-qObydNvD/lib/python2.7/site-packages/tornadotoad/api.py", line 141, in _send
    if tornado.ioloop.IOLoop.initialized():
AttributeError: type object 'IOLoop' has no attribute 'initialized'```

Error installing: Collecting futures==3.2.0 (from gryphon) ERROR: Could not find a version that satisfies the requirement futures==3.2.0 (from gryphon)

Tried pip upgrade
and $ pip install gryphon
and got this error. Any pointers?
Excited to get this started with this project.
Thank you.

'''
Collecting futures==3.2.0 (from gryphon)
  ERROR: Could not find a version that satisfies the requirement futures==3.2.0 (from gryphon) (from versions: 0.2.python3, 0.1, 0.2, 1.0, 2.0, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.1.5, 2.1.6, 2.2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1.0, 3.1.1)
ERROR: No matching distribution found for futures==3.2.0 (from gryphon)
'''

itbit_btc_usd doesn't allow for anything less than 0.01 btc volume

Sorry in advance, should probably be a pull request..

Found that this code in itbit's place_order function makes it so that anything below 3 decimal places in order volume comes in as 0.00.

Present Code:

        # Truncate the volume instead of rounding it because it's better# to trade too
        # little than too much.
        volume = volume.round_to_decimal_places(2, rounding=cdecimal.ROUND_DOWN)

        volume_str = '%.2f' % volume.amount
        price_str = '%.2f' % price.amount

Suggested fix, add for 8 decimal places:

        # Truncate the volume instead of rounding it because it's better# to trade too
        # little than too much.
        volume = volume.round_to_decimal_places(8, rounding=cdecimal.ROUND_DOWN)

        volume_str = '%.8f' % volume.amount
        price_str = '%.2f' % price.amount

Changes:
'%.2f' to '%.8f'
'round_to_decimal_places(2,' .... to 'round_to_decimal_places(8,'

make_exchange_datas_from_keys assertion

This: https://github.com/garethdmm/gryphon/blob/master/gryphon/lib/exchange/exchange_factory.py#L145

keeps asserting, when using the dashboard (Just clicking on "trading" -> "status" for example)
I am guessing this is because I did not setup a bank account ?

So I get (with a small debug change):

Traceback (most recent call last):
  File "/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/tornado/web.py", line 1510, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "/home/alexv/.virtualenvs/gryphon2/local/lib/python2.7/site-packages/tornado/web.py", line 2898, in wrapper
    return method(self, *args, **kwargs)
  File "/home/alexv/Projects/gryphon/gryphon/dashboards/handlers/status.py", line 31, in get
    bank_accounts = self.get_trading_bank_accounts()
  File "/home/alexv/Projects/gryphon/gryphon/dashboards/handlers/status.py", line 178, in get_trading_bank_accounts
    self.trading_db,
  File "/home/alexv/Projects/gryphon/gryphon/lib/exchange/exchange_factory.py", line 102, in make_exchange_data_from_key
    exchange_datas = make_exchange_datas_from_keys(keys, db)
  File "/home/alexv/Projects/gryphon/gryphon/lib/exchange/exchange_factory.py", line 145, in make_exchange_datas_from_keys
    assert len(exchange_datas) == len(pair_names), str(exchange_datas) + " " + str(pair_names)
AssertionError: [] ['BMO_USD']

However I would like the dashboard to be usable, even without any bank account setup.
I am wondering where I should start looking if I want to fix that ?
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.