Skip to content

Broker

Broker

buy(name=None, amount=1, limit=None, stop_loss=None, take_profit=None)

Places a buy order.

Parameters:

Name Type Description Default
name str | None

The name of the data source to buy from. If None, the first data source in the context will be used.

None
amount float

The amount of shares to buy.

1
limit float | None

The limit price to buy at. If None, a market order will be placed.

None
stop_loss float | None

The stop loss price to use. If None, no stop loss will be used.

None
take_profit float | None

The take profit price to use. If None, no take profit will be used.

None

close(data_name=None)

Closes all open positions.

Parameters:

Name Type Description Default
name

The name of the data source to close positions from. If None, the first data source in the context will be used.

required

equity()

Get the current equity at the current time.

Returns:

Type Description
float

The current equity.

is_closed(name=None)

Checks if the broker is closed.

Parameters:

Name Type Description Default
name str | None

The name of the data source to check. If None, the first data source in the context will be used.

None

Returns:

Type Description
bool

True if the broker is closed, False otherwise.

is_long(name=None)

Checks if the broker is long.

Parameters:

Name Type Description Default
name str | None

The name of the data source to check. If None, the first data source in the context will be used.

None

Returns:

Type Description
bool

True if the broker is long, False otherwise.

is_short(name=None)

Checks if the broker is short.

Parameters:

Name Type Description Default
name str | None

The name of the data source to check. If None, the first data source in the context will be used.

None

Returns:

Type Description
bool

True if the broker is short, False otherwise.

sell(name=None, amount=1, limit=None, stop_loss=None, take_profit=None)

Places a sell order.

Parameters:

Name Type Description Default
name str | None

The name of the data source to sell from. If None, the first data source in the context will be used.

None
amount float

The amount of shares to sell.

1
limit float | None

The limit price to sell at. If None, a market order will be placed.

None
stop_loss float | None

The stop loss price to use. If None, no stop loss will be used.

None
take_profit float | None

The take profit price to use. If None, no take profit will be used.

None