Comments (1)
just did this and forgot about it
#[derive(Debug, ThisError)]
enum BrokerError {
#[error("Alpaca error: {0}")]
AlpacaError(String),
}
#[axum::async_trait]
pub trait BrokerClient: Send + Sync {
async fn get_account(&self) -> Result<Account, BrokerError>;
async fn get_positions(&self) -> Result<(), BrokerError>;
async fn get_orders(&self) -> Result<(), BrokerError>;
async fn place_order(&self, order: &Order, broker: &Broker) -> Result<(), BrokerError>;
async fn cancel_order(&self) -> Result<(), BrokerError>;
async fn cancel_all_orders(&self) -> Result<(), BrokerError>;
}
#[axum::async_trait]
impl BrokerClient for Arc<AlpacaClient> {
async fn get_account(&self) -> Result<Account, BrokerError> {
let result = self
.issue::<account::Get>(&())
.await
.map_err(|e| BrokerError::AlpacaError(e.to_string()))?;
Ok(Account::AlpacaAccount(result))
}
async fn get_positions(&self) -> Result<(), BrokerError> {
Ok(())
}
async fn get_orders(&self) -> Result<(), BrokerError> {
Ok(())
}
async fn place_order(&self, order: &Order, broker: &Broker) -> Result<(), BrokerError> {
Ok(())
}
async fn cancel_order(&self) -> Result<(), BrokerError> {
Ok(())
}
async fn cancel_all_orders(&self) -> Result<(), BrokerError> {
Ok(())
}
}
from apca.
Related Issues (20)
- Oauth support? HOT 6
- Hook up portfolio history HOT 3
- support for Latest Multi Trades HOT 1
- Discussion: GPL? HOT 2
- Issue or missunderstanding related to subscriptions. HOT 4
- Calendar date/time. HOT 2
- Tokio using Mio prevents compiling to WASM HOT 1
- UUID using Getrandom and Rand prevents compiling to WASM HOT 1
- Support more Trade properties HOT 11
- Proposal: Use a dedicated data type for stock symbols instead of String HOT 2
- Live trading example not updated HOT 1
- Adding support for crypto streaming HOT 7
- Optionally use rustls instead of hyper-tls HOT 5
- example of streaming data with handlers HOT 3
- Support missing real-time streaming channels HOT 2
- automatic websocket reconnection HOT 3
- What's the point to have Get/Post errors if all what you can get is `the endpoint reported an error`... HOT 1
- Implementing Options Trading for Beta Users in Alpaca's Paper Environment HOT 2
- Support for Rebalancing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apca.