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

NotEnoughCashError - cash not calculated or wrongly #200

Open demontamer opened 6 years ago

demontamer commented 6 years ago

178 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 have enough cash on bittrex but algo crashes with NotEnoughCashError algo: 0.0<0.1 a minute after calculating cash balance as 0.14btc. I haven't done any manual trades and see image below.

image

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

  1. check if exchange cash is wrongly calculated in new release

What steps have you taken to resolve this already?

I thought this could be as a result of a previous state, so deleted and recreated the live_algos folder.

...

Anything else?

This may be as a result of a previous state. So, will help if I knew the right folder to delete. Or how o ensure a clean start from previous algo states. ...

Sincerely, demontamer

lenak25 commented 6 years ago

Hi, thanks for reporting. Could you please share the command you have run and what was the capital_base you have defined?

demontamer commented 6 years ago

`if name == 'main':

The execution mode: backtest or live

MODE = 'live'

if MODE == 'backtest':
    run_algorithm(
        capital_base=0.2,
        data_frequency='daily',
        initialize=initialize,
        handle_data=handle_data,
        analyze=analyze,
        exchange_name='bittrex',
        algo_namespace=algo_namespace,
        base_currency='btc',
        start=pd.to_datetime('2017-10-1', utc=True),
        # end=pd.to_datetime('2017-9-30', utc=True),
        end=pd.to_datetime('2017-12-31', utc=True),
    )

elif MODE == 'live':
    run_algorithm(
    capital_base = 0.1,
        initialize=initialize,
        handle_data=handle_data,
        analyze=analyze,
        exchange_name='bittrex',
        live=True,
        algo_namespace=algo_namespace,
        base_currency='btc',
    simulate_orders=False,
    live_graph=False
       )`
lenak25 commented 6 years ago

Thanks for the information. We will investigate the issue.

lenak25 commented 6 years ago

Hi @demontamer,

Sorry for the big delay in the response. Cleaning previous algorithm state can be achieved using this command: catalyst clean-algo -n <algo_namspace>. Could you please upgrade to the new catalyst version (0.5.4) and please let us know if you still encounter this issue.

Thanks, Lena

martindobrovicky commented 6 years ago

Hi, I am getting the same error on Catalyst version 0.5.8. I tried cleaning algo previous state with "catalyst clean-algo -n ", but it did not work, I have cash stacked at the same value. It seams that it is stacked with what I set initially in "capital_base=0.1".

In addition it keeps crashing with new error: "catalyst.exchange.exchange_errors.NoCandlesReceivedFromExchange: Although requesting 47 candles until 2018-04-23 17:36:00+00:00 of asset TradingPair(452516 [eth_btc]), an empty list of candles was received for poloniex."

lenak25 commented 6 years ago

@ShaolinStyle the clean should have work. You can check if the algorithm folder is still exist at: ~/.catalyst/data/live_algos/<algorithm-namespace> and delete it if it does. Regarding the candles retrieval, I have tried to reproduce this error but wasn't successful. Is it still happening? If so, please open a new Github issue including the command you have run.

martindobrovicky commented 6 years ago

Clean command is not working for me, don't know why. But if I delete manually algorithm from the folder, it works just fine. I am not getting candle error anymore, I assume I might have spammed plx too much and they temporary banned me, hard to tell. Thank you Lena for your help!