forked from moqui/moqui-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1, Add AlpacaToolFactory.groovy, finished load the AlpacaToolFactory.
2, The manner of invoking trading api needs to be optimized and normalized.
- Loading branch information
1 parent
a1cb63d
commit fa49839
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
framework/src/main/groovy/org/moqui/impl/tools/AlpacaToolFactory.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.moqui.impl.tools | ||
|
||
/** | ||
* @Title: AlpacaToolFactory | ||
* @Package org.moqui.impl.tools | ||
* @Description: //TODO | ||
* @author lucasyuan | ||
* @date 8/13/23 | ||
* @version V1.0 | ||
*/ | ||
import groovy.transform.CompileStatic; | ||
import net.jacobpeterson.alpaca.AlpacaAPI; | ||
import org.moqui.context.ExecutionContextFactory; | ||
import org.moqui.context.ToolFactory; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* @author ianyuan | ||
* @version V1.0 | ||
* @Title: AlpacaToolFactory | ||
* @Package com.edt.tradecube.alpaca.marketdata | ||
* @Description: //TODO | ||
* @date 8/6/23 | ||
*/ | ||
@CompileStatic | ||
public class AlpacaToolFactory implements ToolFactory { | ||
|
||
protected final static Logger logger = LoggerFactory.getLogger(AlpacaToolFactory.class); | ||
final static String TOOL_NAME = "Alpaca"; | ||
|
||
protected ExecutionContextFactory ecf = null; | ||
|
||
/** AlpacaAPI instance */ | ||
private AlpacaAPI alpacaAPI = null; | ||
@Override | ||
public void init(ExecutionContextFactory ecf) { | ||
|
||
if( alpacaAPI == null ){ | ||
this.ecf = ecf; | ||
alpacaAPI = new AlpacaAPI(); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public String getName() { | ||
return TOOL_NAME; | ||
} | ||
|
||
@Override | ||
public void preFacadeInit(ExecutionContextFactory ecf) { | ||
|
||
if( alpacaAPI == null ){ | ||
this.ecf = ecf; | ||
alpacaAPI = new AlpacaAPI(); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public AlpacaAPI getInstance(Object... parameters) { | ||
if (alpacaAPI == null) throw new IllegalStateException("AlpacaToolFactory not initialized"); | ||
return this.alpacaAPI; | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#paper trading | ||
key_id = PK0Y91VLYX2I8A3G8AOJ | ||
secret_key = p3vvkuE7Q0L96r5Mbexoj7jvOPFpjwL927nLqVLS | ||
#live trading | ||
#key_id = AKFVIRWOD6CRKMR5Z4SR | ||
#secret_key = ck32dBEgnTnTR0U19LkfrAEcIrcJwL2bEkT6sAQN | ||
endpoint_api_type=paper | ||
data_api_type=iex | ||
user_agent=JavaRuntimeEnvironment/ OkHttp/4.9.1 |