Mizar
  • Whitepaper
    • Abstract
    • C-Mizar
      • Problem
      • Solution
      • Opportunity
      • Product
        • Marketplace
        • DCA Bots
        • API Bots
        • Smart Trading
        • Paper Trading
        • Portfolio Manager
    • D-Mizar
      • Problem
      • Solution
      • Opportunity
      • Product
        • Contract Sniffer
        • Sniper Bot
    • $MZR Token
      • Use Cases
      • Token Metrics
      • Vesting Schedule and Release
      • FAQ
    • Roadmap
      • Supersonic Phase (C-Phase)
      • Hypersonic Phase (D-Phase)
    • Team
  • SDK
    • DCA Bots
      • DCA Bot SDK
      • DCA Bot - TradingView
    • API Bots
      • API Trading SDK
      • API Trading - TradingView
  • Mizar AI (on hold)
    • Mizar AI (on hold)
    • Data Sources
    • Model
      • Downsampling with CUSUM Filter
      • Average Uniqueness
      • Sample Weights
      • Sequentially Bootstrapped Bagging Classifier
      • Metalabeling
      • Bet Sizing
      • Combinatorial Purged Cross Validation
    • Structural Breaks
    • Transformations
      • Labeling Methods
      • Technical Analysis Features
      • Microstructural Features
    • Strategy Backtesting
    • Strategy Deployment
Powered by GitBook
On this page
  • Open Position
  • Close Position
  • Shift Safety Orders
  • Close All Positions
  • Stop Bot and Close all positions
  • Get Open Positions
  • Get Safety Orders
  • Get Active Safety Orders
  • Get Inactive Safety Orders
  • Get Take Profit Orders

Was this helpful?

  1. SDK
  2. DCA Bots

DCA Bot SDK

PreviousDCA BotsNextDCA Bot - TradingView

Last updated 2 years ago

Was this helpful?

Install the Mizar and follow the instruction below.

Open Position

from mizar import Mizar

mizar_client = Mizar()

mizar_client.dca_bot_open_position(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT",
)

It is allowed to override the take profit and stop loss of the bot for

mizar_client.dca_bot_open_position(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT",
    take_profit_pct=0.05
    stop_loss_pct=0.10
)

Expected response

{'detail': 
'Request with action open-position has been successfully submitted to bot 1 that has 1 subscriptions.'}

Close Position

mizar_client.dca_bot_close_position(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT",
)

Expected response

{'detail': 
'Request with action close-position has been successfully submitted to bot 1 that has 1 subscriptions.'}

Shift Safety Orders

mizar_client.dca_bot_shift_safety_orders(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT",
    safety_orders_start_price=45000
)

Expected response

{'detail': 
'Request with action shift-safety-orders has been successfully submitted to bot 1 that has 1 subscriptions.'}

Close All Positions

mizar_client.dca_bot_close_positions(
    bot_id=1,
)

Expected response

{'detail': 
'Request with action close-all-positions has been successfully submitted to bot 1 that has 1 subscriptions.'}

Stop Bot and Close all positions

mizar_client.dca_bot_stop_and_close_positions(
    bot_id=1,
)

Expected response

{'detail': 
'Request with action stop-bot-and-close-all-positions has been successfully submitted to bot 1 that has 1 subscriptions.'}

Get Open Positions

mizar_client.get_dca_bot_position(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT"
)

Expected response

{'data': {'symbol': 'BTCUSDT',
  'start_condition_datetime': '2021-08-31T17:21:02.953815',
  'take_profit_type': 'total',
  'take_profit_pct': 0.01,
  'stop_loss_pct': None,
  'safety_order_deviation_pct': 0.015,
  'safety_order_step_scale': 1.05,
  'safety_order_quote_size': 150.0,
  'safety_order_volume_scale': 1.05,
  'max_num_safety_order': 5,
  'side': 'buy',
  'base_orders': [{'id': '30331250182',
    'status': 'canceled',
    'timestamp': 1630430469415,
    'price': 47415.4,
    'filled': 0.0,
    'remaining': 0.005},
   {'id': '30331253419',
    'status': 'canceled',
    'timestamp': 1630430476596,
    'price': 47418.5,
    'filled': 0.0,
    'remaining': 0.005},
   {'id': '30331257401',
    'status': 'canceled',
    'timestamp': 1630430485760,
    'price': 47418.86,
    'filled': 0.0,
    'remaining': 0.005},
   {'id': '30331263515',
    'status': 'closed',
    'timestamp': 1630430486088,
    'price': 47423.37,
    'filled': 0.005,
    'remaining': 0.0}],
  'active_safety_orders': [{'id': '30331268368',
    'status': 'open',
    'timestamp': 1630430492830,
    'price': 46712.02,
    'filled': 0.0,
    'remaining': 0.003}],
  'take_profit_order': {'id': '30331267657',
   'status': 'open',
   'timestamp': 1630430491891,
   'price': 47897.6,
   'filled': 0.0,
   'remaining': 0.005},
  'inactive_safety_orders': [],
  'inactive_take_profit_orders': []}}

Get Safety Orders

mizar_client.get_dca_bot_safety_orders(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT"
)

Expected response

{'data': [{'id': '30331268368',
   'status': 'open',
   'timestamp': 1630430492830,
   'price': 46712.02,
   'filled': 0.0,
   'remaining': 0.003}]}

Get Active Safety Orders

mizar_client.get_dca_bot_active_safety_orders(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT"
)

Expected response

{'data': [{'id': '30331268368',
   'status': 'open',
   'timestamp': 1630430492830,
   'price': 46712.02,
   'filled': 0.0,
   'remaining': 0.003}]}

Get Inactive Safety Orders

mizar_client.get_dca_bot_inactive_safety_orders(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT"
)

Expected response

{'data': [{'id': '30331268368',
   'status': 'canceled',
   'timestamp': 1630430658612,
   'price': 46712.02,
   'filled': 0.0,
   'remaining': 0.003}]}

Get Take Profit Orders

mizar_client.get_dca_bot_take_profit_orders(
    bot_id=1,
    base_asset="BTC",
    quote_asset="USDT"
)

Expected response

{'data': [{'id': '30331268368',
   'status': 'canceled',
   'timestamp': 1630430658612,
   'price': 46712.02,
   'filled': 0.0,
   'remaining': 0.003}]}
client