-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (31 loc) · 1.24 KB
/
main.py
File metadata and controls
44 lines (31 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from alpaca.trading.client import TradingClient
from alpaca.trading.requests import GetAssetsRequest, MarketOrderRequest, LimitOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce, OrderType
import os
from dotenv import load_dotenv
from sqldb import updateData
load_dotenv()
API_KEY = os.getenv('API_KEY')
SECRET_KEY = os.getenv('SECRET_KEY')
market_order_data = MarketOrderRequest(
symbol="SPY",
qty=55,
side=OrderSide.BUY,
time_in_force=TimeInForce.DAY
)
limit_order_data = LimitOrderRequest(
symbol="BTC/USD",
limit_price=17000,
notional=4000,
side=OrderSide.SELL,
time_in_force=TimeInForce.FOK
)
trading_client = TradingClient(API_KEY, SECRET_KEY)
# Get our account information.
account = trading_client.get_account()
# Check if our account is restricted from trading.
if account.trading_blocked:
print('Account is currently restricted from trading.')
# Check how much money we can use to open new positions.
print('${} is available as buying power.'.format(account.buying_power))
updateData(market_order_data)