scrtlabs / catalyst

An Algorithmic Trading Library for Crypto-Assets in Python
http://enigma.co
Apache License 2.0
2.49k stars 725 forks source link

Live mode crash after buying on poloniex #103

Closed Knifespirit closed 6 years ago

Knifespirit commented 6 years ago

Dear Catalyst Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

I wanted to test catalyst. Tested backtesting, tested the live paper trading. Works fine. As soon as I try to run the code on live mode it will crash right after buying.

I used poloniex. This error happend to me every time right after buying (tried around 10 times)

Here is how you can reproduce this issue on your machine:

Reproduction Steps

  1. Run the example mean_reversion_simple.py on live mode
  2. The bot finds something to buy
  3. The bot buys it
  4. the bot crashes ...

What steps have you taken to resolve this already?

First I thought it was the code. So i tried out making a try and except at the get_open_orders() and the buying and selling part. But the bot still crashes. Its not in the example code. Its in the "order_target_percent" (I think)

Sincerely, Vincent

fredfortier commented 6 years ago

Looks like it's getting a bad response from poloniex when looking up the status of the order. Will fix asap.

On Sun, Dec 17, 2017 at 9:42 AM Knifespirit notifications@github.com wrote:

Dear Catalyst Maintainers,

Before I tell you about my issue, let me describe my environment: Environment

  • Operating System: Ubuntu 16.04
  • Python Version: 2.7
  • Python Bitness: 64
  • How did you install Catalyst: Installed with pip
  • Python packages: alembic==0.7.7 bcolz==0.12.1 boto3==1.4.8 botocore==1.8.15 Bottleneck==1.0.0 ccxt==1.10.283 click==4.0 contextlib2==0.4.0 cyordereddict==0.2.2 Cython==0.25.2 decorator==4.0.0 docutils==0.14 empyrical==0.2.1 enigma-catalyst==0.4.0 futures==3.2.0 int-date==0.1.8 intervaltree==2.1.0 jmespath==0.9.3 Logbook==0.12.5 lru-dict==1.1.4 Mako==1.0.1 MarkupSafe==0.23 multipledispatch==0.4.8 networkx==1.9.1 numexpr==2.6.1 numpy==1.13.1 pandas==0.19.2 pandas-datareader==0.2.1 patsy==0.4.0 pkg-resources==0.0.0 python-dateutil==2.4.2 pytz==2016.4 requests==2.9.1 requests-file==1.4.1 s3transfer==0.1.12 scipy==0.17.1 six==1.10.0 sortedcontainers==1.4.4 SQLAlchemy==1.0.8 statsmodels==0.6.1 stockstats==0.2.0 tables==3.3.0 toolz==0.8.2

Now that you know a little about me, let me tell you about the issue I am having: Description of Issue

I wanted to test catalyst. Tested backtesting, tested the live paper trading. Works fine. As soon as I try to run the code on live mode it will crash right after buying.

I used poloniex. This error happend to me every time right after buying (tried around 10 times)

-

What did you expect to happen? I expect the live trading to continue after buying

What happened instead? Running in live trading mode. [2017-12-17 14:26:18.372871] INFO: run_algo: running algo in live-trading mode [2017-12-17 14:26:21.945637] INFO: run_algo: base currency available in the account: 0.00987449 btc [2017-12-17 14:26:21.959381] INFO: exchange_algorithm: initialized trading algorithm in live mode [2017-12-17 14:26:23.943889] INFO: exchange_algorithm: got totals from exchanges, cash: 0.00987449 positions: 0.0 [2017-12-17 14:26:26.860017] INFO: mean_reversion_simple: 2017-12-17 14:26:00+00:00: buying - price: 0.0017247, rsi: 98.8546764344 [2017-12-17 14:26:26.989984] INFO: CCXT: adjusted order amount 3.04826346611 to 3.04826346 based on lot size [2017-12-17 14:26:28.630529] INFO: exchange_algorithm: statistics for the last 10 minutes: starting_cash ending_cash portfolio_value pnl long_exposure short_exposure orders transactions volume price_change cash price rsi period_close 2017-12-17 14:26:00+00:00 0.00525734 0.00525734 0.00525734 0.0 0 0 0 0 135731.71949528 0.0 0.00525734 0.0017247 98.85467643 [2017-12-17 14:27:02.095339] WARNING: exchange_blotter: check open orders attempt 0: Request failed: 'Exchange' [2017-12-17 14:27:07.291029] WARNING: exchange_blotter: check open orders attempt 1: Request failed: 'Exchange' [2017-12-17 14:27:12.770497] WARNING: exchange_blotter: check open orders attempt 2: Request failed: 'Exchange' [2017-12-17 14:27:19.870265] WARNING: exchange_blotter: check open orders attempt 3: Request failed: 'Exchange' [2017-12-17 14:27:25.073199] WARNING: exchange_blotter: check open orders attempt 4: Request failed: 'Exchange' [2017-12-17 14:27:30.213943] WARNING: exchange_blotter: check open orders attempt 5: Request failed: 'Exchange' Traceback (most recent call last): File "/home/catalyst/catalyst-venv/bin/catalyst", line 11, in sys.exit(main()) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 664, in call return self.main(args, kwargs) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 644, in main rv = self.invoke(ctx) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke return callback(args, *kwargs) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/main.py", line 102, in _ return f(args, **kwargs) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/main.py", line 474, in live stats_output=None, File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/utils/run_algo.py", line 346, in _run overwrite_sim_params=False, File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/algorithm.py", line 724, in run for perf in self.get_generator(): File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/gens/tradesimulation.py", line 224, in transform for capital_change_packet in every_bar(dt): File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/gens/tradesimulation.py", line 122, in every_bar blotter.get_transactions(current_data) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/exchange/exchange_blotter.py", line 297, in get_transactions return self.get_exchange_transactions() File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/exchange/exchange_blotter.py", line 283, in get_exchange_transactions return self.get_exchange_transactions(attempt_index + 1) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/exchange/exchange_blotter.py", line 283, in get_exchange_transactions return self.get_exchange_transactions(attempt_index + 1) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/exchange/exchange_blotter.py", line 283, in get_exchange_transactions return self.get_exchange_transactions(attempt_index + 1) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/exchange/exchange_blotter.py", line 283, in get_exchange_transactions return self.get_exchange_transactions(attempt_index + 1) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/exchange/exchange_blotter.py", line 283, in get_exchange_transactions return self.get_exchange_transactions(attempt_index + 1) File "/home/catalyst/catalyst-venv/local/lib/python2.7/site-packages/catalyst/exchange/exchange_blotter.py", line 289, in get_exchange_transactions error=e catalyst.exchange.exchange_errors.ExchangePortfolioDataError: Unable to retrieve portfolio data: order-status, giving up after 5 attempts: Request failed: 'Exchange'

Here is how you can reproduce this issue on your machine: Reproduction Steps

  1. Run the example mean_reversion_simple.py on live mode
  2. The bot finds something to buy
  3. The bot buys it
  4. the bot crashes ...

What steps have you taken to resolve this already?

First I thought it was the code. So i tried out making a try and except at the get_open_orders() and the buying and selling part. But the bot still crashes. Its not in the example code. Its in the "order_target_percent" (I think)

Sincerely, Vincent

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/enigmampc/catalyst/issues/103, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ-QgnhnID-tCuRa3Qm74PwXDhUCs99ks5tBShbgaJpZM4RErXn .

Knifespirit commented 6 years ago

I still experence the problem. I dont know if you went through it. And i definily dont want to hurry you.

I am just curious and i am very new to the crypto market, so would love to test some live examples. (And sadly both on Bitfinex as on Bittrex i cannot create an account because they disabled account creation)

Futher I got to say, love the project, good work.

fredfortier commented 6 years ago

I haven't have a chance to look into this yet but I will today. If this is an issue, it's high priority so we'll release something asap. Binance should work in the meanwhile.

On Mon, Dec 18, 2017 at 6:49 AM Knifespirit notifications@github.com wrote:

I still experence the problem. I dont know if you went through it. And i definily dont want to hurry you.

I am just curious and i am very new to the crypto market, so would love to test some live examples. (And sadly both on Bitfinex as on Bittrex i cannot create an account because they disabled account creation)

Futher I got to say, love the project, good work.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/enigmampc/catalyst/issues/103#issuecomment-352404347, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ-QmGOY6FN6SuOJ2vA7odR7o1JXQKaks5tBlFIgaJpZM4RErXn .

Knifespirit commented 6 years ago

I just tried binance. Maybe i should report as another issue, but binance doesnt work. It doesnt see the eth_btc symbol even though it clearly in the list. I tried with other, none work on binance while if i try it with poloniex (even tho i cant use live mode) I get no error with eth_btc what so ever.

My error:

(catalyst) D:\Projects\Mini projects\catalyst>python mean_reversion_simple.py [2017-12-18 23:33:27.397000] INFO: run_algo: running algo in paper-trading mode [2017-12-18 23:33:34.106000] INFO: exchange_algorithm: initialized trading algorithm in backtest mode Error traceback: C:\Users\knife\Anaconda3\envs\catalyst\lib\site-packages\catalyst\exchange\exchange.py (line 259) SymbolNotFoundOnExchange: Symbol ETH_BTC not found on exchange Binance. Choose from: ['123_456', 'ada_btc', 'ada_eth', 'adx_bnb', 'adx_btc', 'adx_eth', 'amb_bnb', 'amb_btc', 'amb_eth', 'ark_btc', 'ark_eth', 'arn_btc', 'arn_eth', 'ast_btc', 'ast_eth', 'bat_bnb', 'bat_btc', 'bat_eth', 'bcd_btc', 'bcd_eth', 'bch_bnb', 'bch_btc', 'bch_eth', 'bch_usdt', 'bcpt_bnb', 'bcpt_btc', 'bcpt_eth', 'bnb_btc', 'bnb_eth', 'bnb_usdt', 'bnt_btc', 'bnt_eth', 'bqx_btc', 'bqx_eth', 'btc_usdt', 'btg_btc', 'btg_eth', 'btm_eth', 'bts_bnb', 'bts_btc', 'bts_eth', 'cdt_btc', 'cdt_eth', 'cmt_bnb', 'cmt_btc', 'cmt_eth', 'cnd_bnb', 'cnd_btc', 'cnd_eth', 'ctr_btc', 'ctr_eth', 'dash_btc', 'dash_eth', 'dgd_btc', 'dgd_eth', 'dlt_bnb', 'dlt_btc', 'dlt_eth', 'dnt_btc', 'dnt_eth', 'elc_btc', 'eng_btc', 'eng_eth', 'enj_btc', 'enj_eth', 'eos_btc', 'eos_eth', 'etc_btc', 'etc_btc', 'etc_eth', 'eth_btc', 'eth_usdt', 'evx_btc', 'evx_eth', 'fuel_btc', 'fuel_eth', 'fun_btc', 'fun_eth', 'gas_btc', 'gto_bnb', 'gto_btc', 'gto_eth', 'gvt_btc', 'gvt_eth', 'gxs_btc', 'gxs_eth', 'hcc_btc', 'hsr_btc', 'hsr_eth', 'icn_btc', 'icn_eth', 'icx_bnb', 'icx_btc', 'icx_eth', 'iota_bnb', 'iota_btc', 'iota_eth', 'kmd_btc', 'kmd_eth', 'knc_btc', 'knc_eth', 'lend_bnb', 'lend_btc', 'lend_eth', 'link_btc', 'link_eth', 'llt_btc', 'lrc_btc', 'lrc_eth', 'lsk_bnb', 'lsk_btc', 'lsk_eth', 'ltc_bnb', 'ltc_btc', 'ltc_eth', 'ltc_usdt', 'mana_btc', 'mana_eth', 'mco_btc', 'mco_eth', 'mda_btc', 'mda_eth', 'mod_btc', 'mod_eth', 'mth_btc', 'mth_eth', 'mtl_btc', 'mtl_eth', 'neo_bnb', 'neo_btc', 'neo_eth', 'neo_usdt', 'nuls_bnb', 'nuls_btc', 'nuls_eth', 'oax_btc', 'oax_eth', 'omg_btc', 'omg_eth', 'poe_btc', 'poe_eth', 'powr_bnb', 'powr_btc', 'powr_eth', 'ppt_btc', 'ppt_eth', 'qsp_bnb', 'qsp_btc', 'qsp_eth', 'qtum_btc', 'qtum_eth', 'rcn_bnb', 'rcn_btc', 'rcn_eth', 'rdn_bnb', 'rdn_btc', 'rdn_eth', 'req_btc', 'req_eth', 'salt_btc', 'salt_eth', 'sngls_btc', 'sngls_eth', 'snm_btc', 'snm_eth', 'snt_btc', 'snt_eth', 'storj_btc', 'storj_eth', 'strat_btc', 'strat_eth', 'sub_btc', 'sub_eth', 'tnb_btc', 'tnb_eth', 'tnt_btc', 'tnt_eth', 'trx_btc', 'trx_eth', 'ven_bnb', 'ven_btc', 'ven_eth', 'vib_btc', 'vib_eth', 'wabi_bnb', 'wabi_btc', 'wabi_eth', 'waves_bnb', 'waves_btc', 'waves_eth', 'wtc_bnb', 'wtc_btc', 'wtc_eth', 'xlm_bnb', 'xlm_btc', 'xlm_eth', 'xmr_btc', 'xmr_eth', 'xrp_btc', 'xrp_eth', 'xvg_btc', 'xvg_eth', 'xzc_bnb', 'xzc_btc', 'xzc_eth', 'yoyo_bnb', 'yoyo_btc', 'yoyo_eth', 'zec_btc', 'zec_eth', 'zrx_btc', 'zrx_eth']

fredfortier commented 6 years ago

Are you backtesting or live trading? Unfortunately, Binance does not include historical data yet. On Mon, Dec 18, 2017 at 3:36 PM Knifespirit notifications@github.com wrote:

I just tried binance. Maybe i should report as another issue, but binance doesnt work. It doesnt see the eth_btc symbol even though it clearly in the list. I tried with other, none work on binance while if i try it with poloniex (even tho i cant use live mode) I get no error with eth_btc what so ever.

My error:

(catalyst) D:\Projects\Mini projects\catalyst>python mean_reversion_simple.py [2017-12-18 23:33:27.397000] INFO: run_algo: running algo in paper-trading mode [2017-12-18 23:33:34.106000] INFO: exchange_algorithm: initialized trading algorithm in backtest mode Error traceback: C:\Users\knife\Anaconda3\envs\catalyst\lib\site-packages\catalyst\exchange\exchange.py (line 259) SymbolNotFoundOnExchange: Symbol ETH_BTC not found on exchange Binance. Choose from: ['123_456', 'ada_btc', 'ada_eth', 'adx_bnb', 'adx_btc', 'adx_eth', 'amb_bnb', 'amb_btc', 'amb_eth', 'ark_btc', 'ark_eth', 'arn_btc', 'arn_eth', 'ast_btc', 'ast_eth', 'bat_bnb', 'bat_btc', 'bat_eth', 'bcd_btc', 'bcd_eth', 'bch_bnb', 'bch_btc', 'bch_eth', 'bch_usdt', 'bcpt_bnb', 'bcpt_btc', 'bcpt_eth', 'bnb_btc', 'bnb_eth', 'bnb_usdt', 'bnt_btc', 'bnt_eth', 'bqx_btc', 'bqx_eth', 'btc_usdt', 'btg_btc', 'btg_eth', 'btm_eth', 'bts_bnb', 'bts_btc', 'bts_eth', 'cdt_btc', 'cdt_eth', 'cmt_bnb', 'cmt_btc', 'cmt_eth', 'cnd_bnb', 'cnd_btc', 'cnd_eth', 'ctr_btc', 'ctr_eth', 'dash_btc', 'dash_eth', 'dgd_btc', 'dgd_eth', 'dlt_bnb', 'dlt_btc', 'dlt_eth', 'dnt_btc', 'dnt_eth', 'elc_btc', 'eng_btc', 'eng_eth', 'enj_btc', 'enj_eth', 'eos_btc', 'eos_eth', 'etc_btc', 'etc_btc', 'etc_eth', 'eth_btc', 'eth_usdt', 'evx_btc', 'evx_eth', 'fuel_btc', 'fuel_eth', 'fun_btc', 'fun_eth', 'gas_btc', 'gto_bnb', 'gto_btc', 'gto_eth', 'gvt_btc', 'gvt_eth', 'gxs_btc', 'gxs_eth', 'hcc_btc', 'hsr_btc', 'hsr_eth', 'icn_btc', 'icn_eth', 'icx_bnb', 'icx_btc', 'icx_eth', 'iota_bnb', 'iota_btc', 'iota_eth', 'kmd_btc', 'kmd_eth', 'knc_btc', 'knc_eth', 'lend_bnb', 'lend_btc', 'lend_eth', 'link_btc', 'link_eth', 'llt_btc', 'lrc_btc', 'lrc_eth', 'lsk_bnb', 'lsk_btc', 'lsk_eth', 'ltc_bnb', 'ltc_btc', 'ltc_eth', 'ltc_usdt', 'mana_btc', 'mana_eth', 'mco_btc', 'mco_eth', 'mda_btc', 'mda_eth', 'mod_btc', 'mod_eth', 'mth_btc', 'mth_eth', 'mtl_btc', 'mtl_eth', 'neo_bnb', 'neo_btc', 'neo_eth', 'neo_usdt', 'nuls_bnb', 'nuls_btc', 'nuls_eth', 'oax_btc', 'oax_eth', 'omg_btc', 'omg_eth', 'poe_btc', 'poe_eth', 'powr_bnb', 'powr_btc', 'powr_eth', 'ppt_btc', 'ppt_eth', 'qsp_bnb', 'qsp_btc', 'qsp_eth', 'qtum_btc', 'qtum_eth', 'rcn_bnb', 'rcn_btc', 'rcn_eth', 'rdn_bnb', 'rdn_btc', 'rdn_eth', 'req_btc', 'req_eth', 'salt_btc', 'salt_eth', 'sngls_btc', 'sngls_eth', 'snm_btc', 'snm_eth', 'snt_btc', 'snt_eth', 'storj_btc', 'storj_eth', 'strat_btc', 'strat_eth', 'sub_btc', 'sub_eth', 'tnb_btc', 'tnb_eth', 'tnt_btc', 'tnt_eth', 'trx_btc', 'trx_eth', 'ven_bnb', 'ven_btc', 'ven_eth', 'vib_btc', 'vib_eth', 'wabi_bnb', 'wabi_btc', 'wabi_eth', 'waves_bnb', 'waves_btc', 'waves_eth', 'wtc_bnb', 'wtc_btc', 'wtc_eth', 'xlm_bnb', 'xlm_btc', 'xlm_eth', 'xmr_btc', 'xmr_eth', 'xrp_btc', 'xrp_eth', 'xvg_btc', 'xvg_eth', 'xzc_bnb', 'xzc_btc', 'xzc_eth', 'yoyo_bnb', 'yoyo_btc', 'yoyo_eth', 'zec_btc', 'zec_eth', 'zrx_btc', 'zrx_eth']

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/enigmampc/catalyst/issues/103#issuecomment-352592491, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZ-QtCOocXTxzQUQ95Sekkyhl2pP8--ks5tBvcagaJpZM4RErXn .

Knifespirit commented 6 years ago

I was backtesting. But I guess that explains why it didnt work. :)

fredfortier commented 6 years ago

I was able to replicate this issue and confirm that it's isolated to Poloniex. Fixing now.

fredfortier commented 6 years ago

Fixed. We'll push a release soon to reflect this.