forked from withbelay/alpaca-broker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
46 lines (40 loc) · 1.55 KB
/
Copy pathindex.ts
File metadata and controls
46 lines (40 loc) · 1.55 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
43
44
45
46
import * as api from './api'
// export all APIs and models so they can be used individually if desired
export * from './api'
export * from './events'
interface AlpacaEnvironment {
[env: string]: string
}
export const AlpacaEnvironments: { [env: string]: string } = {
sandbox: 'https://broker-api.sandbox.alpaca.markets/v1',
production: 'https://broker-api.alpaca.markets/v1'
}
export class AlpacaApi {
accounts: api.AccountsApi
assets: api.AssetsApi
calendar: api.CalendarApi
clock: api.ClockApi
documents: api.DocumentsApi
events: api.EventsApi
funding: api.FundingApi
journals: api.JournalsApi
oauth: api.OAuthApi
trading: api.TradingApi
constructor({ apiKey, apiSecret, basePath }: { apiKey: string; apiSecret: string; basePath: string }) {
this.accounts = new api.AccountsApi(apiKey, apiSecret, basePath)
this.assets = new api.AssetsApi(apiKey, apiSecret, basePath)
this.calendar = new api.CalendarApi(apiKey, apiSecret, basePath)
this.clock = new api.ClockApi(apiKey, apiSecret, basePath)
this.documents = new api.DocumentsApi(apiKey, apiSecret, basePath)
this.events = new api.EventsApi(apiKey, apiSecret, basePath)
this.funding = new api.FundingApi(apiKey, apiSecret, basePath)
this.journals = new api.JournalsApi(apiKey, apiSecret, basePath)
this.oauth = new api.OAuthApi(apiKey, apiSecret, basePath)
this.trading = new api.TradingApi(apiKey, apiSecret, basePath)
}
}
export enum AlpacaErrorCode {
INVALID_FORMAT = 40010000,
INSUFFICIENT_BUYING_POWER = 40310000,
ACH_ALREADY_ACTIVE = 40910000
}