Пример #1
0
 def setup_method(self):
     self.bitso = BitsoApi(api_server="localhost",
                           api_key="00000000-0000-0000-0000-000000000000",
                           secret_key="bitsosecretkey",
                           timeout=15.5)
Пример #2
0
    def __init__(self, args: list):
        parser = argparse.ArgumentParser(prog='bitso-market-maker-keeper')

        parser.add_argument(
            "--bitso-api-server",
            type=str,
            default="https://api.bitso.com",
            help=
            "Address of the bitso API server (default: 'https://api.bitso.com')"
        )

        parser.add_argument("--bitso-api-key",
                            type=str,
                            required=True,
                            help="API key for the Bitso API")

        parser.add_argument(
            "--bitso-secret-key",
            type=str,
            required=True,
            help="RSA Private Key for signing requests to the BitsoX API")

        parser.add_argument(
            "--bitso-timeout",
            type=float,
            default=9.5,
            help=
            "Timeout for accessing the Bitso API (in seconds, default: 9.5)")

        parser.add_argument(
            "--pair",
            type=str,
            required=True,
            help="Token pair (sell/buy) on which the keeper will operate")

        parser.add_argument("--config",
                            type=str,
                            required=True,
                            help="Bands configuration file")

        parser.add_argument("--price-feed",
                            type=str,
                            required=True,
                            help="Source of price feed")

        parser.add_argument(
            "--price-feed-expiry",
            type=int,
            default=120,
            help="Maximum age of the price feed (in seconds, default: 120)")

        parser.add_argument("--spread-feed",
                            type=str,
                            help="Source of spread feed")

        parser.add_argument(
            "--spread-feed-expiry",
            type=int,
            default=3600,
            help="Maximum age of the spread feed (in seconds, default: 3600)")

        parser.add_argument("--control-feed",
                            type=str,
                            help="Source of control feed")

        parser.add_argument(
            "--control-feed-expiry",
            type=int,
            default=86400,
            help="Maximum age of the control feed (in seconds, default: 86400)"
        )

        parser.add_argument("--order-history",
                            type=str,
                            help="Endpoint to report active orders to")

        parser.add_argument(
            "--order-history-every",
            type=int,
            default=30,
            help=
            "Frequency of reporting active orders (in seconds, default: 30)")

        parser.add_argument(
            "--refresh-frequency",
            type=int,
            default=3,
            help="Order book refresh frequency (in seconds, default: 3)")

        parser.add_argument("--debug",
                            dest='debug',
                            action='store_true',
                            help="Enable debug output")

        self.arguments = parser.parse_args(args)
        setup_logging(self.arguments)

        self.bands_config = ReloadableConfig(self.arguments.config)
        self.price_feed = PriceFeedFactory().create_price_feed(self.arguments)
        self.spread_feed = create_spread_feed(self.arguments)
        self.control_feed = create_control_feed(self.arguments)
        self.order_history_reporter = create_order_history_reporter(
            self.arguments)

        self.history = History()
        self.bitso_api = BitsoApi(api_server=self.arguments.bitso_api_server,
                                  api_key=self.arguments.bitso_api_key,
                                  secret_key=self.arguments.bitso_secret_key,
                                  timeout=self.arguments.bitso_timeout)

        self.order_book_manager = OrderBookManager(
            refresh_frequency=self.arguments.refresh_frequency)
        self.order_book_manager.get_orders_with(
            lambda: self.bitso_api.get_orders(self.pair()))
        self.order_book_manager.get_balances_with(
            lambda: self.bitso_api.get_balances())
        self.order_book_manager.cancel_orders_with(
            lambda order: self.bitso_api.cancel_order(order.order_id))
        self.order_book_manager.enable_history_reporting(
            self.order_history_reporter, self.our_buy_orders,
            self.our_sell_orders)
        self.order_book_manager.start()
Пример #3
0
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys

from pyexchange.bitso import BitsoApi
from pymaker.numeric import Wad

bitso = BitsoApi('https://api.bitso.com', sys.argv[1], sys.argv[2], 9.5)
print("Starting BitsoApi with the following parameters: ", sys.argv)

# GET "/v3/balance/"
# print(bitso.get_balances())

#print(bitso.get_markets())
# print(bitso.get_pair('ETH/USDC'))

# GET "/api/v1/orders"
# print(bitso.get_orders('eth_mxn'))

# POST /api/v1/orders
# print(bitso.place_order('eth_mxn', 'buy', 5200.000, .01))

# DELETE /api/v1/orders/{order_id}