Merge pull request #13 from gcarq/develop
Update from upstream repo gcarq/freqtrade@develop
This commit is contained in:
commit
770b05eb42
@ -317,8 +317,10 @@ class RPC(object):
|
|||||||
and order['side'] == 'buy':
|
and order['side'] == 'buy':
|
||||||
exchange.cancel_order(trade.open_order_id, trade.pair)
|
exchange.cancel_order(trade.open_order_id, trade.pair)
|
||||||
trade.close(order.get('price') or trade.open_rate)
|
trade.close(order.get('price') or trade.open_rate)
|
||||||
# TODO: sell amount which has been bought already
|
# Do the best effort, if we don't know 'filled' amount, don't try selling
|
||||||
return
|
if order['filled'] is None:
|
||||||
|
return
|
||||||
|
trade.amount = order['filled']
|
||||||
|
|
||||||
# Ignore trades with an attached LIMIT_SELL order
|
# Ignore trades with an attached LIMIT_SELL order
|
||||||
if order and order['status'] == 'open' \
|
if order and order['status'] == 'open' \
|
||||||
|
@ -450,20 +450,44 @@ def test_rpc_forcesell(default_conf, ticker, fee, mocker) -> None:
|
|||||||
freqtradebot.state = State.RUNNING
|
freqtradebot.state = State.RUNNING
|
||||||
assert cancel_order_mock.call_count == 0
|
assert cancel_order_mock.call_count == 0
|
||||||
# make an limit-buy open trade
|
# make an limit-buy open trade
|
||||||
|
trade = Trade.query.filter(Trade.id == '1').first()
|
||||||
|
filled_amount = trade.amount / 2
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
'freqtrade.freqtradebot.exchange.get_order',
|
'freqtrade.freqtradebot.exchange.get_order',
|
||||||
return_value={
|
return_value={
|
||||||
'status': 'open',
|
'status': 'open',
|
||||||
'type': 'limit',
|
'type': 'limit',
|
||||||
'side': 'buy'
|
'side': 'buy',
|
||||||
|
'filled': filled_amount
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
# check that the trade is called, which is done
|
# check that the trade is called, which is done by ensuring exchange.cancel_order is called
|
||||||
# by ensuring exchange.cancel_order is called
|
# and trade amount is updated
|
||||||
(error, res) = rpc.rpc_forcesell('1')
|
(error, res) = rpc.rpc_forcesell('1')
|
||||||
assert not error
|
assert not error
|
||||||
assert res == ''
|
assert res == ''
|
||||||
assert cancel_order_mock.call_count == 1
|
assert cancel_order_mock.call_count == 1
|
||||||
|
assert trade.amount == filled_amount
|
||||||
|
|
||||||
|
freqtradebot.create_trade()
|
||||||
|
trade = Trade.query.filter(Trade.id == '2').first()
|
||||||
|
amount = trade.amount
|
||||||
|
# make an limit-buy open trade, if there is no 'filled', don't sell it
|
||||||
|
mocker.patch(
|
||||||
|
'freqtrade.freqtradebot.exchange.get_order',
|
||||||
|
return_value={
|
||||||
|
'status': 'open',
|
||||||
|
'type': 'limit',
|
||||||
|
'side': 'buy',
|
||||||
|
'filled': None
|
||||||
|
}
|
||||||
|
)
|
||||||
|
# check that the trade is called, which is done by ensuring exchange.cancel_order is called
|
||||||
|
(error, res) = rpc.rpc_forcesell('2')
|
||||||
|
assert not error
|
||||||
|
assert res == ''
|
||||||
|
assert cancel_order_mock.call_count == 2
|
||||||
|
assert trade.amount == amount
|
||||||
|
|
||||||
freqtradebot.create_trade()
|
freqtradebot.create_trade()
|
||||||
# make an limit-sell open trade
|
# make an limit-sell open trade
|
||||||
@ -475,11 +499,11 @@ def test_rpc_forcesell(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'side': 'sell'
|
'side': 'sell'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(error, res) = rpc.rpc_forcesell('2')
|
(error, res) = rpc.rpc_forcesell('3')
|
||||||
assert not error
|
assert not error
|
||||||
assert res == ''
|
assert res == ''
|
||||||
# status quo, no exchange calls
|
# status quo, no exchange calls
|
||||||
assert cancel_order_mock.call_count == 1
|
assert cancel_order_mock.call_count == 2
|
||||||
|
|
||||||
|
|
||||||
def test_performance_handle(default_conf, ticker, limit_buy_order, fee,
|
def test_performance_handle(default_conf, ticker, limit_buy_order, fee,
|
||||||
|
71
setup.sh
71
setup.sh
@ -2,16 +2,17 @@
|
|||||||
#encoding=utf8
|
#encoding=utf8
|
||||||
|
|
||||||
function updateenv () {
|
function updateenv () {
|
||||||
echo "
|
echo "-------------------------"
|
||||||
-------------------------
|
echo "Update your virtual env"
|
||||||
Update your virtual env
|
echo "-------------------------"
|
||||||
-------------------------
|
|
||||||
"
|
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
pip3.6 install --upgrade pip
|
echo "pip3 install in-progress. Please wait..."
|
||||||
pip3 install -r requirements.txt --upgrade
|
pip3.6 install --quiet --upgrade pip
|
||||||
pip3 install -r requirements.txt
|
pip3 install --quiet -r requirements.txt --upgrade
|
||||||
pip3 install -e .
|
pip3 install --quiet -r requirements.txt
|
||||||
|
pip3 install --quiet -e .
|
||||||
|
echo "pip3 install completed"
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install tab lib
|
# Install tab lib
|
||||||
@ -29,10 +30,11 @@ function install_macos () {
|
|||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo "Install Brew"
|
echo "Install Brew"
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo
|
|
||||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||||
fi
|
fi
|
||||||
brew install python3 wget ta-lib
|
brew install python3 wget ta-lib
|
||||||
|
|
||||||
|
test_and_fix_python_on_mac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install bot Debian_ubuntu
|
# Install bot Debian_ubuntu
|
||||||
@ -54,7 +56,6 @@ function reset () {
|
|||||||
echo "----------------------------"
|
echo "----------------------------"
|
||||||
echo "Reset branch and virtual env"
|
echo "Reset branch and virtual env"
|
||||||
echo "----------------------------"
|
echo "----------------------------"
|
||||||
echo
|
|
||||||
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* master") ]
|
if [ "1" == $(git branch -vv |grep -cE "\* develop|\* master") ]
|
||||||
then
|
then
|
||||||
if [ -d ".env" ]; then
|
if [ -d ".env" ]; then
|
||||||
@ -77,18 +78,30 @@ function reset () {
|
|||||||
echo "Reset ignored because you are not on 'master' or 'develop'."
|
echo "Reset ignored because you are not on 'master' or 'develop'."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
python3.6 -m venv .env
|
python3.6 -m venv .env
|
||||||
updateenv
|
updateenv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_and_fix_python_on_mac() {
|
||||||
|
|
||||||
|
if ! [ -x "$(command -v python3.6)" ]
|
||||||
|
then
|
||||||
|
echo "-------------------------"
|
||||||
|
echo "Fixing Python"
|
||||||
|
echo "-------------------------"
|
||||||
|
echo "Python 3.6 is not linked in your system. Fixing it..."
|
||||||
|
brew link --overwrite python
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function config_generator () {
|
function config_generator () {
|
||||||
|
|
||||||
echo "Starting to generate config.json"
|
echo "Starting to generate config.json"
|
||||||
|
echo
|
||||||
echo "-------------------------"
|
|
||||||
echo "General configuration"
|
echo "General configuration"
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo
|
|
||||||
default_max_trades=3
|
default_max_trades=3
|
||||||
read -p "Max open trades: (Default: $default_max_trades) " max_trades
|
read -p "Max open trades: (Default: $default_max_trades) " max_trades
|
||||||
max_trades=${max_trades:-$default_max_trades}
|
max_trades=${max_trades:-$default_max_trades}
|
||||||
@ -105,14 +118,13 @@ function config_generator () {
|
|||||||
read -p "Fiat currency: (Default: $default_fiat_currency) " fiat_currency
|
read -p "Fiat currency: (Default: $default_fiat_currency) " fiat_currency
|
||||||
fiat_currency=${fiat_currency:-$default_fiat_currency}
|
fiat_currency=${fiat_currency:-$default_fiat_currency}
|
||||||
|
|
||||||
echo "------------------------"
|
|
||||||
echo "Bittrex config generator"
|
|
||||||
echo "------------------------"
|
|
||||||
echo
|
echo
|
||||||
|
echo "Exchange config generator"
|
||||||
|
echo "------------------------"
|
||||||
read -p "Exchange API key: " api_key
|
read -p "Exchange API key: " api_key
|
||||||
read -p "Exchange API Secret: " api_secret
|
read -p "Exchange API Secret: " api_secret
|
||||||
|
|
||||||
echo "-------------------------"
|
echo
|
||||||
echo "Telegram config generator"
|
echo "Telegram config generator"
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
read -p "Telegram Token: " token
|
read -p "Telegram Token: " token
|
||||||
@ -131,6 +143,10 @@ function config_generator () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function config () {
|
function config () {
|
||||||
|
|
||||||
|
echo "-------------------------"
|
||||||
|
echo "Config file generator"
|
||||||
|
echo "-------------------------"
|
||||||
if [ -f config.json ]
|
if [ -f config.json ]
|
||||||
then
|
then
|
||||||
read -p "A config file already exist, do you want to override it [Y/N]? "
|
read -p "A config file already exist, do you want to override it [Y/N]? "
|
||||||
@ -144,22 +160,26 @@ function config () {
|
|||||||
config_generator
|
config_generator
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "-------------------------"
|
||||||
|
echo "Config file generated"
|
||||||
|
echo "-------------------------"
|
||||||
echo "Edit ./config.json to modify Pair and other configurations."
|
echo "Edit ./config.json to modify Pair and other configurations."
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
function install () {
|
function install () {
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo "Install mandatory dependencies"
|
echo "Install mandatory dependencies"
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo
|
|
||||||
|
|
||||||
if [ "$(uname -s)" == "Darwin" ]
|
if [ "$(uname -s)" == "Darwin" ]
|
||||||
then
|
then
|
||||||
echo "- You are on macOS"
|
echo "macOS detected. Setup for this system in-progress"
|
||||||
install_macos
|
install_macos
|
||||||
elif [ -x "$(command -v apt-get)" ]
|
elif [ -x "$(command -v apt-get)" ]
|
||||||
then
|
then
|
||||||
echo "- You are on Debian/Ubuntu"
|
echo "Debian/Ubuntu detected. Setup for this system in-progress"
|
||||||
install_debian
|
install_debian
|
||||||
else
|
else
|
||||||
echo "This script does not support your OS."
|
echo "This script does not support your OS."
|
||||||
@ -167,12 +187,13 @@ function install () {
|
|||||||
echo "Wait 10 seconds to continue the next install steps or use ctrl+c to interrupt this shell."
|
echo "Wait 10 seconds to continue the next install steps or use ctrl+c to interrupt this shell."
|
||||||
sleep 10
|
sleep 10
|
||||||
fi
|
fi
|
||||||
|
echo
|
||||||
reset
|
reset
|
||||||
echo "
|
|
||||||
- Install complete.
|
|
||||||
"
|
|
||||||
config
|
config
|
||||||
echo "You can now use the bot by executing 'source .env/bin/activate; python3 freqtrade/main.py'."
|
echo "-------------------------"
|
||||||
|
echo "Run the bot"
|
||||||
|
echo "-------------------------"
|
||||||
|
echo "You can now use the bot by executing 'source .env/bin/activate; python3.6 freqtrade/main.py'."
|
||||||
}
|
}
|
||||||
|
|
||||||
function plot () {
|
function plot () {
|
||||||
|
Loading…
Reference in New Issue
Block a user